Refine search
/** * Wait and retry. */ public void waitAndRetry() { ContinueToSendToBatchSenderAsstManager continueToSendToBatchSenderAsstManager = new ContinueToSendToBatchSenderAsstManager( processedWorkerCount); logger.debug("NOW WAIT Another " + asstManagerRetryIntervalMillis + " MS. at " + PcDateUtils.getNowDateTimeStrStandard()); getContext() .system() .scheduler() .scheduleOnce( Duration.create(asstManagerRetryIntervalMillis, TimeUnit.MILLISECONDS), getSelf(), continueToSendToBatchSenderAsstManager, getContext().system().dispatcher(), getSelf()); return; }
Cancellable scheduler = getContext().system().scheduler().schedule( Duration.create( 0, TimeUnit.MILLISECONDS ), Duration.create( qakkaFig.getQueueRefreshMilliseconds(), TimeUnit.MILLISECONDS ), self(), new QueueRefreshRequest( queueName, false ), getContext().dispatcher(), getSelf() ); refreshSchedulersByQueueName.put( queueName, scheduler ); Cancellable scheduler = getContext().system().scheduler().schedule( Duration.create( 0, TimeUnit.SECONDS ), Duration.create( qakkaFig.getQueueTimeoutSeconds() / 2, TimeUnit.SECONDS ), Cancellable scheduler = getContext().system().scheduler().schedule( Duration.create( 0, TimeUnit.MILLISECONDS ), Duration.create( qakkaFig.getShardAllocationCheckFrequencyMillis(), TimeUnit.MILLISECONDS ),
@Override public Object call() throws Exception { LOG.info("Attaching to job {} at the job manager {}.", jobID, jobManager.path()); jobManager.tell( decorateMessage( new JobManagerMessages.RegisterJobClient( jobID, ListeningBehaviour.EXECUTION_RESULT_AND_STATE_CHANGES)), getSelf()); // issue a RegistrationTimeout message to check that we submit the job within // the given timeout getContext().system().scheduler().scheduleOnce( timeout, getSelf(), decorateMessage(JobClientMessages.getRegistrationTimeout()), getContext().dispatcher(), ActorRef.noSender()); return null; } }, getContext().dispatcher());
private void scheduleKillAll() { final Runnable killAll = new Runnable() { @Override public void run() { router.route(PoisonPill.getInstance(), getSelf()); } }; getContext() .system() .scheduler() .scheduleOnce(Duration.create(SHUTDOWN_GRACE_TIME, TimeUnit.MILLISECONDS), killAll, getContext().dispatcher()); } }
public Worker(ActorRef clusterClient, Props workExecutorProps, FiniteDuration registerInterval) { this.clusterClient = clusterClient; this.workExecutor = getContext().watch(getContext().actorOf(workExecutorProps, "exec")); this.registerTask = getContext().system().scheduler().schedule(Duration.Zero(), registerInterval, clusterClient, new SendToAll("/user/master/singleton", new RegisterWorker(workerId)), getContext().dispatcher(), getSelf()); }
@Override protected void onRecoveryComplete() { restoreFromSnapshot = null; //notify shard manager getContext().parent().tell(new ActorInitialized(), getSelf()); // Being paranoid here - this method should only be called once but just in case... if (txCommitTimeoutCheckSchedule == null) { // Schedule a message to be periodically sent to check if the current in-progress // transaction should be expired and aborted. FiniteDuration period = Duration.create(transactionCommitTimeout / 3, TimeUnit.MILLISECONDS); txCommitTimeoutCheckSchedule = getContext().system().scheduler().schedule( period, period, getSelf(), TX_COMMIT_TIMEOUT_CHECK_MESSAGE, getContext().dispatcher(), ActorRef.noSender()); } }
.withFallback(ConfigFactory.load()); ActorSystem system = ActorSystem.create("ClusterSystem", config); final ActorRef frontend = system.actorOf( Props.create(TransformationFrontend.class), "frontend"); final FiniteDuration interval = Duration.create(2, TimeUnit.SECONDS); final Timeout timeout = new Timeout(Duration.create(5, TimeUnit.SECONDS)); final ExecutionContext ec = system.dispatcher(); final AtomicInteger counter = new AtomicInteger(); system.scheduler().schedule(interval, interval, new Runnable() { public void run() { ask(frontend,
long delayMs = (signal.getTime() == null ? now : signal.getTime()) - now; if (delayMs <= 0) root.tell(signal, root); else { ExecutionContext executionContext = actorSystem.dispatcher(); if (!signal.getRepeatInterval().isPresent()) cancellable = actorSystem.scheduler().scheduleOnce( Duration.create(delayMs, TimeUnit.MILLISECONDS), root, signal, executionContext, root); else cancellable = actorSystem.scheduler().schedule( Duration.create(delayMs, TimeUnit.MILLISECONDS), signal.getRepeatInterval().get(), root, signal, executionContext,
private void scheduleShutdown() { shutdownCancellable = getContext().getSystem().scheduler() .scheduleOnce(SHUTDOWN_DELAY, getSelf(), Shutdown.getInstance(), 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()); }
public void schedule(UntypedActorContext context) { if (repeatedTriggerTime <= 0) { LOGGER.info("Scheduling once {}", toString()); context.system().scheduler().scheduleOnce( startTime(), context.self(), getScheduledMessage(), context.dispatcher(), ActorRef.noSender()); } else { LOGGER.info("Scheduling repeated {}", toString()); context.system().scheduler().schedule( startTime(), Duration.create(getRepeatedTriggerTime(), getTriggerTimeUnit()), context.self(), getScheduledMessage(), context.dispatcher(), ActorRef.noSender()); } }
private void scheduleTimeoutMessage(ActorContext context, TimeoutMessage message, long delay) { context.system() .scheduler() .scheduleOnce( Duration.create(delay, TimeUnit.MILLISECONDS), context.self(), message, context.dispatcher(), context.self()); }
@Override @Nonnull public ScheduledFuture<?> scheduleAtFixedRate(@Nonnull Runnable command, long initialDelay, long period, @Nonnull TimeUnit unit) { ScheduledFutureTask<Void> scheduledFutureTask = new ScheduledFutureTask<>( command, triggerTime(unit.toNanos(initialDelay)), unit.toNanos(period)); Cancellable cancellable = actorSystem.scheduler().schedule( new FiniteDuration(initialDelay, unit), new FiniteDuration(period, unit), scheduledFutureTask, actorSystem.dispatcher()); scheduledFutureTask.setCancellable(cancellable); return scheduledFutureTask; }
private Cancellable internalSchedule(Runnable runnable, long delay, TimeUnit unit) { return actorSystem.scheduler().scheduleOnce( new FiniteDuration(delay, unit), runnable, actorSystem.dispatcher()); }
private void scheduleRegistrationListener(FiniteDuration interval) { LOG.debug("--->scheduleRegistrationListener called."); registrationSchedule = getContext().system().scheduler().schedule( interval, interval, getSelf(), new RegisterListener(), getContext().system().dispatcher(), getSelf()); }
mediator.tell(new DistributedPubSubMediator.Subscribe(MasterActor.MASTER, getSelf()), getSelf()); mediator.tell(new DistributedPubSubMediator.Subscribe(MasterActor.FINISH, getSelf()), getSelf()); forceNextPhase = context().system().scheduler() .schedule(Duration.create(secondsPoll, TimeUnit.SECONDS), Duration.create(secondsPoll,TimeUnit.SECONDS), new Runnable() { this.clearStateWorkers = context().system().scheduler() .schedule(Duration.create(1,TimeUnit.MINUTES), Duration.create(1,TimeUnit.MINUTES), new Runnable() {
private void scheduleInternalRetrieveHotEntities() { initHotMetrics(); getContext().getSystem() .scheduler() .schedule(FiniteDuration.apply(WAIT_TIME_MS, TimeUnit.MILLISECONDS), FiniteDuration.apply(SCHEDULE_INTERNAL_RETRIEVE_COMMAND, TimeUnit.MILLISECONDS), getSelf(), InternalRetrieveStatistics.newInstance(), getContext().getSystem().dispatcher(), ActorRef.noSender()); }
/** * Schedules the runnable to be run at a given interval. There is an initial delay before the first time. Note that * the runnable is NOT run in the context of the actor. Always use {@link #self()} to interact with the actor! * * @param initialDelay Initial delay to wait. * @param interval Amount of time to wait before runnable is called. * @param runnable Code to run. * @return A Cancellable object for the runnable. */ @Nonnull public Cancellable schedule(@Nonnull final FiniteDuration initialDelay, @Nonnull final FiniteDuration interval, @Nonnull final Runnable runnable) { assert initialDelay != null; assert interval != null; assert runnable != null; return system.scheduler().schedule(initialDelay, interval, runnable, executionContext()); }
public <T extends BackendInfo> Cancellable executeInActor(@Nonnull final InternalCommand<T> command, final FiniteDuration delay) { return scheduler.scheduleOnce(Preconditions.checkNotNull(delay), self(), Preconditions.checkNotNull(command), executionContext, ActorRef.noSender()); } }
/** * Schedules messages ever interval seconds. * @param initialDelay * @param interval * @param message * @return */ private Cancellable scheduleCron(int initialDelay, int interval, MessageTypes message) { return scheduler.schedule(secs(initialDelay), secs(interval), getSelf(), message, getContext().dispatcher(), null); }