本文整理汇总了Java中akka.actor.SupervisorStrategy类的典型用法代码示例。如果您正苦于以下问题:Java SupervisorStrategy类的具体用法?Java SupervisorStrategy怎么用?Java SupervisorStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SupervisorStrategy类属于akka.actor包,在下文中一共展示了SupervisorStrategy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(10, Duration.create(1, TimeUnit.MINUTES),
new Function<Throwable, SupervisorStrategy.Directive>() {
@Override
public SupervisorStrategy.Directive apply(Throwable param)
throws Exception {
if (param instanceof
IllegalArgumentException)
return SupervisorStrategy.restart();
if (param instanceof
ArithmeticException)
return SupervisorStrategy.resume();
if (param instanceof
NullPointerException)
return SupervisorStrategy.stop();
else return SupervisorStrategy.escalate();
}
}
);
}
开发者ID:dhinojosa,项目名称:intro_to_reactive,代码行数:22,代码来源:OneForOneGrandparentActor.java
示例2: buildResumeOnRuntimeErrorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
private static SupervisorStrategy buildResumeOnRuntimeErrorStrategy() {
return new OneForOneStrategy(-1, Duration.Inf(),
new Function<Throwable, SupervisorStrategy.Directive>() {
@Override
public Directive apply(Throwable throwable) throws Exception {
logException(throwable);
if (throwable instanceof Error) {
return OneForOneStrategy.escalate();
} else if (throwable instanceof RuntimeException) {
return OneForOneStrategy.resume();
} else {
return OneForOneStrategy.restart();
}
}
});
}
开发者ID:kaaproject,项目名称:kaa,代码行数:17,代码来源:SupervisionStrategyFactory.java
示例3: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(-1, Duration.Inf(),
t -> {
log.info("Throwable, Work is failed for1 "+ t);
if (t instanceof ActorInitializationException)
return stop();
else if (t instanceof DeathPactException)
return stop();
else if (t instanceof RuntimeException) {
if (currentJobId!=null) {
log.info("RuntimeException, Work is failed for "+ currentJobId);
sendToMaster(new MasterWorkerProtocol.WorkFailed(workerId, jobId(),new Result(-1,"","","",null)));
}
getContext().become(receiveBuilder()
.matchAny(p->idle.apply(p))
.build());
return restart();
}
else if (t instanceof Exception) {
if (currentJobId!=null) {
log.info("Exception, Work is failed for "+ currentJobId);
sendToMaster(new MasterWorkerProtocol.WorkFailed(workerId, jobId(),new Result(-1,"","","",null)));
}
getContext().become(receiveBuilder()
.matchAny(p->idle.apply(p))
.build());
return restart();
}
else {
log.info("Throwable, Work is failed for "+ t);
return escalate();
}
}
);
}
开发者ID:Abiy,项目名称:distGatling,代码行数:37,代码来源:Worker.java
示例4: create
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy create() {
return new OneForOneStrategy(
false,
new PFBuilder<Throwable, SupervisorStrategy.Directive>()
.match(
Exception.class,
(Exception e) -> {
if (e instanceof ActorKilledException) {
LOG.debug("Actor was killed. Stopping it now.", e);
} else {
LOG.error("Actor failed with exception. Stopping it now.", e);
}
return SupervisorStrategy.Stop$.MODULE$;
})
.build());
}
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:StoppingSupervisorWithoutLoggingActorKilledExceptionStrategy.java
示例5: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy()
{
SupervisorStrategyInfo info = javactorInfoByJavactorType
.get(javactor.getClass()).getSupervisorStrategyInfo().getInfo();
Duration withinDuration = toDuration(info.getTimeRange(), info.getTimeUnit());
final int maxNumRetries = info.getMaxNumRetries();
final boolean loggingEnabled = info.isLoggingEnabled();
return info.getType().equals(SupervisorStrategyType.ONE_FOR_ONE) ?
new OneForOneStrategy(maxNumRetries,
withinDuration,
myDecider(),
loggingEnabled
) :
new AllForOneStrategy(maxNumRetries,
withinDuration,
myDecider(),
loggingEnabled
);
}
开发者ID:mrpantsuit,项目名称:javactor,代码行数:21,代码来源:JavactorUntypedActor.java
示例6: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(10, Duration.create("1 minute"),
(Function<Throwable, Directive>) t -> {
LOG.warn("Supervisor Strategy caught unexpected exception - resuming", t);
return SupervisorStrategy.resume();
});
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:ShardManager.java
示例7: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(10, Duration.create("1 minute"), t -> {
LOG.error("An exception happened actor will be resumed", t);
return SupervisorStrategy.resume();
});
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:RpcManager.java
示例8: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(-1, Duration.Inf(), throwable -> {
logger.error(throwable, "Unknown session error");
if (throwable instanceof Error) {
return OneForOneStrategy.escalate();
} else {
return OneForOneStrategy.resume();
}
});
}
开发者ID:osswangxining,项目名称:iotplatform,代码行数:12,代码来源:SessionActor.java
示例9: apply
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public Directive apply(Throwable t) {
logger.error(t, "Unknown failure");
if (t instanceof RuntimeException) {
return SupervisorStrategy.restart();
} else {
return SupervisorStrategy.stop();
}
}
开发者ID:osswangxining,项目名称:iotplatform,代码行数:10,代码来源:AppActor.java
示例10: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new AllForOneStrategy(10, Duration.create(1, TimeUnit.HOURS),
new Function<Throwable, Directive>() {
@Override
public Directive apply(Throwable param) throws Exception {
if (param instanceof IllegalArgumentException) return escalate();
if (param instanceof ArithmeticException) return escalate();
if (param instanceof NullPointerException) return escalate();
else return stop();
}
}
);
}
开发者ID:dhinojosa,项目名称:intro_to_reactive,代码行数:15,代码来源:AllForOneParentActor.java
示例11: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new AllForOneStrategy(10, Duration.create(1, TimeUnit.HOURS),
new Function<Throwable, SupervisorStrategy.Directive>() {
@Override
public SupervisorStrategy.Directive apply(Throwable param) throws Exception {
if (param instanceof IllegalArgumentException) return escalate();
if (param instanceof ArithmeticException) return escalate();
if (param instanceof NullPointerException) return escalate();
else return stop();
}
}
);
}
开发者ID:dhinojosa,项目名称:intro_to_reactive,代码行数:15,代码来源:OneForOneParentActor.java
示例12: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new AllForOneStrategy(10, Duration.create(1, TimeUnit.HOURS),
new Function<Throwable, SupervisorStrategy.Directive>() {
@Override
public SupervisorStrategy.Directive apply(Throwable param) throws Exception {
if (param instanceof IllegalArgumentException) return SupervisorStrategy.stop();
if (param instanceof ArithmeticException) return SupervisorStrategy.resume();
if (param instanceof NullPointerException) return SupervisorStrategy.restart();
else return SupervisorStrategy.escalate();
}
}
);
}
开发者ID:dhinojosa,项目名称:intro_to_reactive,代码行数:15,代码来源:AllForOneGrandparentActor.java
示例13: supervisorDirective
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
/**
* Returns how to handle the given fault that occurred in a child actor.
*
* <p>If an exception occurs in the child actor, we send a {@link Status.Failure} message to this actor.
* Otherwise, if the {@link Throwable} is not an exception, the failure is escalated; that is, this actor will
* fail itself.
*
* <p>The strategy deactivates the Akka-provided logging, which logs all exception as errors by default. Instead,
* this strategy performs its own logging: If the {@link Throwable} is an {@link Exception}, the exception is logged
* at the debug level. Otherwise, the {@link Throwable} is logged at the error level.
*/
private SupervisorStrategy.Directive supervisorDirective(Throwable throwable) {
if (throwable instanceof Exception) {
InterpreterException exception = throwable instanceof InterpreterException
? (InterpreterException) throwable
: new InterpreterException(
ExecutionTrace.empty(),
String.format("Failure of root-module interpreter %s.", getSender()),
throwable
);
if (log.isDebugEnabled()) {
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
writer.println(
"Exception thrown in root-module interpreter and caught in top-level interpreter.");
throwable.printStackTrace(writer);
log.debug(stringWriter.toString());
}
getSelf().tell(new Status.Failure(exception), getSender());
return SupervisorStrategy.stop();
} else {
log.error(throwable, "Error in root-module interpreter. Escalating... The JVM may not survive.");
return SupervisorStrategy.escalate();
}
}
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:38,代码来源:TopLevelInterpreterActor.java
示例14: apply
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy.Directive apply(Throwable throwable) {
if (throwable instanceof Exception) {
return SupervisorStrategy.stop();
} else {
return SupervisorStrategy.escalate();
}
}
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:9,代码来源:MasterInterpreterActor.java
示例15: supervisorDirective
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
/**
* Returns how to handle the given fault that occurred in a child actor.
*/
private SupervisorStrategy.Directive supervisorDirective(Throwable throwable) {
if (throwable instanceof InterpreterException) {
return SupervisorStrategy.escalate();
} else if (throwable instanceof Exception) {
InterpreterException interpreterException = mapChildException((Exception) throwable);
getSelf().tell(new ChildActorFailed(interpreterException), getSelf());
return SupervisorStrategy.stop();
} else {
return SupervisorStrategy.escalate();
}
}
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:15,代码来源:AbstractModuleInterpreterActor.java
示例16: supervisorDirective
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
private SupervisorStrategy.Directive supervisorDirective(Throwable throwable) {
// We cannot just re-throw the exception here because it would be caught by the actor system (which would
// just restart the actor). We therefore schedule a deferred exception directly in the
// CallingThreadExecutor.
asyncTaskExecutor.execute(() -> { throw new UncaughtThrowableException(throwable); });
return SupervisorStrategy.stop();
}
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:8,代码来源:ModuleInterpretation.java
示例17: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(-1, Duration.Inf(),
throwable -> {
logger.error(throwable, "Unknown session error");
if (throwable instanceof Error) {
return OneForOneStrategy.escalate();
} else {
return OneForOneStrategy.resume();
}
});
}
开发者ID:thingsboard,项目名称:thingsboard,代码行数:13,代码来源:SessionActor.java
示例18: supervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(-1, Duration.create("1 minute"),
t -> {
log.error(t, "DroneActor failure caught by supervisor.");
System.err.println(t.getMessage());
return SupervisorStrategy.resume(); // Continue on all exceptions!
});
}
开发者ID:ugent-cros,项目名称:cros-core,代码行数:10,代码来源:DroneActor.java
示例19: getSupervisorStrategy
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
/**
* The supervisor strategy.
*
* @param notificationRetryNumber
* Number of retry when a delivery failed.
* @param notificationRetryDuration
* How long to wait before attempting to distribute the message
* again.
*/
private static SupervisorStrategy getSupervisorStrategy(int notificationRetryNumber, String notificationRetryDuration) {
return new OneForOneStrategy(notificationRetryNumber, Duration.create(notificationRetryDuration), new Function<Throwable, Directive>() {
@Override
public Directive apply(Throwable t) {
log.error("An notification processor reported an exception, retry", t);
return resume();
}
});
}
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:19,代码来源:DefaultNotificationManagerPlugin.java
示例20: createActors
import akka.actor.SupervisorStrategy; //导入依赖的package包/类
private void createActors(ActorSystem actorSystem) {
SupervisorStrategy strategy = getSupervisorStrategy(getNotificationRetryNumber(), getNotificationRetryDuration());
this.supervisorActor = actorSystem.actorOf((new RoundRobinPool(getPoolSize())).withSupervisorStrategy(strategy)
.props(Props.create(new NotificationMessageProcessingActorCreator(getConfiguration(), getPreferenceManagerPlugin(), getEmailService(),
this.getI18nMessagesPlugin()))),
SUPERVISOR_ACTOR_NAME);
log.info("Actor based notification system is started");
}
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:9,代码来源:DefaultNotificationManagerPlugin.java
注:本文中的akka.actor.SupervisorStrategy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论