-
-
Save kcleereman/d729d47d80262961f1a6 to your computer and use it in GitHub Desktop.
JobManager cleanup and the callback that invokes it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JobManagerImpl implements JobManager { | |
private final JobManager self = TypedActor.<JobManager>self(); | |
private final Promise<String> completion; | |
public JobManager(Promise<String> completion) { | |
this.completion = completion; | |
completion.future().onComplete(new OnComplete<String>() { | |
@Override | |
public void onComplete(Throwable arg0, String arg1) { | |
self.cleanup(); | |
} | |
}, TypedActor.dispatcher()); | |
} | |
public void cleanup() { | |
if(completion.isCompleted()) { | |
immutable.batchManager().nextBatch(); | |
jobQueue.clear(); | |
for(ActorRef child : JavaConversions.asJavaIterable(TypedActor.context().children())) { | |
TypedActor.context().stop(child); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment