/** Add the stats to the reporter, print if completed, and stop the simulator. */ private void reportStats(PolicyStats stats) throws IOException { reporter.add(stats); if (--remaining == 0) { reporter.print(); context().stop(self()); System.out.println("Executed in " + stopwatch); } }
/** * Process a cluster update. * * @param context actor context */ public void processClusterUpdate(ActorContext context) { if (!clusterService.isMainEntityNode(key)) { LOG.debug("[{}] No longer a global endpoint node for {}", endpointKey); routes.clear(); context.stop(context.self()); } }
/** * Process cluster update. * * @param context the actor context */ public void processClusterUpdate(ActorContext context) { if (!eventService.isMainUserNode(userId)) { LOG.trace("No longer a global user node for user {}", userId); map.clear(); context.stop(context.self()); } }
@Override public Receive createReceive() { return receiveBuilder() .matchEquals(START, msg -> broadcast()) .matchEquals(ERROR, msg -> context().stop(self())) .match(PolicyStats.class, this::reportStats) .build(); }
} else if (message instanceof EndpointStopMessage) { LOG.debug("[{}] Received stop request from application actor", actorKey); context().stop(self()); } else { LOG.warn("[{}] Received unknown message {}", actorKey, message);
/** Broadcast the trace events to all of the policy actors. */ private void broadcast() { try (LongStream events = eventStream()) { LongArrayList batch = new LongArrayList(batchSize); for (PrimitiveIterator.OfLong i = events.iterator(); i.hasNext();) { batch.add(i.nextLong()); if (batch.size() == batchSize) { router.route(batch, self()); batch = new LongArrayList(batchSize); } } router.route(batch, self()); router.route(FINISH, self()); } catch (Exception e) { context().system().log().error(e, ""); context().stop(self()); } }
/** Add the stats to the reporter, print if completed, and stop the simulator. */ private void reportStats(PolicyStats stats) throws IOException { reporter.add(stats); if (--remaining == 0) { reporter.print(); context().stop(self()); System.out.println("Executed in " + stopwatch); } }
@Override public Receive createReceive() { return receiveBuilder() .matchEquals(START, msg -> broadcast()) .matchEquals(ERROR, msg -> context().stop(self())) .match(PolicyStats.class, this::reportStats) .build(); }
.match(Stop.class, msg -> context().stop(self())) .match(Object.class, this::unhandled)
@Override public void preStart() { if (expr instanceof Const) { Integer value = ((Const) expr).getValue(); context().parent().tell(new Result(expr, value, myPosition), self()); // Don't forget to stop the actor after it has nothing more to do context().stop(self()); } else { context().actorOf(FlakyExpressionCalculator.props(expr.getLeft(), Left), "left"); context().actorOf(FlakyExpressionCalculator.props(expr.getRight(), Right), "right"); } }
protected void onMediaGroupStateChanged(MediaGroupStateChanged message, ActorRef self, ActorRef sender) throws Exception { if(logger.isDebugEnabled()) logger.debug("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ onMediaGroupStateChanged - received STATE is: "+message.state()+" current fsm STATE is: "+fsm.state()+" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); switch (message.state()) { case ACTIVE: if (is(creatingMediaGroup)) { fsm.transition(message, preActive); } break; case INACTIVE: if (is(creatingMediaGroup)) { this.fail = Boolean.TRUE; fsm.transition(message, failed); } else if (is(stopping)) { // Stop media group actor this.mediaGroup.tell(new StopObserving(self), self); context().stop(mediaGroup); this.mediaGroup = null; // Move to next state this.fsm.transition(message, fail ? failed : inactive); } break; default: break; } }
/** Broadcast the trace events to all of the policy actors. */ private void broadcast() { try (LongStream events = eventStream()) { LongArrayList batch = new LongArrayList(batchSize); for (PrimitiveIterator.OfLong i = events.iterator(); i.hasNext();) { batch.add(i.nextLong()); if (batch.size() == batchSize) { router.route(batch, self()); batch = new LongArrayList(batchSize); } } router.route(batch, self()); router.route(FINISH, self()); } catch (Exception e) { context().system().log().error(e, ""); context().stop(self()); } }