net.grinder.console.communication
Class ConsoleCommunicationImplementation

java.lang.Object
  extended by net.grinder.console.communication.ConsoleCommunicationImplementation
All Implemented Interfaces:
ConsoleCommunication

public final class ConsoleCommunicationImplementation
extends Object
implements ConsoleCommunication

Handles communication for the console.

Author:
Philip Aston

Constructor Summary
ConsoleCommunicationImplementation(Resources resources, ConsoleProperties properties, ErrorHandler errorHandler, TimeAuthority timeAuthority)
          Constructor that uses a default idlePollDelay.
ConsoleCommunicationImplementation(Resources resources, ConsoleProperties properties, ErrorHandler errorHandler, TimeAuthority timeAuthority, long idlePollDelay, long inactiveClientTimeOut)
          Constructor.
 
Method Summary
 MessageDispatchRegistry getMessageDispatchRegistry()
          Returns the message dispatch registry which callers can use to register new message handlers.
 int getNumberOfConnections()
          The number of connections that have been accepted and are still active.
 boolean processOneMessage()
          Wait to receive a message, then process it.
 void sendToAddressedAgents(Address address, Message message)
          Send the given message to the given agent processes (which may pass it on to its workers).
 void sendToAgents(Message message)
          Send the given message to the agent processes (which may pass it on to their workers).
 void shutdown()
          Shut down communication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleCommunicationImplementation

public ConsoleCommunicationImplementation(Resources resources,
                                          ConsoleProperties properties,
                                          ErrorHandler errorHandler,
                                          TimeAuthority timeAuthority)
                                   throws DisplayMessageConsoleException
Constructor that uses a default idlePollDelay.

Parameters:
resources - Resources.
properties - Console properties.
errorHandler - Error handler.
timeAuthority - Knows the time
Throws:
DisplayMessageConsoleException - If properties are invalid.

ConsoleCommunicationImplementation

public ConsoleCommunicationImplementation(Resources resources,
                                          ConsoleProperties properties,
                                          ErrorHandler errorHandler,
                                          TimeAuthority timeAuthority,
                                          long idlePollDelay,
                                          long inactiveClientTimeOut)
                                   throws DisplayMessageConsoleException
Constructor.

Parameters:
resources - Resources.
properties - Console properties.
errorHandler - Error handler.
timeAuthority - Knows the time
idlePollDelay - Time in milliseconds that our ServerReceiver threads should sleep for if there's no incoming messages.
inactiveClientTimeOut - How long before we consider a client connection that presents no data to be inactive.
Throws:
DisplayMessageConsoleException - If properties are invalid.
Method Detail

getMessageDispatchRegistry

public MessageDispatchRegistry getMessageDispatchRegistry()
Returns the message dispatch registry which callers can use to register new message handlers.

Specified by:
getMessageDispatchRegistry in interface ConsoleCommunication
Returns:
The registry.

shutdown

@PreDestroy
public void shutdown()
Shut down communication.

Specified by:
shutdown in interface ConsoleCommunication

processOneMessage

public boolean processOneMessage()
Wait to receive a message, then process it.

Specified by:
processOneMessage in interface ConsoleCommunication
Returns:
true if we processed a message successfully; false if we've been shut down.
See Also:
shutdown()

getNumberOfConnections

public int getNumberOfConnections()
The number of connections that have been accepted and are still active. Used by the unit tests.

Returns:
The number of accepted connections.

sendToAgents

public void sendToAgents(Message message)
Send the given message to the agent processes (which may pass it on to their workers).

Any errors that occur will be handled with the error handler.

Specified by:
sendToAgents in interface ConsoleCommunication
Parameters:
message - The message to send.

sendToAddressedAgents

public void sendToAddressedAgents(Address address,
                                  Message message)
Send the given message to the given agent processes (which may pass it on to its workers).

Any errors that occur will be handled with the error handler.

Specified by:
sendToAddressedAgents in interface ConsoleCommunication
Parameters:
address - The address to which the message should be sent.
message - The message to send.


Copyright © 2000-2013. All Rights Reserved.