gov.sandia.ccaffeine.dc.distributed
Class ServerMux

java.lang.Object
  extended by gov.sandia.ccaffeine.dc.distributed.ServerMux
All Implemented Interfaces:
HeartbeatListener, ShutdownListener, java.util.EventListener

public class ServerMux
extends java.lang.Object
implements HeartbeatListener, ShutdownListener

|--in--| client1 |-------------|---in----|-----------|-out--| |controllerClient |--out----|ServerMux |--in--| client2 |-------------| |-----------|-out--| . . . . . .


Field Summary
protected  int builderPort
           
static java.lang.String DATA_COLLECTOR_ACK
           
static java.lang.String DATA_COLLECTOR_MSG
           
static java.lang.String DID_NOT_RECEIVE_HEARTBEAT_FROM_GUI_CLIENT
           
protected  HeartbeatMonitor heartbeatMonitor
           
static java.lang.String REMOVE_CLIENT_MSG
           
static java.lang.String SERVER_SRC
           
static java.lang.String SHUTDOWN_MSG
           
 
Constructor Summary
ServerMux(gov.sandia.ccaffeine.dc.distributed.ConnectionManager computeClientMgr, Connection controllerConnect, gov.sandia.ccaffeine.dc.distributed.ClientFactory clientFactory)
           
ServerMux(gov.sandia.ccaffeine.dc.distributed.ConnectionManager computeClientMgr, Connection controllerConnect, gov.sandia.ccaffeine.dc.distributed.ClientFactory clientFactory, int heartbeatTimeout, int builderPort)
           
ServerMux(java.io.InputStream[] in, java.io.OutputStream[] out, java.io.InputStream controllerInput, java.io.OutputStream controllerOutput)
           
 
Method Summary
 void addOutOfBandListener(gov.sandia.ccaffeine.dc.distributed.OutOfBandListener l)
          Register a listener to receive out of band messages recognized as lines beginning with an out of band token.
 void broadcastToClients(java.lang.String s)
           
 void clientOutput(gov.sandia.ccaffeine.dc.distributed.ClientOutputEvent evt)
           
 void didNotReceiveHeartbeat(HeartbeatEvent event)
          If the heartbeat monitor notices that the GUI client has stopped sending heartbeats to the Muxer then the heartbeat monitor will invoke this method.
 void doClientIO()
          Initiate listening and multiplexing client output now.
 java.lang.Thread getControllerClientThread()
           
 int getNumClients()
           
static java.lang.String getOutofBandToken()
          Return the out of band token.
 boolean isRunning()
           
protected  void killAllMpiNodes(int builderPort)
          Kill all MPI nodes
 void newConnect(Connection newConnection)
           
 void receivedHeartbeat(HeartbeatEvent event)
           
 void relayMessageFromController(java.lang.String s)
           
 void relayMessageFromDataProducers(java.lang.String s)
           
 void removeOutOfBandListener(gov.sandia.ccaffeine.dc.distributed.OutOfBandListener l)
           
 void serverShuttingDown(ShutdownEvent event)
          This method is invoked whenever the controllerClient shuts down.
 void setDataCollectorByName(java.lang.String className)
           
 void setExternalClientOutputListener(gov.sandia.ccaffeine.dc.distributed.ClientOutputListener xLsnr)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVER_SRC

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

DATA_COLLECTOR_ACK

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

REMOVE_CLIENT_MSG

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

SHUTDOWN_MSG

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

DATA_COLLECTOR_MSG

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

DID_NOT_RECEIVE_HEARTBEAT_FROM_GUI_CLIENT

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

heartbeatMonitor

protected HeartbeatMonitor heartbeatMonitor

builderPort

protected int builderPort
Constructor Detail

ServerMux

public ServerMux(java.io.InputStream[] in,
                 java.io.OutputStream[] out,
                 java.io.InputStream controllerInput,
                 java.io.OutputStream controllerOutput)

ServerMux

public ServerMux(gov.sandia.ccaffeine.dc.distributed.ConnectionManager computeClientMgr,
                 Connection controllerConnect,
                 gov.sandia.ccaffeine.dc.distributed.ClientFactory clientFactory,
                 int heartbeatTimeout,
                 int builderPort)
Parameters:
computeClientMgr - connections to MPI nodes
controllerConnect - connection to GUI client
clientFactory - factory that can create socket connections
heartbeatTimout - number of milliseconds we will wait for a heartbeat from the GUI client
builderPort - The Muxer port that the GUI client connects to

ServerMux

public ServerMux(gov.sandia.ccaffeine.dc.distributed.ConnectionManager computeClientMgr,
                 Connection controllerConnect,
                 gov.sandia.ccaffeine.dc.distributed.ClientFactory clientFactory)
Method Detail

serverShuttingDown

public void serverShuttingDown(ShutdownEvent event)
This method is invoked whenever the controllerClient shuts down. We want to respond by shutting down all of the MPI nodes.

Specified by:
serverShuttingDown in interface ShutdownListener
Parameters:
event - The event that is generated when the controllerClient shuts down.

shutdown

public void shutdown()

killAllMpiNodes

protected void killAllMpiNodes(int builderPort)
Kill all MPI nodes

Parameters:
builderPort - the port number, on the Muxer, that the GUI client uses to connect to the Muxer.

setExternalClientOutputListener

public void setExternalClientOutputListener(gov.sandia.ccaffeine.dc.distributed.ClientOutputListener xLsnr)

getControllerClientThread

public java.lang.Thread getControllerClientThread()

doClientIO

public void doClientIO()
Initiate listening and multiplexing client output now.


broadcastToClients

public void broadcastToClients(java.lang.String s)

isRunning

public boolean isRunning()

didNotReceiveHeartbeat

public void didNotReceiveHeartbeat(HeartbeatEvent event)
If the heartbeat monitor notices that the GUI client has stopped sending heartbeats to the Muxer then the heartbeat monitor will invoke this method. We want to notify the ServerOutOfboundListener that the client is no longer connected to the Muxer.

Specified by:
didNotReceiveHeartbeat in interface HeartbeatListener
Parameters:
event - The event that gets generated whenever the heartbeat monitor notices that the GUI client is no longer sending heartbeats to the Muxer.

receivedHeartbeat

public void receivedHeartbeat(HeartbeatEvent event)
Specified by:
receivedHeartbeat in interface HeartbeatListener

clientOutput

public void clientOutput(gov.sandia.ccaffeine.dc.distributed.ClientOutputEvent evt)

newConnect

public void newConnect(Connection newConnection)

relayMessageFromDataProducers

public void relayMessageFromDataProducers(java.lang.String s)

relayMessageFromController

public void relayMessageFromController(java.lang.String s)

getNumClients

public int getNumClients()

setDataCollectorByName

public void setDataCollectorByName(java.lang.String className)

addOutOfBandListener

public void addOutOfBandListener(gov.sandia.ccaffeine.dc.distributed.OutOfBandListener l)
Register a listener to receive out of band messages recognized as lines beginning with an out of band token.


removeOutOfBandListener

public void removeOutOfBandListener(gov.sandia.ccaffeine.dc.distributed.OutOfBandListener l)

getOutofBandToken

public static java.lang.String getOutofBandToken()
Return the out of band token.