com.sun.sgs.impl.service.nodemap.affinity.dlpa
Class LabelPropagationServer

java.lang.Object
  extended by com.sun.sgs.impl.service.nodemap.affinity.BasicState
      extended by com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagationServer
All Implemented Interfaces:
AffinityGroupFinder, LPAServer, LPAAffinityGroupFinder, Remote

public class LabelPropagationServer
extends BasicState
implements LPAAffinityGroupFinder, LPAServer

The server portion of the distributed label propagation algorithm.

The server is known to each node participating in the algorithm. It is responsible for preparing the nodes for a run of the algorithm, coordinating the iterations of the algorithm, and collecting and merging results from each node when finished.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.sgs.impl.service.nodemap.affinity.BasicState
BasicState.State
 
Field Summary
(package private) static int DEFAULT_MAX_IO_ATTEMPTS
          The default number of IO task retries.
(package private) static int DEFAULT_RETRY_WAIT_TIME
          The default time interval to wait between IO task retries.
static int DEFAULT_SERVER_PORT
          The default value of the server port.
static String IO_TASK_PROPERTY_PREFIX
          Prefix for io task related properties.
static String IO_TASK_RETRIES_PROPERTY
          An optional property that specifies the maximum number of retries for IO tasks in services.
static String IO_TASK_WAIT_TIME_PROPERTY
          An optional property that specifies the wait time between successive IO task retries.
static String SERVER_EXPORT_NAME
          The name we export ourselves under.
static String SERVER_PORT_PROPERTY
          The property name for the server port.
 
Fields inherited from class com.sun.sgs.impl.service.nodemap.affinity.BasicState
state
 
Constructor Summary
LabelPropagationServer(ProfileCollector col, WatchdogService wdog, Properties properties)
          Constructs a new label propagation server.
 
Method Summary
 void disable()
          Disables the finder.
 void enable()
          Enables the finder.
 NavigableSet<RelocatingAffinityGroup> findAffinityGroups()
          Finds affinity groups across all nodes in the Darkstar cluster.
 void finishedIteration(long nodeId, boolean converged, boolean failed, int iteration)
          Indicates that the given nodeId has completed an iteration of the label propagation algorithm.
 LPAClient getLPAClientProxy(long nodeId)
          Returns the LPAClient for the given nodeId.
 void readyToBegin(long nodeId, boolean failed)
          Indicates that the given nodeId is ready to begin the label propagation algorithm.
 void register(long nodeId, LPAClient client)
          Registers a proxy for the node.
(package private) static boolean runIoTask(IoRunnable ioTask, WatchdogService wdog, long nodeId, int maxTries, int waitTime, String name)
          Executes the specified ioTask by invoking its run method.
 void shutdown()
          Shuts down the finder.
 
Methods inherited from class com.sun.sgs.impl.service.nodemap.affinity.BasicState
checkForDisabledOrShutdownState, checkForShutdownState, setDisabledState, setEnabledState, setShutdownState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVER_PORT_PROPERTY

public static final String SERVER_PORT_PROPERTY
The property name for the server port.

See Also:
Constant Field Values

DEFAULT_SERVER_PORT

public static final int DEFAULT_SERVER_PORT
The default value of the server port.

See Also:
Constant Field Values

SERVER_EXPORT_NAME

public static final String SERVER_EXPORT_NAME
The name we export ourselves under.

See Also:
Constant Field Values

IO_TASK_PROPERTY_PREFIX

public static final String IO_TASK_PROPERTY_PREFIX
Prefix for io task related properties.

See Also:
Constant Field Values

IO_TASK_RETRIES_PROPERTY

public static final String IO_TASK_RETRIES_PROPERTY
An optional property that specifies the maximum number of retries for IO tasks in services.

See Also:
Constant Field Values

IO_TASK_WAIT_TIME_PROPERTY

public static final String IO_TASK_WAIT_TIME_PROPERTY
An optional property that specifies the wait time between successive IO task retries.

See Also:
Constant Field Values

DEFAULT_MAX_IO_ATTEMPTS

static final int DEFAULT_MAX_IO_ATTEMPTS
The default number of IO task retries.

See Also:
Constant Field Values

DEFAULT_RETRY_WAIT_TIME

static final int DEFAULT_RETRY_WAIT_TIME
The default time interval to wait between IO task retries.

See Also:
Constant Field Values
Constructor Detail

LabelPropagationServer

public LabelPropagationServer(ProfileCollector col,
                              WatchdogService wdog,
                              Properties properties)
                       throws IOException
Constructs a new label propagation server. Only one should exist within a Darkstar cluster.

Parameters:
col - the profile collector
wdog - the watchdog service, used for error reporting
properties - the application properties
Throws:
IOException - if an error occurs
Method Detail

findAffinityGroups

public NavigableSet<RelocatingAffinityGroup> findAffinityGroups()
                                                         throws AffinityGroupFinderFailedException
Finds affinity groups across all nodes in the Darkstar cluster. If no groups are found, an empty set is returned. If an error is encountered during a run, an AffinityGroupFinderFailedException is thrown. Errors include nodes not responding to server requests.

Specified by:
findAffinityGroups in interface LPAAffinityGroupFinder
Returns:
the affinity groups, or an empty set if none are found
Throws:
AffinityGroupFinderFailedException - if there is an error

disable

public void disable()
Disables the finder.

Specified by:
disable in interface AffinityGroupFinder

enable

public void enable()
Enables the finder.

Specified by:
enable in interface AffinityGroupFinder

shutdown

public void shutdown()
Shuts down the finder.

Specified by:
shutdown in interface AffinityGroupFinder

readyToBegin

public void readyToBegin(long nodeId,
                         boolean failed)
                  throws IOException
Indicates that the given nodeId is ready to begin the label propagation algorithm.

Specified by:
readyToBegin in interface LPAServer
Parameters:
nodeId - the node that is ready to begin
failed - true if there was a problem while setting up
Throws:
IOException - if there is a communication problem

finishedIteration

public void finishedIteration(long nodeId,
                              boolean converged,
                              boolean failed,
                              int iteration)
                       throws IOException
Indicates that the given nodeId has completed an iteration of the label propagation algorithm.

Specified by:
finishedIteration in interface LPAServer
Parameters:
nodeId - the node that has finished an iteration
converged - true if the node believes the algorithm has converged and can be stopped
failed - true if there was a problem while running
iteration - the iteration that has finished
Throws:
IOException - if there is a communication problem

getLPAClientProxy

public LPAClient getLPAClientProxy(long nodeId)
                            throws IOException
Returns the LPAClient for the given nodeId. If null is returned, the node should be considered failed.

Specified by:
getLPAClientProxy in interface LPAServer
Parameters:
nodeId - the node we need the proxy for
Returns:
the LPA client proxy for the given node, or null if the node has failed
Throws:
IOException - if there is a communication problem

register

public void register(long nodeId,
                     LPAClient client)
              throws IOException
Registers a proxy for the node. If a client has already been registered for the node, it is replaced.

Specified by:
register in interface LPAServer
Parameters:
nodeId - the node the proxy represents
client - the client proxy, which this server and other nodes can call
Throws:
IOException - if there is a communication problem

runIoTask

static boolean runIoTask(IoRunnable ioTask,
                         WatchdogService wdog,
                         long nodeId,
                         int maxTries,
                         int waitTime,
                         String name)
Executes the specified ioTask by invoking its run method. If the specified task throws an IOException, this method will retry the task for a fixed number of times. The number of retries and the wait time between retries are configurable properties.

This is much the same as the like method in AbstractService, except we don't bother to check for a transactional context (we won't be in one).

Parameters:
ioTask - a task with IO-related operations
wdog - the watchdog service for the local node, in case of failure
nodeId - the node that should be shut down in case of failure
maxTries - the number of times to attempt the retry
waitTime - the amount of time to wait before retry
name - name of caller, in case of failure
Returns:
true if the ioTask ran successfully

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved