org.almendra.janet.cas.node
Class Node

java.lang.Object
  extended by org.almendra.janet.cas.node.Node
All Implemented Interfaces:
INamedObject, ISimpleActiveObject, IUniqueGlobalIdObject, ILoggable, IObjectSpaceProvider

public class Node
extends java.lang.Object
implements INamedObject, ISimpleActiveObject, ILoggable, IUniqueGlobalIdObject, IObjectSpaceProvider

Author:
Oliver

Field Summary
protected  AgentDispatcherRemote agentDispatcher
           
protected  ApplicationRegistry applicationRegistry
           
protected  java.util.Map clusterEventRegistriesByName
           
protected  java.util.Map clusterSpacesByName
           
static int DISCONNECT_TIMEOUT
           
protected  IEventRegistry eventRegistry
           
protected  UniqueId id
           
protected  AgentDispatcher localAgentDispatcher
           
protected  java.util.Map localClusterEventRegistriesByName
           
static java.lang.String LOG_EVENT_ABOUT_TO_DISCONNECT_FROM_ALL_NODES
           
static java.lang.String LOG_EVENT_DISCONNECTED_FROM_ALL_NODES
           
static java.lang.String LOG_EVENT_EXCEPTION_OCCURED_DISCONNECTING_FROM_ALL_NODES
           
static java.lang.String LOG_EVENT_NODE_NAME_CHANGED
           
static java.lang.String LOG_EVENT_NODE_STARTED
           
static java.lang.String LOG_EVENT_NODE_STARTING_UP
           
static java.lang.String LOG_EVENT_NODE_STOPPED
           
static java.lang.String LOG_EVENT_RECEIVED_PERMISSION_TO_SHUT_DOWN
           
static java.lang.String LOG_EVENT_REQUESTING_PERMISSION_TO_SHUT_DOWN
           
static java.lang.String LOG_EVENT_TIMEOUT_OCCURED_DISCONNECTING_FROM_ALL_NODES
           
protected  Logger logger
           
static java.lang.String LOGGER_OBJECT_NAME
           
protected  java.util.List monitorAgents
           
protected  java.lang.Object monitorAgentsLock
           
protected  java.lang.String name
          clusterwide unique node name
static java.lang.String NO_TITLE_PREFIX_FOUND
           
protected  IObjectSpace objectSpace
           
static java.lang.String RMI_LABEL_PREFIX
           
protected  SchedulerAnchor schedulerAnchor
           
static int SHUTDOWN_TIMEOUT
           
protected  ISimpleEventRegistry simpleEventRegistry
           
protected  SystemAgent systemAgent
           
protected  java.lang.String version
           
protected  IVetoableEventRegistry vetoableEventRegistry
           
 
Constructor Summary
protected Node()
           
  Node(NodeDescriptor nodeDescriptor)
           
 
Method Summary
 void addClusterEventRegistries(java.util.Map clusterEventRegistriesByName)
           
 void addClusterSpaces(java.util.Map clusterSpacesByName)
           
 void addMonitorAgent(IAgentProxy monitorAgent)
           
 void deregisterApplication(java.lang.String applicationName)
           
 void disconnectFromCentral()
           
 void disconnectFromNodesWithoutCentral()
           
 boolean disconnectRequest()
           
 NodeAccessor getAccessor()
           
 AgentDispatcherRemote getAgentDispatcher()
           
 IAgentDispatcher getAgentDispatcher(AgentPath path)
           
 AgentPath getAgentPath(java.lang.String applicationName, java.lang.String capabilityName, java.lang.String agentName)
           
 AbstractApplication getApplication(java.lang.String applicationName)
           
 ApplicationRegistry getApplicationRegistry()
           
 Arbitrator getArbitrator()
           
 BillboardPanelController getBillboard()
           
 java.util.Collection getClusterEventRegistries()
           
 ILocalClusterEventRegistry getClusterEventRegistry(java.lang.String name)
           
 AbstractClusterImage getClusterImage()
           
 ISerializableObjectSpace getClusterObjectSpace()
           
 ISerializableObjectSpace getClusterObjectSpace(java.lang.String name)
           
 TextAreaPanelController getFreeTextArea()
           
 UniqueId getGlobalId()
          Return the globally unique id
 AgentDispatcher getLocalAgentDispatcher()
           
protected  AbstractNodeImage getLocalNodeImage()
           
 LoggerAccessor getLogAccessor()
           
 Logger getLogger()
           
 java.util.List getMonitorAgents()
           
 IMonitorProducerAnchor getMonitorProducerAnchor()
           
 java.lang.String getName()
          All objects that have a user-defined name must implement this method.
 AbstractNodeAnchor getNodeAnchor()
           
 NodeDescriptor getNodeDescriptor()
           
 ILocalEventRegistry getNodeEventRegistry()
           
 java.lang.String getNodeLabel()
           
 NodeLocation getNodeLocation()
           
 IObjectSpace getNodeObjectSpace()
           
 IObjectSpace getObjectSpace()
           
 java.lang.String getRMIName()
           
 SchedulerAnchor getScheduler()
           
 ISimpleEventRegistry getSimpleEventRegistry()
           
 IAgent getSystemAgent()
           
 AgentPath getSystemAgentPath()
           
 IAgentProxy getSystemAgentProxy()
           
 AbstractNodeAnchor getSystemAnchor()
           
 SystemApplication getSystemApplication()
           
 Arbitrator getSystemArbitrator()
           
 CommandScheduler getSystemScheduler()
           
 java.lang.String getTemporaryNodeName(java.lang.String currentNodeNameOrNull)
          Answer a temporary node name if current node name is null.
 UniqueId getUniqueId()
           
 java.lang.String getVersion()
           
 IVetoableEventRegistry getVetoableEventRegistry()
           
 java.lang.String getViewTitle()
           
protected  void init(LocalLoggerDescriptor loggerDescriptor)
           
protected  void init(NodeDescriptor nodeDescriptor)
           
protected  void init(SystemApplication sysApp, LocalLoggerDescriptor loggerDescriptor)
           
protected  void initAgentDispatcher()
           
 boolean isActive()
          Answer whether the thread that runs the active object is running or not.
 boolean isForeignApplicationRegistered(java.lang.String applicationName, java.lang.String nodeName)
           
 boolean isForeignCapabilityRegistered(CapabilityPath path)
           
 boolean isIdle()
           
 boolean isLastNodeOnWorkstation()
           
 boolean isLocalPath(AgentPath path)
           
protected  void logDisconnect(java.lang.Exception ex)
           
protected  ISerializableObjectSpace lookupClusterSpace(java.lang.String name)
           
protected  void propagateDeregisteredApplication(java.lang.String applicationName, java.util.List nodeNames)
           
protected  Application propagateRegisteredApplication(Application app, java.util.List nodeNames)
           
 Application registerApplication(Application app, java.util.List nodeNames)
          Register the application in the node's application registry, create all agents, and start their schedulers.
 java.util.List registeredLogEvents()
          Return list of events that may occur for an object.
protected  void registerEvents()
           
 void registerSystemCapabilities()
           
 boolean removeMonitorAgents(IAgentProxy monitorAgent)
           
 void sendToMonitorAgents(ICommand cmd)
           
 void setName(java.lang.String newName)
          Set the node name.
 void setVersion(java.lang.String version)
           
 boolean shutdown()
           
protected  void signalShutdown()
           
 void start()
          Start the thread that runs the active object.
 void stop()
          Stop the thread that runs the active object.
protected  void storeApplications(NodeDescriptor nodeDescriptor, SystemApplication sysApp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_EVENT_NODE_STARTING_UP

public static final java.lang.String LOG_EVENT_NODE_STARTING_UP
See Also:
Constant Field Values

LOG_EVENT_NODE_STARTED

public static final java.lang.String LOG_EVENT_NODE_STARTED
See Also:
Constant Field Values

LOG_EVENT_NODE_STOPPED

public static final java.lang.String LOG_EVENT_NODE_STOPPED
See Also:
Constant Field Values

LOG_EVENT_NODE_NAME_CHANGED

public static final java.lang.String LOG_EVENT_NODE_NAME_CHANGED
See Also:
Constant Field Values

LOG_EVENT_ABOUT_TO_DISCONNECT_FROM_ALL_NODES

public static final java.lang.String LOG_EVENT_ABOUT_TO_DISCONNECT_FROM_ALL_NODES
See Also:
Constant Field Values

LOG_EVENT_DISCONNECTED_FROM_ALL_NODES

public static final java.lang.String LOG_EVENT_DISCONNECTED_FROM_ALL_NODES
See Also:
Constant Field Values

LOG_EVENT_TIMEOUT_OCCURED_DISCONNECTING_FROM_ALL_NODES

public static final java.lang.String LOG_EVENT_TIMEOUT_OCCURED_DISCONNECTING_FROM_ALL_NODES
See Also:
Constant Field Values

LOG_EVENT_EXCEPTION_OCCURED_DISCONNECTING_FROM_ALL_NODES

public static final java.lang.String LOG_EVENT_EXCEPTION_OCCURED_DISCONNECTING_FROM_ALL_NODES
See Also:
Constant Field Values

LOG_EVENT_REQUESTING_PERMISSION_TO_SHUT_DOWN

public static final java.lang.String LOG_EVENT_REQUESTING_PERMISSION_TO_SHUT_DOWN
See Also:
Constant Field Values

LOG_EVENT_RECEIVED_PERMISSION_TO_SHUT_DOWN

public static final java.lang.String LOG_EVENT_RECEIVED_PERMISSION_TO_SHUT_DOWN
See Also:
Constant Field Values

LOGGER_OBJECT_NAME

public static final java.lang.String LOGGER_OBJECT_NAME
See Also:
Constant Field Values

RMI_LABEL_PREFIX

public static final java.lang.String RMI_LABEL_PREFIX
See Also:
Constant Field Values

NO_TITLE_PREFIX_FOUND

public static final java.lang.String NO_TITLE_PREFIX_FOUND
See Also:
Constant Field Values

SHUTDOWN_TIMEOUT

public static final int SHUTDOWN_TIMEOUT
See Also:
Constant Field Values

DISCONNECT_TIMEOUT

public static final int DISCONNECT_TIMEOUT
See Also:
Constant Field Values

name

protected java.lang.String name
clusterwide unique node name


id

protected UniqueId id

logger

protected Logger logger

systemAgent

protected SystemAgent systemAgent

schedulerAnchor

protected SchedulerAnchor schedulerAnchor

applicationRegistry

protected ApplicationRegistry applicationRegistry

localAgentDispatcher

protected AgentDispatcher localAgentDispatcher

agentDispatcher

protected AgentDispatcherRemote agentDispatcher

eventRegistry

protected IEventRegistry eventRegistry

simpleEventRegistry

protected ISimpleEventRegistry simpleEventRegistry

objectSpace

protected IObjectSpace objectSpace

version

protected java.lang.String version

clusterSpacesByName

protected java.util.Map clusterSpacesByName

clusterEventRegistriesByName

protected java.util.Map clusterEventRegistriesByName

localClusterEventRegistriesByName

protected java.util.Map localClusterEventRegistriesByName

monitorAgentsLock

protected java.lang.Object monitorAgentsLock

monitorAgents

protected java.util.List monitorAgents

vetoableEventRegistry

protected IVetoableEventRegistry vetoableEventRegistry
Constructor Detail

Node

protected Node()

Node

public Node(NodeDescriptor nodeDescriptor)
     throws DescriptorParseException,
            NodeStartupException
Throws:
DescriptorParseException
NodeStartupException
Method Detail

getLogger

public Logger getLogger()
Returns:
Returns the logger.

init

protected void init(NodeDescriptor nodeDescriptor)
             throws DescriptorParseException,
                    NodeStartupException
Parameters:
nodeDescriptor -
Throws:
DescriptorParseException
NodeStartupException

storeApplications

protected void storeApplications(NodeDescriptor nodeDescriptor,
                                 SystemApplication sysApp)
                          throws DescriptorParseException
Throws:
DescriptorParseException

getName

public java.lang.String getName()
Description copied from interface: INamedObject
All objects that have a user-defined name must implement this method.

Specified by:
getName in interface INamedObject
Returns:

setName

public void setName(java.lang.String newName)
Set the node name. Tell all dependent objects that need to know the node name about the it.

Parameters:
newName - the new node name

init

protected void init(SystemApplication sysApp,
                    LocalLoggerDescriptor loggerDescriptor)
             throws NodeStartupException
Throws:
NodeStartupException

getTemporaryNodeName

public java.lang.String getTemporaryNodeName(java.lang.String currentNodeNameOrNull)
Answer a temporary node name if current node name is null. A node does node know it's final name before it has finished the startup process. Return a network-wide unique temporary node name.

Parameters:
currentNodeNameOrNull -
Returns:
the temporary node name

init

protected void init(LocalLoggerDescriptor loggerDescriptor)

initAgentDispatcher

protected void initAgentDispatcher()
                            throws NodeStartupException
Throws:
NodeStartupException

registerEvents

protected void registerEvents()

start

public void start()
Description copied from interface: ISimpleActiveObject
Start the thread that runs the active object.

Specified by:
start in interface ISimpleActiveObject

stop

public void stop()
Description copied from interface: ISimpleActiveObject
Stop the thread that runs the active object.

Specified by:
stop in interface ISimpleActiveObject

signalShutdown

protected void signalShutdown()

getSystemScheduler

public CommandScheduler getSystemScheduler()
Returns:

getSystemAgent

public IAgent getSystemAgent()
Returns:

getSystemAgentPath

public AgentPath getSystemAgentPath()
Returns:

getSystemAgentProxy

public IAgentProxy getSystemAgentProxy()

getScheduler

public SchedulerAnchor getScheduler()
Returns:

getApplicationRegistry

public ApplicationRegistry getApplicationRegistry()
Returns:

isIdle

public boolean isIdle()

registeredLogEvents

public java.util.List registeredLogEvents()
Description copied from interface: ILoggable
Return list of events that may occur for an object.

Specified by:
registeredLogEvents in interface ILoggable
Returns:

getLogAccessor

public LoggerAccessor getLogAccessor()

getAccessor

public NodeAccessor getAccessor()

getGlobalId

public UniqueId getGlobalId()
Description copied from interface: IUniqueGlobalIdObject
Return the globally unique id

Specified by:
getGlobalId in interface IUniqueGlobalIdObject
Returns:

getArbitrator

public Arbitrator getArbitrator()

getSystemArbitrator

public Arbitrator getSystemArbitrator()

isActive

public boolean isActive()
Description copied from interface: ISimpleActiveObject
Answer whether the thread that runs the active object is running or not.

Specified by:
isActive in interface ISimpleActiveObject
Returns:

getAgentDispatcher

public AgentDispatcherRemote getAgentDispatcher()
Returns:
Returns the local agentDispatcher.

getApplication

public AbstractApplication getApplication(java.lang.String applicationName)

getSystemApplication

public SystemApplication getSystemApplication()

getViewTitle

public java.lang.String getViewTitle()
Returns:

getSystemAnchor

public AbstractNodeAnchor getSystemAnchor()
Returns:

getAgentDispatcher

public IAgentDispatcher getAgentDispatcher(AgentPath path)
                                    throws NoSuchAgentException
Parameters:
path -
Returns:
Throws:
NoSuchAgentException

isLocalPath

public boolean isLocalPath(AgentPath path)
Parameters:
path -
Returns:

getUniqueId

public UniqueId getUniqueId()

getLocalAgentDispatcher

public AgentDispatcher getLocalAgentDispatcher()
Returns:
Returns the localAgentDispatcher.

getRMIName

public java.lang.String getRMIName()
Returns:

disconnectRequest

public boolean disconnectRequest()

getAgentPath

public AgentPath getAgentPath(java.lang.String applicationName,
                              java.lang.String capabilityName,
                              java.lang.String agentName)

disconnectFromCentral

public void disconnectFromCentral()

disconnectFromNodesWithoutCentral

public void disconnectFromNodesWithoutCentral()

logDisconnect

protected void logDisconnect(java.lang.Exception ex)
Parameters:
exception -

shutdown

public boolean shutdown()

registerApplication

public Application registerApplication(Application app,
                                       java.util.List nodeNames)
                                throws AlreadyRegisteredException,
                                       java.lang.IllegalArgumentException,
                                       java.rmi.RemoteException
Register the application in the node's application registry, create all agents, and start their schedulers. Send a notifications to all nodes in the cluster that a new application has been registered at this node.

Parameters:
app -
nodeNames - names of all nodes where to register, all foreign nodes if null.
Returns:
@throws AlreadyRegisteredException
Throws:
java.lang.IllegalArgumentException
AlreadyRegisteredException
java.rmi.RemoteException

getLocalNodeImage

protected AbstractNodeImage getLocalNodeImage()
Returns:

propagateRegisteredApplication

protected Application propagateRegisteredApplication(Application app,
                                                     java.util.List nodeNames)
                                              throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

getNodeLocation

public NodeLocation getNodeLocation()
Returns:

propagateDeregisteredApplication

protected void propagateDeregisteredApplication(java.lang.String applicationName,
                                                java.util.List nodeNames)

getVersion

public java.lang.String getVersion()
Returns:
Returns the version.

setVersion

public void setVersion(java.lang.String version)
Parameters:
version - The version to set.

getNodeEventRegistry

public ILocalEventRegistry getNodeEventRegistry()
Returns:
Returns the eventRegistry.

deregisterApplication

public void deregisterApplication(java.lang.String applicationName)
Parameters:
name2 -

isForeignApplicationRegistered

public boolean isForeignApplicationRegistered(java.lang.String applicationName,
                                              java.lang.String nodeName)
Parameters:
applicationName -
Returns:

getNodeAnchor

public AbstractNodeAnchor getNodeAnchor()

isForeignCapabilityRegistered

public boolean isForeignCapabilityRegistered(CapabilityPath path)
Parameters:
capabilityName -
applicationName -
nodeName -
Returns:

getNodeObjectSpace

public IObjectSpace getNodeObjectSpace()
Returns:
Returns the objectSpace.

getClusterObjectSpace

public ISerializableObjectSpace getClusterObjectSpace(java.lang.String name)
                                               throws java.util.NoSuchElementException
Parameters:
clusterSpacesByName -
Throws:
java.util.NoSuchElementException

getClusterEventRegistries

public java.util.Collection getClusterEventRegistries()

getClusterEventRegistry

public ILocalClusterEventRegistry getClusterEventRegistry(java.lang.String name)
                                                   throws java.util.NoSuchElementException,
                                                          java.rmi.RemoteException
Parameters:
clusterSpacesByName -
Throws:
java.util.NoSuchElementException
java.rmi.RemoteException

lookupClusterSpace

protected ISerializableObjectSpace lookupClusterSpace(java.lang.String name)
Parameters:
name -
Returns:

getClusterObjectSpace

public ISerializableObjectSpace getClusterObjectSpace()
                                               throws java.util.NoSuchElementException
Parameters:
clusterSpacesByName -
Throws:
java.util.NoSuchElementException

addClusterSpaces

public void addClusterSpaces(java.util.Map clusterSpacesByName)
Parameters:
clusterSpacesByName -

addClusterEventRegistries

public void addClusterEventRegistries(java.util.Map clusterEventRegistriesByName)

getObjectSpace

public IObjectSpace getObjectSpace()
Specified by:
getObjectSpace in interface IObjectSpaceProvider

isLastNodeOnWorkstation

public boolean isLastNodeOnWorkstation()
                                throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

getNodeDescriptor

public NodeDescriptor getNodeDescriptor()

getClusterImage

public AbstractClusterImage getClusterImage()

registerSystemCapabilities

public void registerSystemCapabilities()
                                throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

getMonitorAgents

public java.util.List getMonitorAgents()
Returns:

addMonitorAgent

public void addMonitorAgent(IAgentProxy monitorAgent)

removeMonitorAgents

public boolean removeMonitorAgents(IAgentProxy monitorAgent)

getMonitorProducerAnchor

public IMonitorProducerAnchor getMonitorProducerAnchor()
Returns:

sendToMonitorAgents

public void sendToMonitorAgents(ICommand cmd)
Parameters:
cmd -

getSimpleEventRegistry

public ISimpleEventRegistry getSimpleEventRegistry()
Returns:
Returns the simpleEventRegistry.

getNodeLabel

public java.lang.String getNodeLabel()
Returns:

getBillboard

public BillboardPanelController getBillboard()

getFreeTextArea

public TextAreaPanelController getFreeTextArea()

getVetoableEventRegistry

public IVetoableEventRegistry getVetoableEventRegistry()
Returns:
Returns the vetoableEventRegistry.