@Override public Receive createReceive() { return receiveBuilder() .match(Integer.class, n -> { CompletableFuture<FactorialResult> result = CompletableFuture.supplyAsync(() -> factorial(n)) .thenApply((factorial) -> new FactorialResult(n, factorial)); pipe(result, getContext().dispatcher()).to(sender()); }) .build(); }
@Override public void preStart() { final Instant now = Instant.now(); final Duration initialDelay = calculateInitialDelay(now, firstIntervalHour); log.info("Initial deletion is scheduled at <{}>", now.plus(initialDelay)); scheduler = getContext().getSystem().scheduler() .schedule(initialDelay, runInterval, getSelf(), PERFORM_DELETION_MESSAGE, getContext().dispatcher(), getSelf()); }
private Cancellable scheduleReconnect() { final FiniteDuration initialDelay = FiniteDuration.apply(reconnectInitialDelay.toMillis(), TimeUnit.MILLISECONDS); final FiniteDuration interval = FiniteDuration.apply(reconnectInterval.toMillis(), TimeUnit.MILLISECONDS); final ReconnectMessages message = ReconnectMessages.START_RECONNECT; log.info("Scheduling reconnect for all connections with initial delay {} and interval {}.", reconnectInitialDelay, reconnectInterval); return getContext().getSystem() .scheduler() .schedule(initialDelay, interval, getSelf(), message, getContext().dispatcher(), ActorRef.noSender()); }
private void handleRetrieveStatisticsDetails(final RetrieveStatisticsDetails command) { log.info("Sending the namespace stats of the search-updater shard as requested.."); PatternsCS.pipe(retrieveStatisticsDetailsResponseSupplier .apply(command.getDittoHeaders()), getContext().dispatcher()).to(getSender()); }
private Cancellable scheduleActivityCheck(final StreamConsumerSettings streamConsumerSettings) { final FiniteDuration initialDelay = fromDuration(streamConsumerSettings.getOutdatedWarningOffset()); final FiniteDuration interval = fromDuration(streamConsumerSettings.getStreamInterval()); final CheckForActivity message = CheckForActivity.INSTANCE; return getContext().getSystem() .scheduler() .schedule(initialDelay, interval, getSelf(), message, getContext().dispatcher(), ActorRef.noSender()); }
@Override public void preStart() throws Exception { super.preStart(); final FiniteDuration delayAndInterval = FiniteDuration.create(getMaxIdleTime().getSeconds(), TimeUnit.SECONDS); activityCheck = getContext().system().scheduler() .schedule(delayAndInterval, delayAndInterval, getSelf(), CheckForActivity.INSTANCE, getContext().dispatcher(), ActorRef.noSender()); }
private Cancellable scheduleReconnect() { final FiniteDuration initialDelay = FiniteDuration.apply(reconnectInitialDelay.toMillis(), TimeUnit.MILLISECONDS); final FiniteDuration interval = FiniteDuration.apply(reconnectInterval.toMillis(), TimeUnit.MILLISECONDS); final ReconnectMessages message = ReconnectMessages.START_RECONNECT; log.info("Scheduling reconnect for all connections with initial delay {} and interval {}.", reconnectInitialDelay, reconnectInterval); return getContext().getSystem() .scheduler() .schedule(initialDelay, interval, getSelf(), message, getContext().dispatcher(), ActorRef.noSender()); }
private void schedulePendingResponse(final ConnectivityCommandResponse response, final ActorRef sender) { getContext().system().scheduler() .scheduleOnce(flushPendingResponsesTimeout, sender, response, getContext().dispatcher(), getSelf()); }
private void stopSelfIfDeletedAfterDelay() { final ExecutionContextExecutor dispatcher = getContext().dispatcher(); cancelStopSelfIfDeletedTrigger(); stopSelfIfDeletedTrigger = getContext().system() .scheduler() .scheduleOnce(DELETED_ACTOR_LIFETIME, getSelf(), STOP_SELF_IF_DELETED, dispatcher, ActorRef.noSender()); }
private void scheduleCheckForPolicyActivity(final long intervalInSeconds) { if (activityChecker != null) { activityChecker.cancel(); } // send a message to ourselves: activityChecker = getContext().system().scheduler() .scheduleOnce(Duration.apply(intervalInSeconds, TimeUnit.SECONDS), getSelf(), new CheckForActivity(lastSequenceNr(), accessCounter), getContext().dispatcher(), null); }
private void scheduleCheckForPolicyActivity(final long intervalInSeconds) { if (activityChecker != null) { activityChecker.cancel(); } // send a message to ourselves: activityChecker = getContext().system().scheduler() .scheduleOnce(Duration.apply(intervalInSeconds, TimeUnit.SECONDS), getSelf(), new CheckForActivity(lastSequenceNr(), accessCounter), getContext().dispatcher(), null); }
private void scheduleStream(final Duration duration) { log.info("Schedule Stream in: {}", duration); if (scheduledStreamStart != null) { scheduledStreamStart.cancel(); } final FiniteDuration finiteDuration = fromDuration(duration); scheduledStreamStart = getContext().system().scheduler() .scheduleOnce(finiteDuration, getSelf(), TryToStartStream.INSTANCE, getContext().dispatcher(), ActorRef.noSender()); }
private void scheduleSnapshot(final long intervalInSeconds) { // send a message to ourselft: snapshotter = getContext().system().scheduler() .scheduleOnce(Duration.apply(intervalInSeconds, TimeUnit.SECONDS), getSelf(), TakeSnapshotInternal.INSTANCE, getContext().dispatcher(), null); }
@Override public void doApply(final Terminated message) { log.info("Persistence actor for Thing with ID <{}> terminated abnormally.", thingId); child = null; final Duration restartDelay = calculateRestartDelay(); getContext().system() .scheduler() .scheduleOnce(new FiniteDuration(restartDelay.toNanos(), TimeUnit.NANOSECONDS), getSelf(), StartChild.INSTANCE, getContext().dispatcher(), null); restartCount += 1; }
private void handleRetrieveStatisticsDetails(final RetrieveStatisticsDetails command) { log.info("Sending the namespace stats of the search-updater shard as requested.."); PatternsCS.pipe(retrieveStatisticsDetailsResponseSupplier .apply(command.getDittoHeaders()), getContext().dispatcher()).to(getSender()); }
private void scheduleShutdown() { shutdownCancellable = getContext().getSystem().scheduler() .scheduleOnce(SHUTDOWN_DELAY, getSelf(), Shutdown.getInstance(), getContext().dispatcher(), ActorRef.noSender()); }
public StatsSampleClient(String servicePath) { this.servicePath = servicePath; FiniteDuration interval = Duration.create(2, TimeUnit.SECONDS); tickTask = getContext() .system() .scheduler() .schedule(interval, interval, self(), "tick", getContext().dispatcher(), null); }
@Override public void doApply(final Terminated message) { log.info("Persistence actor for Policy with ID '{}' terminated abnormally", policyId); child = null; final Duration restartDelay = calculateRestartDelay(); getContext().system().scheduler() .scheduleOnce(new FiniteDuration(restartDelay.toNanos(), TimeUnit.NANOSECONDS), getSelf(), new StartChild(), getContext().dispatcher(), null); restartCount += 1; } }
@Override public void doApply(final Terminated message) { log.info("Persistence actor for Policy with ID '{}' terminated abnormally", policyId); child = null; final Duration restartDelay = calculateRestartDelay(); getContext().system().scheduler() .scheduleOnce(new FiniteDuration(restartDelay.toNanos(), TimeUnit.NANOSECONDS), getSelf(), new StartChild(), getContext().dispatcher(), null); restartCount += 1; } }
@Override public void preStart() throws Exception { super.preStart(); final FiniteDuration delayAndInterval = FiniteDuration.create(getMaxIdleTime().getSeconds(), TimeUnit.SECONDS); activityCheck = getContext().system().scheduler() .schedule(delayAndInterval, delayAndInterval, getSelf(), CheckForActivity.INSTANCE, getContext().dispatcher(), ActorRef.noSender()); }