public class Tunnel extends Agent implements ConnectionListener, MessageListener
A tunnel can be configured as a server or a client. A server tunnel listens on a specified TCP port for incoming connections from client tunnels. A client tunnel connects to a server tunnel at a specified IP address and TCP port.
Once a connection is established, the tunnel agent forwards selected messages
between the two platforms. The agents parameter specifies the list of remote
agents or topics forwarded through the tunnel.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
__doc__ |
protected java.util.List<AgentID> |
agents |
protected java.util.List<Connector> |
connectors |
protected int |
connID
Monotonically increasing connection id counter.
|
protected java.util.Map<java.lang.Integer,Connector> |
connIDs
Map of connection id to Connector.
|
protected java.lang.String |
ip |
protected static long |
MONITOR_PERIOD |
protected int |
port |
protected java.util.concurrent.ExecutorService |
readExecutor |
protected TcpServer |
server |
protected java.util.concurrent.ExecutorService |
writeExecutor |
| Constructor and Description |
|---|
Tunnel(int port) |
Tunnel(java.lang.String ip,
int port) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
connect() |
void |
connected(Connector connector) |
java.util.List<AgentID> |
getAgents()
Get the list of remote agents or topics visible through the tunnel.
|
java.util.Map<java.lang.Integer,java.lang.String> |
getConnIDs()
Get the list of currently connected connection IDs.
|
java.lang.String |
getDescription()
Get description of the tunnel agent.
|
java.lang.String |
getIp()
Get IP address for the tunnel.
|
int |
getPort()
Get TCP port number for the tunnel.
|
java.lang.String |
getTitle()
Get title of the tunnel agent.
|
void |
init()
Called by the container when the agent is started.
|
protected void |
monitor(int id,
Connector c) |
boolean |
onReceive(Message msg)
This method is called for each message to be conveyed to the listener.
|
protected void |
removeConnector(Connector c) |
protected void |
sendToRemote(Connector c,
byte[] data) |
void |
setAgents(java.util.List<AgentID> agents)
Set the list of remote agents or topics visible through the tunnel.
|
void |
shutdown()
Called by the container when the agent is terminated.
|
add, agent, agentForService, agentForService, agentsForService, agentsForService, block, block, clone, currentTimeMillis, delay, deregister, deregister, die, getAgentID, getContainer, getName, getPlatform, getState, getStore, getType, getYieldDuringReceive, nanoTime, platformSend, prepareRequest, println, receive, receive, receive, receive, receive, receive, receive, receive, register, register, request, request, run, send, setLogLevel, setQueueSize, setYieldDuringReceive, stop, subscribe, topic, topic, topic, topic, topic, topic, toString, unsubscribe, wakeprotected static final long MONITOR_PERIOD
protected java.lang.String ip
protected int port
protected TcpServer server
protected final java.util.List<AgentID> agents
protected final java.util.List<Connector> connectors
protected java.util.concurrent.ExecutorService writeExecutor
protected java.util.concurrent.ExecutorService readExecutor
protected int connID
protected java.util.Map<java.lang.Integer,Connector> connIDs
connIDs parameter exposes the
keys of this map as a read-only snapshot.public static final java.lang.String __doc__
public Tunnel(int port)
public Tunnel(java.lang.String ip,
int port)
public void init()
Agentpublic void shutdown()
Agentpublic void connected(Connector connector)
connected in interface ConnectionListenerprotected void connect()
public boolean onReceive(Message msg)
MessageListenerIf this method returns true, the message is assumed to be consumed and is immediately discarded.
onReceive in interface MessageListenermsg - received message.protected void monitor(int id,
Connector c)
protected void sendToRemote(Connector c, byte[] data)
protected void removeConnector(Connector c)
public java.util.Map<java.lang.Integer,java.lang.String> getConnIDs()
public java.lang.String getIp()
public int getPort()
public java.util.List<AgentID> getAgents()
public void setAgents(java.util.List<AgentID> agents)
agents - List of remote agents/topics visible through the tunnel.public java.lang.String getTitle()
public java.lang.String getDescription()