akka.actor.Scheduler类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中akka.actor.Scheduler类的一些代码示例,展示了Scheduler类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler类的具体详情如下:
包路径:akka.actor.Scheduler
类名称:Scheduler

Scheduler介绍

暂无

代码示例

代码示例来源:origin: eBay/parallec

/**
 * 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;
}

代码示例来源:origin: apache/usergrid

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 ),

代码示例来源:origin: com.alibaba.blink/flink-runtime

@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());

代码示例来源:origin: jingweno/gaffer

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());
 }
}

代码示例来源:origin: keeps/roda

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());
}

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

@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());
  }
}

代码示例来源:origin: wxyyxc1992/Backend-Boilerplates

.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,

代码示例来源:origin: com.github.davidmoten/xuml-model-compiler-runtime

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,

代码示例来源:origin: org.eclipse.ditto/ditto-services-amqpbridge-messaging

private void scheduleShutdown() {
  shutdownCancellable = getContext().getSystem().scheduler()
      .scheduleOnce(SHUTDOWN_DELAY,
          getSelf(),
          Shutdown.getInstance(),
          getContext().dispatcher(),
          ActorRef.noSender());
}

代码示例来源:origin: eclipse/ditto

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());
}

代码示例来源:origin: ajmalbabu/distributed-computing

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());
  }
}

代码示例来源:origin: kaaproject/kaa

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());
}

代码示例来源:origin: com.alibaba.blink/flink-runtime

@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;
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

private Cancellable internalSchedule(Runnable runnable, long delay, TimeUnit unit) {
  return actorSystem.scheduler().scheduleOnce(
    new FiniteDuration(delay, unit),
    runnable,
    actorSystem.dispatcher());
}

代码示例来源:origin: org.opendaylight.controller/sal-akka-raft-example

private void scheduleRegistrationListener(FiniteDuration interval) {
  LOG.debug("--->scheduleRegistrationListener called.");
  registrationSchedule = getContext().system().scheduler().schedule(
    interval, interval, getSelf(), new RegisterListener(),
    getContext().system().dispatcher(), getSelf());
}

代码示例来源:origin: org.deeplearning4j/deeplearning4j-scaleout-akka

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() {

代码示例来源:origin: eclipse/ditto

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());
}

代码示例来源:origin: com.tomtom.speedtools/akka

/**
 * 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());
}

代码示例来源:origin: opendaylight/controller

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());
  }
}

代码示例来源:origin: srikalyc/Sql4D

/**
 * 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);
}

相关文章