org.jppf.node
Class AbstractMonitoredNode

java.lang.Object
  extended by org.jppf.utils.ThreadSynchronization
      extended by org.jppf.node.AbstractMonitoredNode
All Implemented Interfaces:
Runnable, MonitoredNode
Direct Known Subclasses:
JPPFNode

public abstract class AbstractMonitoredNode
extends ThreadSynchronization
implements MonitoredNode, Runnable

Abstract implementation of the MonitoredNode interface.

Author:
Laurent Cohen

Field Summary
protected  AtomicInteger executingCount
          Holds the count of currently executing tasks.
protected  SerializationHelper helper
          Utility for deserialization and serialization.
protected  List<NodeListener> listeners
          The list of listeners that receive notifications from this node.
protected  boolean notifying
          This flag is true if there is at least one listener, and false otherwise.
protected  ObjectSerializer serializer
          Utility for deserialization and serialization.
protected  SocketWrapper socketClient
          Wrapper around the underlying server connection.
protected  SocketInitializer socketInitializer
          Used to synchronize access to the underlying socket from multiple threads.
protected  String uuid
          This node's universal identifier.
 
Fields inherited from class org.jppf.utils.ThreadSynchronization
stopped
 
Constructor Summary
AbstractMonitoredNode()
           
 
Method Summary
 void addNodeListener(NodeListener listener)
          Add a listener to the list of listener for this node.
 void decrementExecutingCount()
          Decrement the count of currently executing tasks and determine whether an idle notification should be sent.
 void fireNodeEvent(int nbTasks)
          Create an event for the execution of a specified number of tasks.
 void fireNodeEvent(NodeEventType eventType)
          Notify all listeners that an event has occurred.
 SerializationHelper getHelper()
          Get the utility for deserialization and serialization.
 SocketWrapper getSocketWrapper()
          Get the underlying socket wrapper used by this node.
 int getTaskCount()
          Get the total number of tasks executed.
 void incrementExecutingCount()
          Increment the count of currently executing tasks and determine whether a busy notification should be sent.
 boolean isNotifying()
          Determine whether this node has at least one listener to notify of internal events.
 void removeNodeListener(NodeListener listener)
          Remove a listener from the list of listener for this node.
 void setSocketWrapper(SocketWrapper wrapper)
          Get the underlying socket wrapper used by this node.
 void setTaskCount(int taskCount)
          Set the total number of tasks executed.
abstract  void stopNode(boolean closeSocket)
          Stop this node and release the resources it is using.
 
Methods inherited from class org.jppf.utils.ThreadSynchronization
goToSleep, goToSleep, goToSleep, isStopped, setStopped, wakeUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

helper

protected SerializationHelper helper
Utility for deserialization and serialization.


serializer

protected ObjectSerializer serializer
Utility for deserialization and serialization.


socketClient

protected SocketWrapper socketClient
Wrapper around the underlying server connection.


socketInitializer

protected SocketInitializer socketInitializer
Used to synchronize access to the underlying socket from multiple threads.


listeners

protected List<NodeListener> listeners
The list of listeners that receive notifications from this node.


notifying

protected boolean notifying
This flag is true if there is at least one listener, and false otherwise.


uuid

protected String uuid
This node's universal identifier.


executingCount

protected AtomicInteger executingCount
Holds the count of currently executing tasks. Used to determine when this node is busy or idle.

Constructor Detail

AbstractMonitoredNode

public AbstractMonitoredNode()
Method Detail

addNodeListener

public void addNodeListener(NodeListener listener)
Add a listener to the list of listener for this node.

Specified by:
addNodeListener in interface MonitoredNode
Parameters:
listener - the listener to add.
See Also:
MonitoredNode.addNodeListener(org.jppf.node.event.NodeListener)

removeNodeListener

public void removeNodeListener(NodeListener listener)
Remove a listener from the list of listener for this node.

Specified by:
removeNodeListener in interface MonitoredNode
Parameters:
listener - the listener to remove.
See Also:
MonitoredNode.removeNodeListener(org.jppf.node.event.NodeListener)

fireNodeEvent

public void fireNodeEvent(NodeEventType eventType)
Notify all listeners that an event has occurred.

Specified by:
fireNodeEvent in interface MonitoredNode
Parameters:
eventType - the type of the event as an enumerated value.
See Also:
MonitoredNode.fireNodeEvent(org.jppf.node.event.NodeEventType)

fireNodeEvent

public void fireNodeEvent(int nbTasks)
Create an event for the execution of a specified number of tasks.

Specified by:
fireNodeEvent in interface MonitoredNode
Parameters:
nbTasks - the number of tasks as an int.
See Also:
MonitoredNode.fireNodeEvent(int)

getSocketWrapper

public SocketWrapper getSocketWrapper()
Get the underlying socket wrapper used by this node.

Specified by:
getSocketWrapper in interface MonitoredNode
Returns:
a SocketWrapper instance.

setSocketWrapper

public void setSocketWrapper(SocketWrapper wrapper)
Get the underlying socket wrapper used by this node.

Specified by:
setSocketWrapper in interface MonitoredNode
Parameters:
wrapper - a SocketWrapper instance.

isNotifying

public boolean isNotifying()
Determine whether this node has at least one listener to notify of internal events.

Returns:
true if there is at least one listener, and false otherwise.

stopNode

public abstract void stopNode(boolean closeSocket)
Stop this node and release the resources it is using.

Specified by:
stopNode in interface MonitoredNode
Parameters:
closeSocket - determines whether the underlying socket should be closed.
See Also:
MonitoredNode.stopNode(boolean)

getTaskCount

public int getTaskCount()
Get the total number of tasks executed.

Returns:
the number of tasks as an int.

setTaskCount

public void setTaskCount(int taskCount)
Set the total number of tasks executed.

Parameters:
taskCount - the number of tasks as an int.

getHelper

public SerializationHelper getHelper()
Get the utility for deserialization and serialization.

Returns:
a SerializationHelper instance.

decrementExecutingCount

public void decrementExecutingCount()
Decrement the count of currently executing tasks and determine whether an idle notification should be sent.


incrementExecutingCount

public void incrementExecutingCount()
Increment the count of currently executing tasks and determine whether a busy notification should be sent.



Copyright © 2005-2010 JPPF Team.