use of actor4j.core.utils.ActorGroup in project actor4j-core by relvaner.
the class ActorBalancingOnCreationManual method balanceGroups.
public void balanceGroups(Map<UUID, Long> cellsMap, List<ActorThread> actorThreads, Map<UUID, Long> groupsMap, List<ActorGroup> groups) {
int i = 0;
for (ActorGroup group : groups) {
balanceGroup(cellsMap, groupsMap, actorThreads.get(i).getId(), group);
i++;
if (i == actorThreads.size())
i = 0;
}
}
use of actor4j.core.utils.ActorGroup in project actor4j-core by relvaner.
the class StatelessActorFeature method test.
@Test(timeout = 10000)
public void test() {
ActorSystem system = new ActorSystem();
system.setParallelismFactor(2);
CountDownLatch testDone = new CountDownLatch(system.getParallelismMin() * system.getParallelismFactor());
ActorGroup group = new ActorGroupSet();
system.setAlias(system.addActor(() -> new StatelessActor(group) {
protected boolean first = true;
@Override
public void receive(ActorMessage<?> message) {
logger().debug(String.format("from thread %s of actor %s%n", Thread.currentThread().getName(), self()));
if (first) {
testDone.countDown();
first = false;
}
}
}, system.getParallelismMin() * system.getParallelismFactor()), "instances");
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
system.sendViaAlias(new ActorMessage<Object>(null, 0, system.SYSTEM_ID, null), "instances");
}
}, 0, 50);
system.start();
try {
testDone.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
timer.cancel();
system.shutdownWithActors(true);
}
Aggregations