fulmine.distribution.connection.tcp
Class TcpNetwork

java.lang.Object
  extended by fulmine.distribution.connection.tcp.TcpNetwork
All Implemented Interfaces:
INetwork, IHeartbeatMonitor
Direct Known Subclasses:
FTTcpNetwork

public class TcpNetwork
extends Object
implements INetwork

Creates components that connect using TCP/IP.

Author:
Ramon Servadei

Field Summary
 
Fields inherited from interface fulmine.distribution.IHeartbeatMonitor
DEFAULT_ALLOWED_MISSED_COUNT, DEFAULT_HEARTBEAT_PERIOD
 
Constructor Summary
TcpNetwork()
          Default constructor that reads system properties for the IP address and TCP port to use.
TcpNetwork(String address, int port)
          Construct the network to use specific parameters for the IP address and TCP port of the network connection for the context.
TcpNetwork(String hostAddress, int tcpPort, String udpNetwork, int udpPort, String udpNic)
          Construct the network to use specifying specific parameters for: the IP address and TCP port of the network connection for the context the UDP connection parameters for the discoverer
 
Method Summary
 IConnectionBroker createBroker()
          Create a connection broker.
 IChannel createChannel(IConnection connection)
          Create a channel
 IConnectionDiscoverer createDiscoverer()
          Create a connection discoverer.
 int getAllowableNetworkHeartbeatMissCount()
          Get the number of allowed missed heartbeats before a remote context is deemed to be not available.
 long getNetworkHeartbeatPeriod()
          Get the heartbeat period in milliseconds.
 boolean isListeningOnlyMode()
          Get the value of the listening only mode
 void setAllowableNetworkHeartbeatMissCount(int allowedHeartbeatMissCount)
          Set the allowable number of missed heartbeats from other contexts on the network before that context is deemed to be not available anymore.
 void setContext(IFrameworkContext context)
          Set the context this network services
 void setListeningOnlyMode(boolean listeningOnlyMode)
          Sets the IConnectionDiscoverer returned from INetwork.createDiscoverer() into listening-only mode.
 void setNetworkHeartbeatPeriod(long periodInMillis)
          Set the network heartbeat period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpNetwork

public TcpNetwork()
Default constructor that reads system properties for the IP address and TCP port to use.

See Also:
TcpConnectionBroker.CONTEXT_IP_ADDRESS, TcpConnectionBroker.CONTEXT_TCP_PORT, TcpConnectionBroker.DEFAULT_CONTEXT_TCP_PORT, AbstractConnectionDiscoverer.DEFAULT_UDP_DISCOVERY_NETWORK, AbstractConnectionDiscoverer.DEFAULT_UDP_DISCOVERY_PORT

TcpNetwork

public TcpNetwork(String address,
                  int port)
Construct the network to use specific parameters for the IP address and TCP port of the network connection for the context.

Parameters:
address - the IP address (or hostname) of the host, null for the host address of the local host
port - the TCP port for the context's network connection, 0 for TcpConnectionBroker.DEFAULT_CONTEXT_TCP_PORT

TcpNetwork

public TcpNetwork(String hostAddress,
                  int tcpPort,
                  String udpNetwork,
                  int udpPort,
                  String udpNic)
Construct the network to use specifying specific parameters for:

Parameters:
hostAddress - the IP address (or hostname) of the host, null for the host address of the local host
tcpPort - the TCP port for the context's network connection, 0 for TcpConnectionBroker.DEFAULT_CONTEXT_TCP_PORT
udpNetwork - the UDP network for the discoverer
udpPort - the UDP port for the discoverer
udpNic - the network interface card name to bind to, null for default
Method Detail

createBroker

public IConnectionBroker createBroker()
Description copied from interface: INetwork
Create a connection broker.

Specified by:
createBroker in interface INetwork
Returns:
a connection broker

createChannel

public IChannel createChannel(IConnection connection)
Description copied from interface: INetwork
Create a channel

Specified by:
createChannel in interface INetwork
Parameters:
connection - the connection for the channel
Returns:
a new channel wrapping the connection

createDiscoverer

public IConnectionDiscoverer createDiscoverer()
Description copied from interface: INetwork
Create a connection discoverer.

Specified by:
createDiscoverer in interface INetwork
Returns:
a connection discoverer

setContext

public void setContext(IFrameworkContext context)
Description copied from interface: INetwork
Set the context this network services

Specified by:
setContext in interface INetwork
Parameters:
context - the context this network services

setAllowableNetworkHeartbeatMissCount

public void setAllowableNetworkHeartbeatMissCount(int allowedHeartbeatMissCount)
Description copied from interface: IHeartbeatMonitor
Set the allowable number of missed heartbeats from other contexts on the network before that context is deemed to be not available anymore.

Specified by:
setAllowableNetworkHeartbeatMissCount in interface IHeartbeatMonitor
Parameters:
allowedHeartbeatMissCount - the number of missed heartbeats allowed before a remote context is deemed to be not available
See Also:
IHeartbeatMonitor.setNetworkHeartbeatPeriod(long)

setNetworkHeartbeatPeriod

public void setNetworkHeartbeatPeriod(long periodInMillis)
Description copied from interface: IHeartbeatMonitor
Set the network heartbeat period. This local context will send out a heartbeat ping message onto the network at this rate.

As a general rule-of-thumb, the heartbeat period should be small and the allowed heartbeat miss count high. This provides more leniency for not cancelling a context if heartbeats are missed.

Specified by:
setNetworkHeartbeatPeriod in interface IHeartbeatMonitor
Parameters:
periodInMillis - the heartbeat period in milliseconds

getAllowableNetworkHeartbeatMissCount

public int getAllowableNetworkHeartbeatMissCount()
Description copied from interface: IHeartbeatMonitor
Get the number of allowed missed heartbeats before a remote context is deemed to be not available.

Specified by:
getAllowableNetworkHeartbeatMissCount in interface IHeartbeatMonitor
Returns:
the number of missed heartbeats allowed before a remote context is deemed to be not available

getNetworkHeartbeatPeriod

public long getNetworkHeartbeatPeriod()
Description copied from interface: IHeartbeatMonitor
Get the heartbeat period in milliseconds.

Specified by:
getNetworkHeartbeatPeriod in interface IHeartbeatMonitor
Returns:
the heartbeat period in milliseconds

setListeningOnlyMode

public void setListeningOnlyMode(boolean listeningOnlyMode)
Description copied from interface: INetwork
Sets the IConnectionDiscoverer returned from INetwork.createDiscoverer() into listening-only mode. This effectively means that the discoverer will not send out pulses but will monitor the pulses from other contexts.

Calling this after the discoverer is created and started will also cause the discoverer to go into listening-only mode.

Specified by:
setListeningOnlyMode in interface INetwork
Parameters:
listeningOnlyMode - true if the discoverer should be in listening only mode
See Also:
IConnectionDiscoverer.disablePulsing()

isListeningOnlyMode

public boolean isListeningOnlyMode()
Description copied from interface: INetwork
Get the value of the listening only mode

Specified by:
isListeningOnlyMode in interface INetwork
Returns:
true if the discoverer is in listening only mode


Copyright © 2007-2009. All Rights Reserved.