Bees v0.5.0 API

bees.core
Class Node

java.lang.Object
  |
  +--bees.core.Capability
        |
        +--bees.core.NodeSpec
              |
              +--bees.core.Node
All Implemented Interfaces:
CapabilitySpec, edu.utah.janosvm.kit.comm.jsi.JSIHandler, NodeCache.EventHandler

public final class Node
extends NodeSpec
implements NodeCache.EventHandler, edu.utah.janosvm.kit.comm.jsi.JSIHandler

The Node class provides access to node global functionality.


Field Summary
static PermissionSet DEFAULT_PERMISSIONS
          The default permissions for a new Node object.
static Permission JSI_REGISTER
          Permission to register a JSI handler.
static Permission PROTOCOL_REGISTER
          Permission for registering a protocol.
static Permission READ_NODE_NAME
          Permission for reading the node name.
static Permission READ_NODE_VERSION
          Permission for reading the node version info.
static Permission THREAD_START
          Permission for starting a thread.
 
Fields inherited from class bees.core.Capability
DELETE_PERMISSION, id, INVALID_ID
 
Constructor Summary
Node()
          Construct an empty Node object.
 
Method Summary
 void arraycopy(java.lang.Object src, int src_position, java.lang.Object dst, int dst_position, int length)
           
 void beginManagement(ProtocolSession ps)
          Send a request to the Auth Application asking for it to manage the given protocol.
 IntegerPermission collected(Node node, ProtocolSession ps)
          This is called when this element is up for collection, the return value specifies the new expiration time.
protected  void fromBytes(byte[] flattened, CapabilityEnvelope[] ce)
          Bind this capability to the given object.
 Authorizer getAuthorizer()
           
 Capability getCapability(java.lang.String name)
          Get a user capability from the capability tree.
 ObjectMap getCapabilityMap(java.lang.String name)
          Get a user subtree from the capability tree.
 IntegerPermission getInactivityTimeout()
           
 java.lang.String getName()
           
 void getSuites(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
           
 java.lang.String getVersion()
           
 void handleMessage(edu.utah.janosvm.kit.comm.jsi.JSIHandlerContext jhc, edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
           
 boolean isOnFire()
           
 boolean pass(ProtocolPresentation pp, CapabilityTree ct)
           
 DLProtocolPresentation register(DLProtocolPresentation retval, NeighborImpl ni, PairChain flowDesc, Capability[] initialCaps, PermissionSet transfer, CapabilityTree ct)
          Create a new domain and load the protocol from a neighbor.
 DLProtocolPresentation register(NeighborImpl ni, PairChain flowDesc, Capability[] initialCaps, PermissionSet transfer, CapabilityTree ct)
          Create a new domain and load the protocol from a neighbor.
 void register(ProtocolPresentation pp, CapabilityEnvelope ce, TypeID sessionID)
          Connect the given presentation to a protocol session in another domain.
 void register(ProtocolPresentation pp, ProtocolFlow pf, Capability[] initialCaps, PermissionSet ps, CapabilityTree ct)
          Create a new domain and load a protocol from the local disk.
 void removed(Node node, ProtocolSession ps)
          This is called when the element is manually removed from from the cache.
 CapabilityEnvelope[] requestCapability(java.lang.String src, java.lang.String dst, byte[] auth)
          Request a capability from the Auth Application.
 edu.utah.janosvm.kit.comm.jsi.JSIHandler resolveSpecifier(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm, edu.utah.janosvm.kit.comm.jsi.JSIPair jp)
           
 void revoke()
          Revoke access to the capability.
 void setAuthorizer(Authorizer authorizer)
           
 void setInactivityTimeout(IntegerPermission ip)
           
 void setJSIHandler(java.lang.String name, edu.utah.janosvm.kit.comm.jsi.JSIHandler jh)
          Set the JSIHandler for a given subproperty.
 void shutdown()
          Shutdown the BDomain containing this node.
 void sleep(long millis)
          Put the current thread to sleep for the given number of milliseconds.
 void threadStart(java.lang.Runnable r)
          Create and start a new thread with a default name.
 void threadStart(java.lang.Runnable r, java.lang.String threadName)
          Create and start a new thread.
 java.lang.String toShortString()
           
 java.lang.String toString()
           
 
Methods inherited from class bees.core.NodeSpec
getFactory, specFromBytes, toBytes
 
Methods inherited from class bees.core.Capability
checkPermission, clear, clonePermission, deleteCapability, equals, fromBytes, revokedPermission, revokePermission, revokePermissions, valid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

READ_NODE_NAME

public static final Permission READ_NODE_NAME
Permission for reading the node name.

READ_NODE_VERSION

public static final Permission READ_NODE_VERSION
Permission for reading the node version info.

THREAD_START

public static final Permission THREAD_START
Permission for starting a thread.

PROTOCOL_REGISTER

public static final Permission PROTOCOL_REGISTER
Permission for registering a protocol.

JSI_REGISTER

public static final Permission JSI_REGISTER
Permission to register a JSI handler.

DEFAULT_PERMISSIONS

public static final PermissionSet DEFAULT_PERMISSIONS
The default permissions for a new Node object.
Constructor Detail

Node

public Node()
Construct an empty Node object.
Method Detail

fromBytes

protected void fromBytes(byte[] flattened,
                         CapabilityEnvelope[] ce)
                  throws java.lang.Exception
Description copied from class: Capability
Bind this capability to the given object.
Overrides:
fromBytes in class Capability
See Also:
Capability.fromBytes(byte[], CapabilityEnvelope[])

revoke

public void revoke()
Description copied from class: Capability
Revoke access to the capability.
Overrides:
revoke in class Capability
See Also:
Capability.revoke()

getAuthorizer

public Authorizer getAuthorizer()
Returns:
This node's "authorizer" handler.

setAuthorizer

public void setAuthorizer(Authorizer authorizer)
Parameters:
authorizer - This node's "authorizer" handler.

getCapabilityMap

public ObjectMap getCapabilityMap(java.lang.String name)
                           throws java.util.NoSuchElementException
Get a user subtree from the capability tree.
Parameters:
name - The name of the subtree.
Returns:
The ObjectMap matching the given name.
Throws:
java.util.NoSuchElementException - if the subtree couldn't be found.

getCapability

public Capability getCapability(java.lang.String name)
                         throws java.util.NoSuchElementException
Get a user capability from the capability tree.
Parameters:
name - The name of the capability.
Returns:
The Capability matching the given name.
Throws:
java.util.NoSuchElementException - if the capability couldn't be found.

getName

public java.lang.String getName()
Overrides:
getName in class NodeSpec
Returns:
The name of this node.

getVersion

public java.lang.String getVersion()
Overrides:
getVersion in class NodeSpec
Returns:
The the version of Bees on this node.

setInactivityTimeout

public void setInactivityTimeout(IntegerPermission ip)
Parameters:
ip - Permission that indicates the number of milliseconds this node should live for without any activity.

getInactivityTimeout

public IntegerPermission getInactivityTimeout()
Returns:
Permission that indicates the number of milliseconds this node should live for without any activity.

removed

public final void removed(Node node,
                          ProtocolSession ps)
Description copied from interface: NodeCache.EventHandler
This is called when the element is manually removed from from the cache.
Specified by:
removed in interface NodeCache.EventHandler
See Also:
NodeCache.EventHandler.removed(Node, ProtocolSession)

collected

public final IntegerPermission collected(Node node,
                                         ProtocolSession ps)
Description copied from interface: NodeCache.EventHandler
This is called when this element is up for collection, the return value specifies the new expiration time. Null is returned if the element should really be collected.
Specified by:
collected in interface NodeCache.EventHandler
See Also:
NodeCache.EventHandler.collected(Node, ProtocolSession)

beginManagement

public void beginManagement(ProtocolSession ps)
                     throws java.util.NoSuchElementException
Send a request to the Auth Application asking for it to manage the given protocol. XXX This should probably be moved into ProtocolSession.
Parameters:
ps - The ProtocolSession to be managed.
Throws:
java.util.NoSuchElementException - If the "authenticator" capability could not be found.

requestCapability

public CapabilityEnvelope[] requestCapability(java.lang.String src,
                                              java.lang.String dst,
                                              byte[] auth)
                                       throws java.lang.IllegalStateException
Request a capability from the Auth Application.
Parameters:
src - The name of the capability in the Auth Applications name space.
dst - The name of the capability in this domain's name space.
auth - The Auth data required to gain access to the requested capabilities.
Returns:
An array of CapabilityEnvelopes containing the requested capabilities or null if the capabilities were not available.
Throws:
java.lang.IllegalStateException - If beginManagement was not called before requesting the capability.

pass

public boolean pass(ProtocolPresentation pp,
                    CapabilityTree ct)

register

public void register(ProtocolPresentation pp,
                     ProtocolFlow pf,
                     Capability[] initialCaps,
                     PermissionSet ps,
                     CapabilityTree ct)
              throws BDomainCreationException,
                     java.lang.ClassNotFoundException,
                     java.lang.InstantiationException,
                     java.lang.IllegalAccessException,
                     java.lang.Throwable
Create a new domain and load a protocol from the local disk.
Parameters:
pp - The ProtocolPresentation to connect to the protocol in the new domain.
pf - The description of the flow.
initialCaps - The resource capabilities required to get the domain going.
ps - The resource limits for the new domain.
ct - The capabilities to pass to the new domain.

register

public DLProtocolPresentation register(DLProtocolPresentation retval,
                                       NeighborImpl ni,
                                       PairChain flowDesc,
                                       Capability[] initialCaps,
                                       PermissionSet transfer,
                                       CapabilityTree ct)
                                throws BDomainCreationException,
                                       java.lang.Throwable
Create a new domain and load the protocol from a neighbor.
Parameters:
retval - The DLProtocolPresentation to connect to the DLProtocol in the new domain or null if one should be created.
ni - The neighbor to download the flow from.
flowDesc - The flow tuple.
initialCaps - The resource capabilities required to get the domain going.
transfer - The resource limits for the new domain.
ct - The capabilities to pass to the new domain.
Returns:
A DLProtocolPresentation that can be used to control the download process.

register

public DLProtocolPresentation register(NeighborImpl ni,
                                       PairChain flowDesc,
                                       Capability[] initialCaps,
                                       PermissionSet transfer,
                                       CapabilityTree ct)
                                throws BDomainCreationException,
                                       java.lang.Throwable
Create a new domain and load the protocol from a neighbor.
Parameters:
ni - The neighbor to download the flow from.
flowDesc - The flow tuple.
initialCaps - The resource capabilities required to get the domain going.
transfer - The resource limits for the new domain.
ct - The capabilities to pass to the new domain.
Returns:
A DLProtocolPresentation that can be used to control the download process.

register

public void register(ProtocolPresentation pp,
                     CapabilityEnvelope ce,
                     TypeID sessionID)
              throws MissingCapabilityException,
                     java.lang.InstantiationException
Connect the given presentation to a protocol session in another domain.
Parameters:
pp - The ProtocolPresentation to connect.
ce - An envelope containing an EventChannel capability.
sessionID - The protocol session identifier to connect to in the domain.

threadStart

public void threadStart(java.lang.Runnable r,
                        java.lang.String threadName)
                 throws PermissionException
Create and start a new thread.
Parameters:
r - The Runnable to begin executing in a new thread.
threadName - The name of the newly created thread.
Throws:
PermissionException - If this node does not have the THREAD_START permission.

threadStart

public void threadStart(java.lang.Runnable r)
                 throws PermissionException
Create and start a new thread with a default name.
Parameters:
r - The Runnable to begin executing in a new thread.
Throws:
PermissionException - If this node does not have the THREAD_START permission.

setJSIHandler

public void setJSIHandler(java.lang.String name,
                          edu.utah.janosvm.kit.comm.jsi.JSIHandler jh)
                   throws PermissionException
Set the JSIHandler for a given subproperty.
Parameters:
name - The property name that should resolve to the given JSIHandler.
jh - The JSIHandler that implements a property.
Throws:
PermissionException - If this node does not have the JSI_REGISTER property.

shutdown

public void shutdown()
Shutdown the BDomain containing this node.

sleep

public void sleep(long millis)
           throws java.lang.InterruptedException
Put the current thread to sleep for the given number of milliseconds.
Parameters:
millis - The number of milliseconds to sleep.
Throws:
java.lang.InterruptedException - If another thread uses interrupt() on the current thread.

arraycopy

public void arraycopy(java.lang.Object src,
                      int src_position,
                      java.lang.Object dst,
                      int dst_position,
                      int length)
See Also:
java.lang.System#arraycopy(Object, int, Object, int, int)

isOnFire

public boolean isOnFire()
Returns:
True if the node is on fire.

resolveSpecifier

public edu.utah.janosvm.kit.comm.jsi.JSIHandler resolveSpecifier(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm,
                                                                 edu.utah.janosvm.kit.comm.jsi.JSIPair jp)
Specified by:
resolveSpecifier in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.resolveSpecifier(JSIMessage, JSIPair)

handleMessage

public void handleMessage(edu.utah.janosvm.kit.comm.jsi.JSIHandlerContext jhc,
                          edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
Specified by:
handleMessage in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.handleMessage(JSIHandlerContext, JSIMessage)

getSuites

public void getSuites(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
Specified by:
getSuites in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.getSuites(JSIMessage)

toShortString

public java.lang.String toShortString()
Returns:
An abbreviated description of this object.

toString

public java.lang.String toString()
Overrides:
toString in class NodeSpec
Following copied from class: bees.core.Capability
See Also:
Object.toString()

Bees v0.5.0 API

This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/