Class RelayTransportAgent
- java.lang.Object
-
- jadex.platform.service.message.relaytransport.RelayTransportAgent
-
- All Implemented Interfaces:
ITransportService
,IRoutingService
public class RelayTransportAgent extends java.lang.Object implements ITransportService, IRoutingService
Agent implementing relay routing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RelayTransportAgent.Ack
Acknowledgement message.static class
RelayTransportAgent.Ping
Ping message.
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
agent
The agent.protected int
cachesize
Size of the routing cache.protected IComponentStep<java.lang.Void>
connectstep
Component step used to connect to relays.protected boolean
debug
Set to true for more verbose output.protected PassiveLeaseTimeSet<IComponentIdentifier>
directconns
Directly connected platforms.protected IExecutionFeature
execfeat
Execution feature.static java.lang.String
FORWARD_DEST
ID of forwarding messages.static java.lang.String
FORWARD_SENDER
ID of sender of forwarding messages.protected boolean
forwarding
Flag if the transport allows forwarding.protected jadex.bridge.component.impl.IInternalMessageFeature
intmsgfeat
Relay transport agent's internal message feature.protected java.util.Set<IComponentIdentifier>
keepaliveconnections
List of working connections to relays.protected int
keepalivecount
Maintain a connection to at least this number of relays.protected long
keepaliveinterval
Delay of keepalive messages.protected Future<java.lang.Void>
keepaliveupdatefuture
Update future to shorten timeout when keepalive update happens.protected long
nextclean
Timestamp of the next clean for direct routes.protected static int
PRIORITY
Transport priority = lowprotected java.util.LinkedHashSet<IComponentIdentifier>
relays
List of relays.protected Future<java.lang.Void>
relayupdatefuture
Update future to shorten timeout when query update happens.protected IRwMap<IComponentIdentifier,Tuple2<IComponentIdentifier,java.lang.Integer>>
routecache
Routing information (target platform / next route hop + cost).protected int
routingdelay
Maximum time spent on finding routing services.protected LRU<IComponentIdentifier,IRoutingService>
routingservicecache
Cache for routing service proxies.protected ISecurityService
secservice
Security service.
-
Constructor Summary
Constructors Constructor Description RelayTransportAgent()
Creates the agent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IIntermediateFuture<java.lang.Integer>
discoverRoute(IComponentIdentifier dest, java.util.LinkedHashSet<IComponentIdentifier> hops)
Attempts to find a route to a destination.protected IFuture<byte[]>
encryptHeader(IMsgHeader header)
Encrypts the header.protected ITerminableFuture<java.lang.Integer>
forwardMessage(IMsgHeader header, byte[] body)
protected Tuple2<IComponentIdentifier,java.lang.Integer>
getRouteFromCache(IComponentIdentifier target)
Gets a route from cache.protected IRoutingService
getRoutingService(IComponentIdentifier relayplatform)
Gets a proxy of the routing service of a known relay.protected IComponentIdentifier
getRtComponent(IComponentIdentifier platformid)
Gets the relay transport component for a platform.protected boolean
hasDirectConnection(IComponentIdentifier target)
Checks if a direct connection to target exists.ITerminableFuture<java.lang.Integer>
sendMessage(IMsgHeader header, byte[] encheader, byte[] body)
Send a message.protected void
setupClient()
Sets the transport up to be a relay client.protected void
setupForwarding()
Sets the transport up to allow forwarding / relay mode.IFuture<java.lang.Void>
start()
Agent initialization.
-
-
-
Field Detail
-
FORWARD_SENDER
public static final java.lang.String FORWARD_SENDER
ID of sender of forwarding messages.- See Also:
- Constant Field Values
-
FORWARD_DEST
public static final java.lang.String FORWARD_DEST
ID of forwarding messages.- See Also:
- Constant Field Values
-
PRIORITY
protected static final int PRIORITY
Transport priority = low- See Also:
- Constant Field Values
-
agent
protected IInternalAccess agent
The agent.
-
secservice
protected ISecurityService secservice
Security service.
-
execfeat
protected IExecutionFeature execfeat
Execution feature.
-
intmsgfeat
protected jadex.bridge.component.impl.IInternalMessageFeature intmsgfeat
Relay transport agent's internal message feature.
-
forwarding
protected boolean forwarding
Flag if the transport allows forwarding.
-
keepalivecount
protected int keepalivecount
Maintain a connection to at least this number of relays.
-
keepaliveinterval
protected long keepaliveinterval
Delay of keepalive messages.
-
routingdelay
protected int routingdelay
Maximum time spent on finding routing services.
-
debug
protected boolean debug
Set to true for more verbose output.
-
cachesize
protected int cachesize
Size of the routing cache.
-
nextclean
protected long nextclean
Timestamp of the next clean for direct routes.
-
relays
protected java.util.LinkedHashSet<IComponentIdentifier> relays
List of relays.
-
keepaliveconnections
protected java.util.Set<IComponentIdentifier> keepaliveconnections
List of working connections to relays.
-
connectstep
protected IComponentStep<java.lang.Void> connectstep
Component step used to connect to relays.
-
routingservicecache
protected LRU<IComponentIdentifier,IRoutingService> routingservicecache
Cache for routing service proxies.
-
directconns
protected PassiveLeaseTimeSet<IComponentIdentifier> directconns
Directly connected platforms.
-
routecache
protected IRwMap<IComponentIdentifier,Tuple2<IComponentIdentifier,java.lang.Integer>> routecache
Routing information (target platform / next route hop + cost).
-
keepaliveupdatefuture
protected Future<java.lang.Void> keepaliveupdatefuture
Update future to shorten timeout when keepalive update happens.
-
relayupdatefuture
protected Future<java.lang.Void> relayupdatefuture
Update future to shorten timeout when query update happens.
-
-
Method Detail
-
start
public IFuture<java.lang.Void> start()
Agent initialization.
-
sendMessage
public ITerminableFuture<java.lang.Integer> sendMessage(IMsgHeader header, byte[] encheader, byte[] body)
Send a message.- Specified by:
sendMessage
in interfaceITransportService
- Parameters:
header
- Message header.body
- Message body.encheader
- Message header already encoded and encrypted for sending.- Returns:
- Done, when sent, failure otherwise.
-
forwardMessage
protected ITerminableFuture<java.lang.Integer> forwardMessage(IMsgHeader header, byte[] body)
-
discoverRoute
public IIntermediateFuture<java.lang.Integer> discoverRoute(IComponentIdentifier dest, java.util.LinkedHashSet<IComponentIdentifier> hops)
Attempts to find a route to a destination.- Specified by:
discoverRoute
in interfaceIRoutingService
- Parameters:
destination
- The destination.hops
- Previous hops.- Returns:
- Route cost when routing via this route (multiple returns with different costs possible).
-
setupForwarding
protected void setupForwarding()
Sets the transport up to allow forwarding / relay mode.
-
setupClient
protected void setupClient()
Sets the transport up to be a relay client.
-
getRoutingService
protected IRoutingService getRoutingService(IComponentIdentifier relayplatform)
Gets a proxy of the routing service of a known relay.- Parameters:
relay
- The relay ID.- Returns:
- Service proxy.
-
getRouteFromCache
protected Tuple2<IComponentIdentifier,java.lang.Integer> getRouteFromCache(IComponentIdentifier target)
Gets a route from cache.- Parameters:
target
- The target.- Returns:
- The route, or null if not found.
-
hasDirectConnection
protected boolean hasDirectConnection(IComponentIdentifier target)
Checks if a direct connection to target exists.- Parameters:
target
- The target.- Returns:
- True, if connection exists.
-
getRtComponent
protected IComponentIdentifier getRtComponent(IComponentIdentifier platformid)
Gets the relay transport component for a platform.- Parameters:
platformid
- The platform ID.- Returns:
- ID of the relay transport component.
-
encryptHeader
protected IFuture<byte[]> encryptHeader(IMsgHeader header)
Encrypts the header.- Parameters:
header
- Header.- Returns:
- Encrypted header.
-
-