}
getContext().system().scheduler().scheduleOnce(Duration.create(1, TimeUnit.SECONDS),
new Runnable() {
@Override
public void run() {
getSelf().tell(new collecterCheckResponse(), ActorRef.noSender());
}
}, getContext().system().dispatcher());
} else if (message instanceof collecterCheckResponse){
FiniteDuration duration = Duration.create(
10, TimeUnit.SECONDS);
Future<Object> futureList = Patterns.ask(monitor, new queryMonitorForResponse(), new Timeout(duration));
try {
List<ActorRef> collectList = (List<ActorRef>) Await.result(futureList, duration);
if (collectList.size() > 0) {
for (ActorRef m : collectList) {
slaveQ.offer(m);
atomic.incrementAndGet();
}
for (ActorRef m : individualCollectors) {
atomic.incrementAndGet();
m.tell("start", getSelf());
}
}
} catch (Exception e) {
System.out.println("Collector ask monitor timeout");
}
if (atomic.intValue() == 0 && jobInfo.state == State.finishedNotGathered) {
director.tell(collectedResponse, getSelf());
for (ActorRef ic : individualCollectors) {
getContext().stop(ic);
}
individualCollectors.clear();
} else {
getContext().system().scheduler().scheduleOnce(Duration.create(2, TimeUnit.SECONDS),
new Runnable() {
@Override
public void run() {
getSelf().tell(new collecterCheckResponse(), ActorRef.noSender());
}
}, getContext().system().dispatcher());
}
} else if (message instanceof BatchResponseFromManager) {
BatchResponseFromManager res = (BatchResponseFromManager) message;