Package jadex.platform.service.registry
Class AutoConfigRegistryAgent
- java.lang.Object
-
- jadex.platform.service.registry.AutoConfigRegistryAgent
-
- All Implemented Interfaces:
IAutoConfigRegistryService
public class AutoConfigRegistryAgent extends java.lang.Object implements IAutoConfigRegistryService
Agent that observes the environment and decides to a) make this platform to a SP registry (upgrade) b) make this platform from a SP registry to a normal client (downgrade)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AutoConfigRegistryAgent.Counting
Enum as result type for counting.class
AutoConfigRegistryAgent.ResultCountTracker
Helper class for tracking the results and deciding if too_less or many superpeers have been found.
-
Field Summary
Fields Modifier and Type Field Description protected IFuture<java.lang.Void>
activefut
protected IInternalAccess
agent
The agent.protected long
checkdelay
protected int
max_rep
Repeat search until action.protected int
max_sps
Maximum number of sps .protected int
min_sps
Minimum number of superpeers (sps) .
-
Constructor Summary
Constructors Constructor Description AutoConfigRegistryAgent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>
activate()
Activate the config service.void
body()
The agent body.Future<java.lang.Double>
computePower(IServiceIdentifier sid)
Compute how good a host is suited for being a superpeer.protected IFuture<java.lang.Number[]>
fetchPowerValues(IServiceIdentifier sid)
Fetch power values from a host.protected IFuture<java.util.Set<Tuple2<IAutoConfigRegistryService,java.lang.Double>>>
findPeers()
Find normal peers (to select one or more from them).protected IServiceRegistry
getRegistry()
Get the registry.protected IServiceIdentifier
getSid()
Get own service id for autoconfig service.protected boolean
isSuperpeer()
Test if this platform is superpeer.protected IFuture<java.lang.Void>
makeClient(IComponentIdentifier cid)
Make another platform to normal peer.IFuture<java.lang.Void>
makeRegistryClient()
Make this platform registry client.IFuture<java.lang.Void>
makeRegistrySuperpeer()
Make this platform registry superpeer.protected IFuture<java.lang.Void>
makeSuperpeer(IComponentIdentifier cid)
Make another platform to superpeer.protected void
searchAfterDelay(AutoConfigRegistryAgent.ResultCountTracker tracker)
Initiate a search after a delay.protected IFuture<java.util.Collection<IAutoConfigRegistryService>>
searchConfigurablePeers()
Search the configurable peers, i.e.protected IFuture<java.util.Collection<ISuperpeerService>>
searchConfigurableSuperpeers()
Search the configurable superpeers, i.e.protected IFuture<java.lang.Void>
searchForSuperpeers(AutoConfigRegistryAgent.ResultCountTracker tracker)
Search for superpeers.
-
-
-
Field Detail
-
agent
protected IInternalAccess agent
The agent.
-
checkdelay
protected long checkdelay
-
min_sps
protected int min_sps
Minimum number of superpeers (sps) .
-
max_sps
protected int max_sps
Maximum number of sps .
-
max_rep
protected int max_rep
Repeat search until action.
-
activefut
protected IFuture<java.lang.Void> activefut
-
-
Method Detail
-
body
public void body()
The agent body.
-
activate
public IFuture<java.lang.Void> activate()
Activate the config service.- Specified by:
activate
in interfaceIAutoConfigRegistryService
-
searchForSuperpeers
protected IFuture<java.lang.Void> searchForSuperpeers(AutoConfigRegistryAgent.ResultCountTracker tracker)
Search for superpeers.
-
searchAfterDelay
protected void searchAfterDelay(AutoConfigRegistryAgent.ResultCountTracker tracker)
Initiate a search after a delay.
-
findPeers
protected IFuture<java.util.Set<Tuple2<IAutoConfigRegistryService,java.lang.Double>>> findPeers()
Find normal peers (to select one or more from them).
-
getSid
protected IServiceIdentifier getSid()
Get own service id for autoconfig service.- Returns:
- The sid.
-
makeSuperpeer
protected IFuture<java.lang.Void> makeSuperpeer(IComponentIdentifier cid)
Make another platform to superpeer.- Parameters:
cid
- The platform id.
-
makeClient
protected IFuture<java.lang.Void> makeClient(IComponentIdentifier cid)
Make another platform to normal peer.- Parameters:
cid
- The platform id.
-
computePower
public Future<java.lang.Double> computePower(IServiceIdentifier sid)
Compute how good a host is suited for being a superpeer.- Parameters:
cid
- The platform id.- Returns:
- The power value.
-
fetchPowerValues
protected IFuture<java.lang.Number[]> fetchPowerValues(IServiceIdentifier sid)
Fetch power values from a host.
-
getRegistry
protected IServiceRegistry getRegistry()
Get the registry.- Returns:
- The registry.
-
makeRegistrySuperpeer
public IFuture<java.lang.Void> makeRegistrySuperpeer()
Make this platform registry superpeer.- Specified by:
makeRegistrySuperpeer
in interfaceIAutoConfigRegistryService
-
makeRegistryClient
public IFuture<java.lang.Void> makeRegistryClient()
Make this platform registry client.- Specified by:
makeRegistryClient
in interfaceIAutoConfigRegistryService
-
isSuperpeer
protected boolean isSuperpeer()
Test if this platform is superpeer.- Returns:
- True, if is superpeer.
-
searchConfigurableSuperpeers
protected IFuture<java.util.Collection<ISuperpeerService>> searchConfigurableSuperpeers()
Search the configurable superpeers, i.e. those that can be up/downgraded.
-
searchConfigurablePeers
protected IFuture<java.util.Collection<IAutoConfigRegistryService>> searchConfigurablePeers()
Search the configurable peers, i.e. those that can be up/downgraded.
-
-