@Override public void close() throws Exception { if (isLoaded()) { actorSystem.terminate(); Await.ready(actorSystem.whenTerminated(), Duration.Inf()); actorSystem = null; } }
@After public void shutDownActorSystem() { if (jobManagerSystem != null) { try { jobManagerSystem.terminate(); Await.ready(jobManagerSystem.whenTerminated(), Duration.Inf()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } } }
Await.ready(actorSystem.whenTerminated(), Duration.Inf()); } catch (InterruptedException | TimeoutException e) { LOG.error("Error shutting down actor system", e);
Await.ready(system.whenTerminated(), Duration.Inf());
@Override public boolean isTerminated() { return actorSystem.whenTerminated().isCompleted(); }
@Override public void run() { try { Await.ready(actorSystem.whenTerminated(), terminationTimeout); } catch (Exception e) { if (e instanceof TimeoutException) { log.error("Actor system shut down timed out.", e); } else { log.error("Failure during actor system shut down.", e); } } finally { log.info("Shutdown completed. Stopping JVM."); System.exit(0); } } }
@Override public void run() { try { Await.ready(actorSystem.whenTerminated(), terminationTimeout); } catch (Exception e) { if (e instanceof TimeoutException) { log.error("Actor system shut down timed out.", e); } else { log.error("Failure during actor system shut down.", e); } } finally { log.info("Shutdown completed. Stopping JVM."); System.exit(0); } } }
private void shutdownActorSystem(ActorSystem actorSystem) { // shut the actor system down actorSystem.terminate(); try { // give it some time to complete the shutdown Await.ready(actorSystem.whenTerminated(), timeout); } catch (InterruptedException | TimeoutException e) { log.error("Exception thrown when terminating the actor system", e); } finally { // now let's crash the JVM System.exit(exitCode); } } }
private void shutdownActorSystem(ActorSystem actorSystem) { // shut the actor system down actorSystem.terminate(); try { // give it some time to complete the shutdown Await.ready(actorSystem.whenTerminated(), timeout); } catch (InterruptedException | TimeoutException e) { log.error("Exception thrown when terminating the actor system", e); } finally { // now let's crash the JVM System.exit(exitCode); } } }
public static void main(String[] args) throws Exception { if (new ArgumentsValidator().validate(args)) { // If the arguments are valid then we can load spring application // context on here. final ApplicationContext context = new AnnotationConfigApplicationContext( M6ApplicationContext.class); // Use an akka system to be able to send messages in parallel // without doing the low level thread manipulation ourselves. final ActorSystem system = context.getBean(ActorSystem.class); final Future<Terminated> workDone = system.whenTerminated(); final ActorRef runCoordinator = system.actorOf(SPRING_EXT_PROVIDER.get(system) .props("RunCoordinatorActor"), "runCoordinator"); runCoordinator.tell(new StartTesting(), ActorRef.noSender()); do { LOGGER.info("Waiting for the process to finish"); Thread.sleep(60000L); } while (!workDone.isCompleted()); } }
@Override public void run(SourceFunction.SourceContext<Object> ctx) throws Exception { LOG.info("Starting the Receiver actor {}", actorName); receiverActor = receiverActorSystem.actorOf( Props.create(classForActor, ctx, urlOfPublisher, autoAck), actorName); LOG.info("Started the Receiver actor {} successfully", actorName); Await.result(receiverActorSystem.whenTerminated(), Duration.Inf()); }
@Override public void run() { try { while (running && (monitored == null || !monitored.whenTerminated().isCompleted())) { logger.info(getMemoryUsageStatsAsString(memoryBean)); logger.info(getDirectMemoryStatsAsString(directBufferBean)); logger.info(getMemoryPoolStatsAsString(poolBeans)); logger.info(getGarbageCollectorStatsAsString(gcBeans)); try { Thread.sleep(interval); } catch (InterruptedException e) { if (running) { throw e; } } } } catch (Throwable t) { logger.error("Memory logger terminated with exception", t); } }
@Override public void run() { try { while (running && (monitored == null || !monitored.whenTerminated().isCompleted())) { logger.info(getMemoryUsageStatsAsString(memoryBean)); logger.info(getDirectMemoryStatsAsString(directBufferBean)); logger.info(getMemoryPoolStatsAsString(poolBeans)); logger.info(getGarbageCollectorStatsAsString(gcBeans)); try { Thread.sleep(interval); } catch (InterruptedException e) { if (running) { throw e; } } } } catch (Throwable t) { logger.error("Memory logger terminated with exception", t); } }
@Override public void shutdown() { if (!shuttingDown) { shuttingDown = true; LOGGER.info("Going to shutdown EVENTS actor system"); Future<Terminated> terminate = eventsSystem.terminate(); terminate.onComplete(new OnComplete<Terminated>() { @Override public void onComplete(Throwable failure, Terminated result) { if (failure != null) { LOGGER.error("Error while shutting down EVENTS actor system", failure); } else { LOGGER.info("Done shutting down EVENTS actor system"); } } }, eventsSystem.dispatcher()); try { LOGGER.info("Waiting up to 30 seconds for EVENTS actor system to shutdown"); Await.result(eventsSystem.whenTerminated(), Duration.create(30, "seconds")); } catch (TimeoutException e) { LOGGER.warn("EVENTS Actor system shutdown wait timed out, continuing..."); } catch (Exception e) { LOGGER.error("Error while shutting down EVENTS actor system", e); } } }
@Override public void shutdown() { LOGGER.info("Going to shutdown JOBS actor system"); Future<Terminated> terminate = jobsSystem.terminate(); terminate.onComplete(new OnComplete<Terminated>() { @Override public void onComplete(Throwable failure, Terminated result) { if (failure != null) { LOGGER.error("Error while shutting down JOBS actor system", failure); } else { LOGGER.info("Done shutting down JOBS actor system"); } } }, jobsSystem.dispatcher()); try { LOGGER.info("Waiting up to 30 seconds for JOBS actor system to shutdown"); Await.result(jobsSystem.whenTerminated(), Duration.create(30, "seconds")); } catch (TimeoutException e) { LOGGER.warn("JOBS Actor system shutdown wait timed out, continuing..."); } catch (Exception e) { LOGGER.error("Error while shutting down JOBS actor system", e); } }
@Override public void close() throws Exception { if (isLoaded()) { actorSystem.terminate(); Await.ready(actorSystem.whenTerminated(), Duration.Inf()); actorSystem = null; } }
@AfterEach public void afterTest() throws Exception { feederActorSystem.terminate(); Await.result(feederActorSystem.whenTerminated(), Duration.Inf()); source.cancel(); sourceThread.join(); }
Await.ready(actorSystem.whenTerminated(), Duration.Inf()); } catch (InterruptedException | TimeoutException e) { LOG.error("Error shutting down actor system", e);
Await.ready(actorSystem.whenTerminated(), Duration.Inf()); } catch (InterruptedException | TimeoutException e) { LOG.error("Error shutting down actor system", e);
@Override public void run(String[] args) throws Exception { try { ActorRef workerActor = actorSystem.actorOf(springExtension.props("workerActor"), "worker-actor"); workerActor.tell(new WorkerActor.Request(), null); workerActor.tell(new WorkerActor.Request(), null); workerActor.tell(new WorkerActor.Request(), null); FiniteDuration duration = FiniteDuration.create(1, TimeUnit.SECONDS); Future<Object> awaitable = Patterns.ask(workerActor, new WorkerActor.Response(), Timeout.durationToTimeout(duration)); logger.info("Response: " + Await.result(awaitable, duration)); } finally { actorSystem.terminate(); Await.result(actorSystem.whenTerminated(), Duration.Inf()); } } }