net.eduvax.grant.core
Class LocalNode

java.lang.Object
  extended by net.eduvax.grant.core.Node
      extended by net.eduvax.grant.core.LocalNode
Direct Known Subclasses:
TestNode

public class LocalNode
extends Node

Local node core. Local work impolémentation : routing or launching tasklet when routed to itself.


Nested Class Summary
private  class LocalNode.DelayedSubmition
           
 
Field Summary
private  java.util.Hashtable activeNodes
          Active nodes set.
private static java.io.File activeNodesFile
          active nodes rc file handler
static int ANT_DEF_DELAY
          default delay for ant engine.
private  AntEngine antEngine
          ant engine manages only local environment. i.e. links to known nodes from this node.
protected  java.util.Vector candidate
          candidate node desciptor list.
private static TaskletEventDispatcher eventDispatcher
          tasklet event dispatcher.
private static java.util.Hashtable knownNodes
          Known nodes.
private static java.io.File knownNodesFile
          known nodes rc file handler
private static SLogger logger
          logger
private  int maxLoad
          max load for node.
private  int minDelay
          minimum delay between two submition attempt.
private static java.util.Random random
          random number generator
private  int routedTasks
          tasks routed by this node.
private  int runnedTasks
          tasks completed by this node.
private  Selector selector
          node selector.
private  int state
          internal state
static int STATE_FULL
           
static int STATE_HALTED
           
static int STATE_RUNNING
           
static int STATE_SHUTDOWN
           
static int STATE_STARTING
           
static java.lang.String[] STATES_NAME
           
private  TaskletManager taskletManager
          tasklet manager
private  int waitingTasks
          tasks wainting to be runned by this node.
 
Constructor Summary
LocalNode(java.lang.String n)
          Create new local node
 
Method Summary
 Node addNode(java.lang.String nName)
          add a node.
protected  boolean checkLoad()
          check for overload.
 void dissipate(java.lang.Object o)
           
 int execReport(ExecReport er)
          manage end of execution notification.
 int execReportToClient(ExecReport er)
           
 void feedback(java.lang.Object o, float feedback)
           
 double fitness(java.lang.Object o)
           
protected  float getFeedback(ExecReport er)
          compute feedback to local ant colony after task execution.
protected  float getFeedback(ExecRequest er)
          compute feedback to local ant colony after task schedule.
 java.lang.String[] getKnownNodes()
          request for known nodes name list.
private  Node getNode(java.lang.String nName)
          Get node if already known, create node handler when not known.
protected  int getTaskCount()
          gets current task count on this node.
 void handleEvent(int eventType, TaskletEvent event)
          dispatch events to registered listeners.
 float load()
          Estimate instant available host power.
protected  void loadNodes(java.util.Hashtable nodeSet, java.io.File nodesFile)
          Reload known nodes from rc file.
 void removeNode(java.lang.String nName)
          remove a node.
private  void saveNodes(java.util.Hashtable nodeSet, java.io.File nodesFile)
          Saves nodes set from rc file.
 void sendEvent(int eventType, TaskletEvent event)
          send envent to root node.
 void setMaxLoad(int max)
          change max load.
protected  void setSelector(Selector s)
          defines selector.
private  int setState(int newState)
          internal state change request.
 void shutdown()
          shutdown node
 java.lang.String status()
          status information.
private  int submitDelayedRequest(ExecRequest er)
           
 ExecRequest submitRequest(ExecRequest er)
          Handle exec request.
 
Methods inherited from class net.eduvax.grant.core.Node
createNode, getFitness, getName, getRCDir, registerNodeFactory, setFitness
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANT_DEF_DELAY

public static final int ANT_DEF_DELAY
default delay for ant engine.

See Also:
Constant Field Values

selector

private Selector selector
node selector.


knownNodes

private static java.util.Hashtable knownNodes
Known nodes.


activeNodes

private java.util.Hashtable activeNodes
Active nodes set. Should contain only nodes from knownNodes.


antEngine

private AntEngine antEngine
ant engine manages only local environment. i.e. links to known nodes from this node. Ant engines uses selector to choose a node each time requested.


candidate

protected java.util.Vector candidate
candidate node desciptor list. Should contain only nodes from activeNodes.


runnedTasks

private int runnedTasks
tasks completed by this node.


routedTasks

private int routedTasks
tasks routed by this node.


state

private int state
internal state


waitingTasks

private int waitingTasks
tasks wainting to be runned by this node.


maxLoad

private int maxLoad
max load for node.


taskletManager

private TaskletManager taskletManager
tasklet manager


minDelay

private int minDelay
minimum delay between two submition attempt. Autoadjusted.


knownNodesFile

private static java.io.File knownNodesFile
known nodes rc file handler


activeNodesFile

private static java.io.File activeNodesFile
active nodes rc file handler


logger

private static SLogger logger
logger


random

private static java.util.Random random
random number generator


eventDispatcher

private static TaskletEventDispatcher eventDispatcher
tasklet event dispatcher.


STATE_STARTING

public static final int STATE_STARTING
See Also:
Constant Field Values

STATE_RUNNING

public static final int STATE_RUNNING
See Also:
Constant Field Values

STATE_FULL

public static final int STATE_FULL
See Also:
Constant Field Values

STATE_SHUTDOWN

public static final int STATE_SHUTDOWN
See Also:
Constant Field Values

STATE_HALTED

public static final int STATE_HALTED
See Also:
Constant Field Values

STATES_NAME

public static final java.lang.String[] STATES_NAME
Constructor Detail

LocalNode

public LocalNode(java.lang.String n)
Create new local node

Parameters:
n - node's name
Method Detail

submitRequest

public ExecRequest submitRequest(ExecRequest er)
Handle exec request. Handling can be :

Specified by:
submitRequest in class Node
Parameters:
er - execute request.
Returns:
modified execute request : local node is added to the routing path.

checkLoad

protected boolean checkLoad()
check for overload. also adjust minimum delay before new submition attempt.


submitDelayedRequest

private int submitDelayedRequest(ExecRequest er)
Returns:
delay before new submition.

execReport

public int execReport(ExecReport er)
manage end of execution notification. Updates known nodes description according to excution report

Specified by:
execReport in class Node
Parameters:
er - tasklet execution report.
len - position in routing stack. (<=0 means last)
Returns:
completion code, 0 is OK.

execReportToClient

public int execReportToClient(ExecReport er)

addNode

public Node addNode(java.lang.String nName)
add a node.

Specified by:
addNode in class Node
Parameters:
nName - node's name (xmlrpc server url)
Returns:
the new node handler.

getNode

private Node getNode(java.lang.String nName)
Get node if already known, create node handler when not known.

Parameters:
nName - node name.
Returns:
node.

saveNodes

private void saveNodes(java.util.Hashtable nodeSet,
                       java.io.File nodesFile)
Saves nodes set from rc file.

Parameters:
nodeSet - node set.
nodeFile - node file.

loadNodes

protected void loadNodes(java.util.Hashtable nodeSet,
                         java.io.File nodesFile)
Reload known nodes from rc file.

Parameters:
nodeSet - node set.
nodeFile - node file.

load

public float load()
Estimate instant available host power. higher value means less charge. Should be meaningfull regarding host type/cpu freq, all over the node network. Should be specialized according each runing host since java does not have any host cpu spec getter, native code may be needed. Default is running tasks count.

Specified by:
load in class Node
Returns:
load indicator

setState

private int setState(int newState)
internal state change request.

Parameters:
newState - next state.
Returns:
current state after request completion. Since requested change may not be allowed, returned state may be different from newState.

sendEvent

public void sendEvent(int eventType,
                      TaskletEvent event)
send envent to root node.

Parameters:
eventType - event type (see TaskletEvent constants)
event - event to send

handleEvent

public void handleEvent(int eventType,
                        TaskletEvent event)
dispatch events to registered listeners.

Specified by:
handleEvent in class Node
Parameters:
eventType - event type (see TaskletEvent constants)
event - event to send

shutdown

public void shutdown()
shutdown node

Specified by:
shutdown in class Node

setMaxLoad

public void setMaxLoad(int max)
change max load.

Parameters:
max - new maximum load to set.

getKnownNodes

public java.lang.String[] getKnownNodes()
Description copied from class: Node
request for known nodes name list.

Specified by:
getKnownNodes in class Node
Returns:
nodes known from this node.

status

public java.lang.String status()
Description copied from class: Node
status information.

Specified by:
status in class Node
Returns:
xml status information.

removeNode

public void removeNode(java.lang.String nName)
Description copied from class: Node
remove a node.

Specified by:
removeNode in class Node
Parameters:
nName - node's name (xmlrpc server url)

fitness

public double fitness(java.lang.Object o)

dissipate

public void dissipate(java.lang.Object o)

feedback

public void feedback(java.lang.Object o,
                     float feedback)

getFeedback

protected float getFeedback(ExecReport er)
compute feedback to local ant colony after task execution. Each node can use its own feedback computation to handle local parameters only known here. But each feedback should have the same goal : return higher value for higher power used/available. Default implementation just consider task completion time

Parameters:
er - execute report
Returns:
computed load indice.

getFeedback

protected float getFeedback(ExecRequest er)
compute feedback to local ant colony after task schedule. Default implementation just consider route path length.

Parameters:
er - execute request
Returns:
computed load indice.

setSelector

protected void setSelector(Selector s)
defines selector. should be used in constructor, unless selection mechanism need realy to be changed during node's life

Parameters:
s - selector to use to perform node choice.

getTaskCount

protected int getTaskCount()
gets current task count on this node.

Returns:
the task count.