Package jadex.platform.service.address
Class TransportAddressAgent
- java.lang.Object
-
- jadex.platform.service.address.TransportAddressAgent
-
- All Implemented Interfaces:
ITransportAddressService
public class TransportAddressAgent extends java.lang.Object implements ITransportAddressService
Agent that provides transport address resolution (platform id -> transport addresses).
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<IComponentIdentifier,java.util.LinkedHashSet<TransportAddress>>
addresses
The managed addresses: target platform -> (transport name -> transport addresses)protected java.util.LinkedHashSet<SubscriptionIntermediateFuture<Tuple2<TransportAddress,java.lang.Boolean>>>
addresssubs
Subscription of local address changes.protected IInternalAccess
agent
Component access.protected static int
ASK_ALL_LIMIT
Maximum number of peers to ask for addresses.protected boolean
askalllookup
protected boolean
awalookup
protected static long
CACHE_INVALIDITY_DUR
Freshness limit for previously failed renewed searches.protected static long
CACHE_VALIDITY_DUR
Freshness limit for renewed searches.protected boolean
directlookup
protected java.util.Map<IComponentIdentifier,java.lang.Long>
freshness
Freshness state of the cache.protected java.util.LinkedHashSet<TransportAddress>
localaddresses
The local addresses.protected java.util.Map<IComponentIdentifier,java.util.LinkedHashSet<TransportAddress>>
manualaddresses
The managed addresses: target platform -> (transport name -> transport addresses)protected boolean
pawalookup
protected java.util.Map<IComponentIdentifier,IFuture<java.util.List<TransportAddress>>>
searches
Current active searches.protected boolean
superpeerlookup
-
Constructor Summary
Constructors Constructor Description TransportAddressAgent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAddresses(java.util.Collection<TransportAddress> addrs)
Adds addresses to cache.protected void
addAddresses(java.util.Collection<TransportAddress> addrs, java.util.Map<IComponentIdentifier,java.util.LinkedHashSet<TransportAddress>> addressmap)
Adds addresses to a map.IFuture<java.lang.Void>
addLocalAddresses(java.util.Collection<TransportAddress> addresses)
Adds the addresses of the local platform.IFuture<java.lang.Void>
addManualAddresses(java.util.Collection<TransportAddress> addresses)
Adds user-specified addresses.protected void
addToManualAddressesList(java.util.Collection<TransportAddress> addrs)
Adds addresses to manual address list.protected java.util.List<TransportAddress>
filterAddresses(java.util.List<TransportAddress> addresses, java.lang.String transporttype)
Filters addresses for transport types.IFuture<java.util.List<TransportAddress>>
getAddresses()
Gets the addresses of the local platform.IFuture<java.util.List<TransportAddress>>
getAddresses(IComponentIdentifier platformid)
Gets the addresses of another platform known to the local platform.IFuture<java.util.List<TransportAddress>>
getAddresses(IComponentIdentifier platformid, java.lang.String transporttype)
Gets the addresses of another platform known to the local platform.IFuture<java.util.List<TransportAddress>>
getAddresses(java.lang.String transporttype)
Gets the addresses of the local platform.protected java.util.List<TransportAddress>
getAddressesFromCache(IComponentIdentifier platformid)
Gets platform addresses from local cache.protected boolean
hasSuperPeer()
Checks if a super peer is available.IFuture<java.lang.Void>
init()
Initializes the service.IFuture<java.util.List<TransportAddress>>
resolveAddresses(IComponentIdentifier platformid, java.lang.String transporttype)
Recursively looks up the addresses of a platform for a specific transport type.protected java.util.List<TransportAddress>
searchAddressesByAskAll(IComponentIdentifier platformid)
Randomly ask other platforms for addresses (search of last resort).protected java.util.List<TransportAddress>
searchAddressesByAskAwareness(IComponentIdentifier platformid)
Searches for addresses using super peer.protected java.util.List<TransportAddress>
searchAddressesByAskRemote(IComponentIdentifier platformid)
Searches for addresses directly asking remote platform.protected java.util.List<TransportAddress>
searchAddressesByAskSuperPeer(IComponentIdentifier platformid)
Searches for addresses using super peer.ISubscriptionIntermediateFuture<Tuple2<TransportAddress,java.lang.Boolean>>
subscribeToLocalAddresses()
Subscribe to local address changes.protected void
updateFromLocalAwareness(IComponentIdentifier platformid)
Updates the cache using the local awareness cache.
-
-
-
Field Detail
-
CACHE_VALIDITY_DUR
protected static final long CACHE_VALIDITY_DUR
Freshness limit for renewed searches.- See Also:
- Constant Field Values
-
CACHE_INVALIDITY_DUR
protected static final long CACHE_INVALIDITY_DUR
Freshness limit for previously failed renewed searches.- See Also:
- Constant Field Values
-
ASK_ALL_LIMIT
protected static final int ASK_ALL_LIMIT
Maximum number of peers to ask for addresses.- See Also:
- Constant Field Values
-
agent
protected IInternalAccess agent
Component access.
-
localaddresses
protected java.util.LinkedHashSet<TransportAddress> localaddresses
The local addresses.
-
searches
protected java.util.Map<IComponentIdentifier,IFuture<java.util.List<TransportAddress>>> searches
Current active searches.
-
freshness
protected java.util.Map<IComponentIdentifier,java.lang.Long> freshness
Freshness state of the cache.
-
addresses
protected java.util.Map<IComponentIdentifier,java.util.LinkedHashSet<TransportAddress>> addresses
The managed addresses: target platform -> (transport name -> transport addresses)
-
manualaddresses
protected java.util.Map<IComponentIdentifier,java.util.LinkedHashSet<TransportAddress>> manualaddresses
The managed addresses: target platform -> (transport name -> transport addresses)
-
addresssubs
protected java.util.LinkedHashSet<SubscriptionIntermediateFuture<Tuple2<TransportAddress,java.lang.Boolean>>> addresssubs
Subscription of local address changes.
-
superpeerlookup
protected boolean superpeerlookup
-
directlookup
protected boolean directlookup
-
pawalookup
protected boolean pawalookup
-
awalookup
protected boolean awalookup
-
askalllookup
protected boolean askalllookup
-
-
Method Detail
-
init
public IFuture<java.lang.Void> init()
Initializes the service.
-
getAddresses
public IFuture<java.util.List<TransportAddress>> getAddresses()
Gets the addresses of the local platform.- Specified by:
getAddresses
in interfaceITransportAddressService
- Returns:
- Addresses of the local platform.
-
getAddresses
public IFuture<java.util.List<TransportAddress>> getAddresses(java.lang.String transporttype)
Gets the addresses of the local platform.- Specified by:
getAddresses
in interfaceITransportAddressService
- Parameters:
transporttype
- The transport type.- Returns:
- Addresses of the local platform.
-
getAddresses
public IFuture<java.util.List<TransportAddress>> getAddresses(IComponentIdentifier platformid)
Gets the addresses of another platform known to the local platform.- Specified by:
getAddresses
in interfaceITransportAddressService
- Parameters:
platformid
- ID of the platform.- Returns:
- Addresses of the platform, if known.
-
getAddresses
public IFuture<java.util.List<TransportAddress>> getAddresses(IComponentIdentifier platformid, java.lang.String transporttype)
Gets the addresses of another platform known to the local platform.- Specified by:
getAddresses
in interfaceITransportAddressService
- Parameters:
platformid
- ID of the platform.transporttype
- The transport type.- Returns:
- Addresses of the platform, if known.
-
resolveAddresses
public IFuture<java.util.List<TransportAddress>> resolveAddresses(IComponentIdentifier platformid, java.lang.String transporttype)
Recursively looks up the addresses of a platform for a specific transport type.- Specified by:
resolveAddresses
in interfaceITransportAddressService
- Parameters:
platformid
- ID of the platform.transporttype
- The transport type.- Returns:
- Addresses of the local platform.
-
addLocalAddresses
public IFuture<java.lang.Void> addLocalAddresses(java.util.Collection<TransportAddress> addresses)
Adds the addresses of the local platform.- Specified by:
addLocalAddresses
in interfaceITransportAddressService
- Parameters:
addresses
- Local platform addresses.- Returns:
- Null, when done.
-
addManualAddresses
public IFuture<java.lang.Void> addManualAddresses(java.util.Collection<TransportAddress> addresses)
Adds user-specified addresses. Warning: Only use this to add manually specified addresses.- Specified by:
addManualAddresses
in interfaceITransportAddressService
- Parameters:
addresses
- Platform addresses.- Returns:
- Null, when done.
-
subscribeToLocalAddresses
public ISubscriptionIntermediateFuture<Tuple2<TransportAddress,java.lang.Boolean>> subscribeToLocalAddresses()
Subscribe to local address changes.- Specified by:
subscribeToLocalAddresses
in interfaceITransportAddressService
- Returns:
- Address and true if removed.
-
hasSuperPeer
protected boolean hasSuperPeer()
Checks if a super peer is available.- Returns:
- True, if super peer is available.
-
updateFromLocalAwareness
protected void updateFromLocalAwareness(IComponentIdentifier platformid)
Updates the cache using the local awareness cache.- Parameters:
platformid
- The platform ID.
-
searchAddressesByAskSuperPeer
protected java.util.List<TransportAddress> searchAddressesByAskSuperPeer(IComponentIdentifier platformid)
Searches for addresses using super peer.- Parameters:
platformid
- The platform ID.- Returns:
- The addresses.
-
searchAddressesByAskRemote
protected java.util.List<TransportAddress> searchAddressesByAskRemote(IComponentIdentifier platformid)
Searches for addresses directly asking remote platform.- Parameters:
platformid
- The platform ID.- Returns:
- The addresses.
-
searchAddressesByAskAwareness
protected java.util.List<TransportAddress> searchAddressesByAskAwareness(IComponentIdentifier platformid)
Searches for addresses using super peer.- Parameters:
platformid
- The platform ID.- Returns:
- The addresses.
-
searchAddressesByAskAll
protected java.util.List<TransportAddress> searchAddressesByAskAll(IComponentIdentifier platformid)
Randomly ask other platforms for addresses (search of last resort).- Parameters:
platformid
- The platform ID.- Returns:
- The addresses.
-
getAddressesFromCache
protected java.util.List<TransportAddress> getAddressesFromCache(IComponentIdentifier platformid)
Gets platform addresses from local cache.- Parameters:
platformid
- Platform ID.- Returns:
- Addresses.
-
addAddresses
protected void addAddresses(java.util.Collection<TransportAddress> addrs)
Adds addresses to cache.- Parameters:
addrs
- The addresses.
-
addToManualAddressesList
protected void addToManualAddressesList(java.util.Collection<TransportAddress> addrs)
Adds addresses to manual address list.- Parameters:
addrs
- The addresses.
-
addAddresses
protected void addAddresses(java.util.Collection<TransportAddress> addrs, java.util.Map<IComponentIdentifier,java.util.LinkedHashSet<TransportAddress>> addressmap)
Adds addresses to a map.- Parameters:
addrs
- The addresses.addressmap
- The map of address that is the target of the operation.
-
filterAddresses
protected java.util.List<TransportAddress> filterAddresses(java.util.List<TransportAddress> addresses, java.lang.String transporttype)
Filters addresses for transport types.- Parameters:
addresses
- The addresses to filter.transporttype
- The transport type.- Returns:
- Filtered list or null of none match.
-
-