ANTS v2.0 API

ants.core
Class Node

java.lang.Object
  |
  +--ants.core.Node

public class Node
extends java.lang.Object

The per-flow Node interface.

An instance of Node is created in the context of each Application and protocol.

Author:
Utah Janos Team
See Also:
PrimordialNode, AppBooster, ProtocolBooster

Method Summary
 void arraycopy(java.lang.Object src, int src_position, java.lang.Object dst, int dst_position, int length)
           
static Node currentNode()
          Return the Node interface associated with the current flow.
static Principal currentPrincipal()
           
 boolean deliverToApp(Capsule cap, int port)
          Deliver the given capsule to the Application on the given port number.
 int getAddress()
          Return the logical 32-bit IP-like "active" address for this Node.
 NodeCache getCache()
           
 NeighborTable getNeighborTable()
           
 Principal getPrincipal()
          Return the security principal associated with this node
 RouteTable getRouteTable()
           
 double getStat(int index)
           
 java.lang.String getVisibleAddressSpec()
          Get the address spec that remote nodes can use to communicate with this node.
 java.lang.String getVisibleProtocolSpec()
          Get the protocol spec that remote nodes can use to communicate with this node.
 java.lang.String hostname()
          Return the string name of the host machine.
 void log(int level, java.lang.String msg)
          Log a message to this Node's "console".
 void log(int level, java.lang.Throwable exception)
          Log an exception.
 void logStackTrace(int level, java.lang.Throwable exception)
          Log an exception.
 void register(Protocol p)
          Just calls register(Protocol,Principal) with a default Principal (SecuirtyDefaults.REMOTE_USERS).
 void register(Protocol protocol, Principal principal)
          Called by applications that want to instantiate a locally originiating protocol.
 boolean routeForNode(Capsule cap, int destination)
          Route a capsule for a particular destination.
 boolean send(Capsule cap)
          Inject a given capsule into the network via the local node.
 boolean sendToNeighbor(Capsule cap, int neighbor)
          Send a capsule to an adjacent node.
 void setAddress(int a)
          Set the logical 32-bit address for this (and every) node This method assumes synchronization is provided elsewhere if this is necessary.
 void shutdown()
          Shutdown this Node.
 void sleep(long millis)
          Have the calling thread sleep for at least the given number of milliseconds.
 void threadStart(java.lang.Runnable r)
           
 void threadStart(java.lang.Runnable r, java.lang.String threadName)
          Start a new thread executing the given Runnable.
 long time()
          Return the current time in milliseconds.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getPrincipal

public Principal getPrincipal()
Return the security principal associated with this node
See Also:
Principal

getAddress

public int getAddress()
Return the logical 32-bit IP-like "active" address for this Node. May return 0, which means the address for the node has not yet been assigned. That happens with DANTE or other dynamic address specification protocols.
Returns:
the 32-bit IP-like "active" address of this Node

setAddress

public void setAddress(int a)
Set the logical 32-bit address for this (and every) node This method assumes synchronization is provided elsewhere if this is necessary.

getVisibleProtocolSpec

public java.lang.String getVisibleProtocolSpec()
Get the protocol spec that remote nodes can use to communicate with this node. This protocol spec will be the spec for the proxy, if this node is being proxied.
See Also:
PrimordialNode#getVisibleProtocolSpec()

getVisibleAddressSpec

public java.lang.String getVisibleAddressSpec()
Get the address spec that remote nodes can use to communicate with this node. This address spec will be the spec for the proxy, if this node is being proxied.
See Also:
PrimordialNode#getVisibleProtocolSpec()

currentNode

public static Node currentNode()
Return the Node interface associated with the current flow.

XXX This method is a hack and would go away if one were to re-write the basic ANTS interfaces. The "current node" should be an explicit paramter to those functions that need it.


currentPrincipal

public static final Principal currentPrincipal()

register

public void register(Protocol p)
Just calls register(Protocol,Principal) with a default Principal (SecuirtyDefaults.REMOTE_USERS).
See Also:
SecuirtyDefaults.REMOTE_USERS, register(Protocol,Principal)

register

public void register(Protocol protocol,
                     Principal principal)
Called by applications that want to instantiate a locally originiating protocol. No security check here because we assume that dynamically loaded protocol code does not have access to the Protocol class.

deliverToApp

public boolean deliverToApp(Capsule cap,
                            int port)
Deliver the given capsule to the Application on the given port number.

Throws:
NoSuchApplicationError - if the port doesn't have an app listening on it.

send

public boolean send(Capsule cap)
Inject a given capsule into the network via the local node. This method is only called by Application#send(). Note that the capsule's evaluate() is responsible for routing...

threadStart

public void threadStart(java.lang.Runnable r)
See Also:
threadStart(java.lang.Runnable,String)

threadStart

public void threadStart(java.lang.Runnable r,
                        java.lang.String threadName)
Start a new thread executing the given Runnable. The caller must have the START_THREAD permission.

routeForNode

public boolean routeForNode(Capsule cap,
                            int destination)
Route a capsule for a particular destination. Note that there is no next hop to the current node, and it is therefore impossible to route to ourself. Since capsules are evaluated at the local node before being sent, it seems like a bad idea to allow them to route to the same node -- this would likely produce an infinite loop.

sendToNeighbor

public boolean sendToNeighbor(Capsule cap,
                              int neighbor)
Send a capsule to an adjacent node. This method does not rely on the routing protocol, thus its quite useful for BOOTP-like protocols that need to send a packet to discover the Node's address.

Note that an association between the neighbor's logical address and a physical address must have been established and installed in the PrimoridalNode's neighborTable.

Note that because the capsules sent this way are used for bootstrapping, they have no source address. This routine inserts "255.255.255.255" as the source addr, and fixes the TTL at 3. Because of this, this routine should only be used by privilged bootstrap protocols.

Parameters:
cap - the capsule to send. Will be encoded and launched just like any other capsule.
neighbor - the logical address of the neighbor node.
See Also:
PrimordialNode#neighborTable, PrimordialNode#loadRouteTableImpl(int,boolean,String)

getCache

public NodeCache getCache()

sleep

public void sleep(long millis)
           throws java.lang.InterruptedException
Have the calling thread sleep for at least the given number of milliseconds.
Parameters:
millis - how long to sleep for, in milliseconds.

shutdown

public void shutdown()
Shutdown this Node. Just kills the flow, and not the entire virtual machine. Shuts down the cache, and de-register's this flow's application if it has one. To shutdown the entire VM, use the non-public PrimordialNode.shutdown().

Interface for shutting down the entire node isn't (yet) visible.

See Also:
PrimordialNode#shutdown()

hostname

public java.lang.String hostname()
Return the string name of the host machine.

time

public long time()
Return the current time in milliseconds.

log

public void log(int level,
                java.lang.String msg)
Log a message to this Node's "console". The messages are sent to the logger installed on this node. The level parameter indicates the serverity of the condition the message relays. Use constants from the edu.utah.janos.io.Log class for this parameter
Parameters:
level - the severity/priority of the log message
msg - the string message
See Also:
#logger, Log

log

public void log(int level,
                java.lang.Throwable exception)
Log an exception. Level parameter is same as for logging a string, see log(int, String)

XXX redundant with logStackTrace(int,Throwable)

See Also:
log(int,String)

logStackTrace

public void logStackTrace(int level,
                          java.lang.Throwable exception)
Log an exception. Same as log(int, Throwable)

XXX redundant with log(int,Throwable)

See Also:
log(int,Throwable)

getRouteTable

public RouteTable getRouteTable()

getNeighborTable

public NeighborTable getNeighborTable()

getStat

public double getStat(int index)
Parameters:
index - The statistic to retrieve, the value should be one of the NodeStat constants.
Returns:
The value of the statistic.

arraycopy

public void arraycopy(java.lang.Object src,
                      int src_position,
                      java.lang.Object dst,
                      int dst_position,
                      int length)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

ANTS v2.0 API

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