|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthmi.bml.bridge.TCPIPRealizerBridgeServer
public final class TCPIPRealizerBridgeServer
Takes a RealizerBridge, and exposes access to it through a tcp/ip connection. The connection is "self-healing".
Detailed documentation can be found in the project report.
| Nested Class Summary | |
|---|---|
private class |
TCPIPRealizerBridgeServer.BMLReader
The process that reads bml from the network connection, and puts it in the bml queue. |
private class |
TCPIPRealizerBridgeServer.BMLRedirector
The process that reads bml from the bml queue, and sends it to the BML realizer. |
static class |
TCPIPRealizerBridgeServer.ServerState
|
| Field Summary | |
|---|---|
private static long |
BML_REDIRECT_WAIT_MILLI
Sleeping time of the BmlRequestRedirector if the bml queue is empty |
private int |
bmlPort
|
private ConcurrentLinkedQueue<String> |
bmlQ
Incoming bml from the client are stored here. |
private TCPIPRealizerBridgeServer.BMLReader |
bmlReader
|
private Thread |
bmlReaderThread
|
private BufferedReader |
bmlReadReader
|
private ServerSocket |
bmlReadServerSocket
|
private Socket |
bmlReadSocket
|
private TCPIPRealizerBridgeServer.BMLRedirector |
bmlRedirector
redirects bml that has come in over the socket to the realizerbridge |
private Thread |
bmlRedirectorThread
the thread under which the bmlRedirector runs. |
private static int |
CONNECT_RETRY_WAIT
|
private Object |
connectionLock
Locking object for the states of the main networking loop. |
protected List<ConnectionStateListener> |
connectionStateListeners
|
private int |
feedbackPort
|
private ConcurrentLinkedQueue<String> |
feedbackQ
Incoming Feedback from the RealizerBridge is stored here. |
private Socket |
feedbackSendSocket
|
private InetSocketAddress |
feedbackSendSocketAddress
|
private PrintWriter |
feedbackSendWriter
|
private boolean |
isconnected
Internal state var: true if a conenction to a server is active |
private static org.slf4j.Logger |
logger
|
private boolean |
mustconnect
Internal state var: true if someone connected on the bmlrequest port, and a feedback connection needs to be established |
private boolean |
mustdisconnect
Internal state var: true if a connection failed and the feedback connection needs to be cleaned up |
private boolean |
mustshutdown
Internal state var: true if a shutdown request has been given |
private long |
nextMainLoopWait
Waiting time for next run() loop. |
private RealizerBridge |
realizerBridge
The realizerbridge that will handle incoming bml |
private TCPIPRealizerBridgeServer.ServerState |
serverState
|
private static int |
SOCKET_TIMEOUT
|
private static int |
WAIT_AFTER_DROPPED_CLIENT
|
| Constructor Summary | |
|---|---|
TCPIPRealizerBridgeServer(RealizerBridge bridge,
int bmlPort,
int feedbackPort)
Set the state variables to appropriate values, start the main processing loop, and start the processing loop that will deliver bml messages to the Realizer. |
|
| Method Summary | |
|---|---|
void |
addConnectionStateListener(ConnectionStateListener l)
|
private void |
doconnect()
Attempt to connect to client feedback channel. |
private void |
dodisconnect()
Disconnect feedback connection to client. |
private void |
dosendFeedback(String feedback)
Send given feedbacki. |
private void |
doshutdown()
Disconnect. |
void |
exception(BMLExceptionFeedback be)
|
TCPIPRealizerBridgeServer.ServerState |
getStatus()
|
boolean |
isConnectedToClient()
Returns true iff there is a connection to a client active (and has not been lost). |
void |
performanceStart(BMLPerformanceStartFeedback psf)
|
void |
performanceStop(BMLPerformanceStopFeedback psf)
|
void |
planningFinished(BMLTPlanningFinishedFeedback pff)
|
void |
planningStart(BMLTPlanningStartFeedback psf)
|
private void |
queueFeedback(String fb)
|
private void |
retryConnect(String msg)
Error connecting, prepare to retry |
void |
run()
The main loop! |
private void |
setServerState(TCPIPRealizerBridgeServer.ServerState state)
|
void |
shutdown()
Instigates total shutdown. |
void |
stopBmlReadSockets()
Stop bml reading sockets preparatory to completely shutting down, or preparatory to connecting new client |
void |
stopFeedbackWriteSockets()
Stop feedback sending socket when to dropping client |
void |
syncProgress(BMLSyncPointProgressFeedback spp)
|
void |
warn(BMLWarningFeedback bw)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static org.slf4j.Logger logger
private static final long BML_REDIRECT_WAIT_MILLI
private static final int SOCKET_TIMEOUT
private static final int CONNECT_RETRY_WAIT
private static final int WAIT_AFTER_DROPPED_CLIENT
private TCPIPRealizerBridgeServer.ServerState serverState
protected List<ConnectionStateListener> connectionStateListeners
private ConcurrentLinkedQueue<String> feedbackQ
private Object connectionLock
private boolean isconnected
private boolean mustshutdown
private boolean mustdisconnect
private boolean mustconnect
private long nextMainLoopWait
private InetSocketAddress feedbackSendSocketAddress
private Socket feedbackSendSocket
private PrintWriter feedbackSendWriter
private ServerSocket bmlReadServerSocket
private Socket bmlReadSocket
private BufferedReader bmlReadReader
private TCPIPRealizerBridgeServer.BMLReader bmlReader
private Thread bmlReaderThread
private int bmlPort
private int feedbackPort
private TCPIPRealizerBridgeServer.BMLRedirector bmlRedirector
private Thread bmlRedirectorThread
private RealizerBridge realizerBridge
private ConcurrentLinkedQueue<String> bmlQ
| Constructor Detail |
|---|
public TCPIPRealizerBridgeServer(RealizerBridge bridge,
int bmlPort,
int feedbackPort)
| Method Detail |
|---|
public void shutdown()
public boolean isConnectedToClient()
public TCPIPRealizerBridgeServer.ServerState getStatus()
public void addConnectionStateListener(ConnectionStateListener l)
private void setServerState(TCPIPRealizerBridgeServer.ServerState state)
public void exception(BMLExceptionFeedback be)
exception in interface BMLExceptionListenerpublic void warn(BMLWarningFeedback bw)
warn in interface BMLWarningListenerpublic void syncProgress(BMLSyncPointProgressFeedback spp)
syncProgress in interface BMLFeedbackListenerpublic void performanceStop(BMLPerformanceStopFeedback psf)
performanceStop in interface BMLFeedbackListenerpublic void performanceStart(BMLPerformanceStartFeedback psf)
performanceStart in interface BMLFeedbackListenerpublic void planningFinished(BMLTPlanningFinishedFeedback pff)
planningFinished in interface BMLTPlanningListenerpublic void planningStart(BMLTPlanningStartFeedback psf)
planningStart in interface BMLTPlanningListenerprivate void queueFeedback(String fb)
public void stopBmlReadSockets()
public void stopFeedbackWriteSockets()
public void run()
run in interface Runnableprivate void dodisconnect()
private void doconnect()
private void retryConnect(String msg)
private void doshutdown()
private void dosendFeedback(String feedback)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||