本文整理汇总了Java中akka.actor.Cancellable.cancel方法的典型用法代码示例。如果您正苦于以下问题:Java Cancellable.cancel方法的具体用法?Java Cancellable.cancel怎么用?Java Cancellable.cancel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类akka.actor.Cancellable
的用法示例。
在下文中一共展示了Cancellable.cancel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scheduleWeeklyReport
import akka.actor.Cancellable; //导入方法依赖的package包/类
private void scheduleWeeklyReport() {
FiniteDuration delay = FiniteDuration.create(secondsUntilNextMondayRun(), TimeUnit.SECONDS);
Cancellable reportTask = tasks.remove("REPORT_SENDER");
if (reportTask != null) {
reportTask.cancel();
}
tasks.put("REPORT_SENDER", system.scheduler().scheduleOnce(delay, () -> {
Logger.info("Running weekly email report");
List<User> teachers = Ebean.find(User.class)
.fetch("language")
.where()
.eq("roles.name", "TEACHER")
.findList();
teachers.forEach(t -> {
try {
composer.composeWeeklySummary(t);
} catch (RuntimeException e) {
Logger.error("Failed to send email for {}", t.getEmail());
}
});
// Reschedule
scheduleWeeklyReport();
}, system.dispatcher()));
}
示例2: onSelectOwner
import akka.actor.Cancellable; //导入方法依赖的package包/类
private void onSelectOwner(final SelectOwner selectOwner) {
LOG.debug("{}: onSelectOwner: {}", persistenceId(), selectOwner);
String currentOwner = getCurrentOwner(selectOwner.getEntityPath());
if (Strings.isNullOrEmpty(currentOwner)) {
writeNewOwner(selectOwner.getEntityPath(), newOwner(currentOwner, selectOwner.getAllCandidates(),
selectOwner.getOwnerSelectionStrategy()));
Cancellable cancellable = entityToScheduledOwnershipTask.get(selectOwner.getEntityPath());
if (cancellable != null) {
if (!cancellable.isCancelled()) {
cancellable.cancel();
}
entityToScheduledOwnershipTask.remove(selectOwner.getEntityPath());
}
}
}
示例3: terminated
import akka.actor.Cancellable; //导入方法依赖的package包/类
void terminated(ActorRef child) {
Cancellable scheduledTermination = scheduledTerminations.get(child);
if (scheduledTermination != null) {
// The child terminated in time, so we should cancel the scheduled termination.
scheduledTermination.cancel();
}
}
示例4: cancel
import akka.actor.Cancellable; //导入方法依赖的package包/类
public void cancel() {
log.info("***** START cancel JobsServiceImpl ****");
for (Cancellable scheduler : schedulers) {
if (scheduler != null) {
scheduler.cancel();
log.info("***** Scheduler was not null and is cancelled ****");
}
}
log.info("***** END cancel JobsServiceImpl ****");
}
示例5: cancelOwnerSelectionTask
import akka.actor.Cancellable; //导入方法依赖的package包/类
private void cancelOwnerSelectionTask(final YangInstanceIdentifier entityPath) {
final Cancellable lastScheduledTask = entityToScheduledOwnershipTask.get(entityPath);
if (lastScheduledTask != null && !lastScheduledTask.isCancelled()) {
lastScheduledTask.cancel();
}
}
示例6: run
import akka.actor.Cancellable; //导入方法依赖的package包/类
/** Run the Monitor. */
public final void run() {
systemMonitor = ActorSystem.create("MonitorSystem");
//creation de l'actor Action
action = systemMonitor.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return new Action(controllerSoftwareService,controllerVmService,controllerKubectlService,nameReplicationController);
}
}), "Actionneur");
//creation de l'actor Decide
decide = systemMonitor.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return new Decide(action,sh,eventNotificationAlertService);
}
}), "Decideur");
//creation l'actor Analyse
analyse = systemMonitor.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return new Analyse(decide,sh,eventNotificationAlertService);
}
}), "Analyseur");
//creation de l'actor Collect des traces de la version Japonais de Wikipedia
// collect = systemMonitor.actorOf(new Props(new UntypedActorFactory() {
// public UntypedActor create() {
// return new CollectTraceWikipedia(analyse,sh);
// }
// }), "Collect");
//creation de l'actor Collect en temps réel
collect = systemMonitor.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return new CollectRealTime(analyse,sh);
}
}), "Collect");
System.out.println("START");
//lecture du nombre de requettes tous les 30 secondes
Cancellable cancellable = systemMonitor.scheduler().schedule(Duration.Zero(),Duration.create(30, "seconds"),collect, new Interval(30));
try {
Thread.sleep(30000000);
} catch (InterruptedException e) {
System.out.println(e.getStackTrace());
return;
}
cancellable.cancel();
System.out.println("END");
}