Modifier and Type | Field and Description |
---|---|
private DistributionUtilities |
distributionUtilities |
private java.util.List<Workplace<Agent>> |
localWorkplaces |
private static org.slf4j.Logger |
logger |
private LoggingService |
loggingService |
private UnicastMessenger |
messenger |
private IMap<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> |
statistics |
private StopCondition |
stopCondition |
private ThreadPool |
threadPool |
private TopologyProvider<java.lang.Long> |
topologyProvider |
private IdGenerator |
workplaceIdGenerator |
private IMap<java.lang.Long,WorkerAddress> |
workplacesLocations |
Constructor and Description |
---|
StreamAgents(Configuration configuration,
ThreadPool threadPool,
DistributionUtilities distributionUtilities,
UnicastMessenger messenger,
TopologyProvider<?> topologyProvider) |
Modifier and Type | Method and Description |
---|---|
private static void |
cancelWorkplaceFuture(ListenableFuture<?> f) |
io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> |
getLocalStatistics()
Returns a read-only view of local statistics map of a current node.
|
io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Set<java.lang.String>> |
getNeighboursOf(long workplaceId)
Returns a read-only view of global statistics map filtered only for neighbours of the given workplace.
|
io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> |
getNeighboursStatistics(long workplaceId)
Returns a read-only view of global statistics map filtered only for neighbours of the given workplace.
|
io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> |
getStatistics()
Returns a read-only view of global statistics map of all available nodes.
|
int |
getTotalWorkplacesCount()
Returns the number of all workplaces that participate in computations.
|
boolean |
isStopConditionReached() |
void |
migrate(Agent agent,
long sourceWorkplace,
long targetWorkplace)
Migrates an agent to a workplace with the given ID in neighbourhood.
|
void |
migrate(Agent agent,
long sourceWorkplace,
java.lang.String neighbourAnnotation)
Migrates an agent to a workplace with the given annotation in neighbourhood.
|
void |
migrateUnconditionally(Agent agent,
long sourceWorkplace,
long targetWorkplace)
Migrates an agent to a workplace with the given ID.
|
private void |
performMigration(Agent agent,
long targetWorkplace)
Performs actual migration without any verification of arguments
|
void |
postStatistics(long id,
io.vavr.collection.Map<java.lang.Object,java.lang.Object> workplaceStatistics)
Posts provided statistics globally, mapping them to the workplace ID.
|
void |
run() |
java.lang.String |
toString() |
private static void |
waitFor(StopCondition stopCondition) |
private static final org.slf4j.Logger logger
private final ThreadPool threadPool
private final DistributionUtilities distributionUtilities
private final IdGenerator workplaceIdGenerator
private final UnicastMessenger messenger
private final IMap<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> statistics
private final IMap<java.lang.Long,WorkerAddress> workplacesLocations
private final StopCondition stopCondition
private final LoggingService loggingService
private final TopologyProvider<java.lang.Long> topologyProvider
@Inject public StreamAgents(Configuration configuration, ThreadPool threadPool, DistributionUtilities distributionUtilities, UnicastMessenger messenger, TopologyProvider<?> topologyProvider)
public void run()
run
in interface java.lang.Runnable
private static void cancelWorkplaceFuture(ListenableFuture<?> f)
private static void waitFor(StopCondition stopCondition) throws java.lang.InterruptedException
java.lang.InterruptedException
public void postStatistics(long id, io.vavr.collection.Map<java.lang.Object,java.lang.Object> workplaceStatistics)
Manager
Posts provided statistics globally, mapping them to the workplace ID.
postStatistics
in interface Manager
id
- workplace idworkplaceStatistics
- statistics as a mappublic int getTotalWorkplacesCount()
Manager
Returns the number of all workplaces that participate in computations.
getTotalWorkplacesCount
in interface Manager
public io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> getStatistics()
Manager
Returns a read-only view of global statistics map of all available nodes.
getStatistics
in interface Manager
public io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> getLocalStatistics()
Manager
Returns a read-only view of local statistics map of a current node.
getLocalStatistics
in interface Manager
public io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> getNeighboursStatistics(long workplaceId)
Manager
Returns a read-only view of global statistics map filtered only for neighbours of the given workplace.
getNeighboursStatistics
in interface Manager
public io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Set<java.lang.String>> getNeighboursOf(long workplaceId)
Manager
Returns a read-only view of global statistics map filtered only for neighbours of the given workplace.
getNeighboursOf
in interface Manager
public void migrate(Agent agent, long sourceWorkplace, long targetWorkplace)
Manager
Migrates an agent to a workplace with the given ID in neighbourhood.
This method always use the current topology.
public void migrate(Agent agent, long sourceWorkplace, java.lang.String neighbourAnnotation)
Manager
Migrates an agent to a workplace with the given annotation in neighbourhood.
This method always use the current topology.
public void migrateUnconditionally(Agent agent, long sourceWorkplace, long targetWorkplace)
Manager
Migrates an agent to a workplace with the given ID.
This method makes it possible to bypass a current topology.
migrateUnconditionally
in interface Manager
public boolean isStopConditionReached()
isStopConditionReached
in interface Manager
public java.lang.String toString()
toString
in class java.lang.Object
private void performMigration(Agent agent, long targetWorkplace)
Performs actual migration without any verification of arguments