private static SupervisorStrategy buildResumeOrEscalateStrategy() { 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 { return OneForOneStrategy.resume(); } } }); }
private static SupervisorStrategy buildRestartOrEscalateStrategy() { 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 { return OneForOneStrategy.restart(); } } }); }
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(); } } }); }
@Override public SupervisorStrategy supervisorStrategy() { return new OneForOneStrategy(0, Duration.Zero(), new Function<Throwable, Directive>() { public Directive apply(Throwable cause) { log.error("Problem with processing",cause); return SupervisorStrategy.resume(); } } ); }
@Override public SupervisorStrategy supervisorStrategy() { return new OneForOneStrategy(10, Duration.create("1 minute"), new Function<Throwable, SupervisorStrategy.Directive>() { @Override public SupervisorStrategy.Directive apply(final Throwable t) { LOG.error("An exception happened actor will be resumed", t); return SupervisorStrategy.resume(); } } ); } }
@Override public SupervisorStrategy supervisorStrategy() { SupervisorStrategy supervisorStrategy = new OneForOneStrategy( 0, Duration.Zero(), new Function<Throwable, SupervisorStrategy.Directive>() { @Override public SupervisorStrategy.Directive apply(Throwable t) throws Exception { log.warning("Actor encountered error: {}", t); // default behaviour return SupervisorStrategy.escalate(); } }); return supervisorStrategy; }
@Override public SupervisorStrategy supervisorStrategy() { SupervisorStrategy supervisorStrategy = new OneForOneStrategy( 0, Duration.Zero(), new Function<Throwable, SupervisorStrategy.Directive>() { @Override public SupervisorStrategy.Directive apply(Throwable t) throws Exception { log.warning("Actor encountered error: {}", t); // default behaviour return SupervisorStrategy.escalate(); } }); return supervisorStrategy; }
@Override public SupervisorStrategy supervisorStrategy() { SupervisorStrategy supervisorStrategy = new OneForOneStrategy( 0, Duration.Zero(), new Function<Throwable, SupervisorStrategy.Directive>() { @Override public SupervisorStrategy.Directive apply(Throwable t) throws Exception { log.warning("Actor encountered error: {}", t); // default behaviour return SupervisorStrategy.escalate(); } }); return supervisorStrategy; }
@Override public SupervisorStrategy supervisorStrategy() { SupervisorStrategy supervisorStrategy = new OneForOneStrategy( 0, Duration.Zero(), new Function<Throwable, SupervisorStrategy.Directive>() { @Override public SupervisorStrategy.Directive apply(Throwable t) throws Exception { log.warning("Actor encountered error: {}", t); // default behaviour return SupervisorStrategy.escalate(); } }); return supervisorStrategy; } }
@Override public SupervisorStrategy supervisorStrategy() { return new OneForOneStrategy(10, FiniteDuration.create(1, TimeUnit.MINUTES), t -> { LOG.error("An exception happened actor will be resumed", t); return SupervisorStrategy.resume(); }); } }
@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(); } ); }
@Override public SupervisorStrategy create() { return new OneForOneStrategy(SupervisorStrategy.makeDecider(throwable -> { return SupervisorStrategy.escalate(); })); } }
@Override public SupervisorStrategy create() { return new OneForOneStrategy(SupervisorStrategy.makeDecider(throwable -> { return SupervisorStrategy.escalate(); })); } }
@Override public SupervisorStrategy supervisorStrategy() { return new OneForOneStrategy(0, Duration.Zero(), new Function<Throwable, Directive>() { public Directive apply(Throwable cause) { log.error("Problem with processing",cause); mediator.tell(new DistributedPubSubMediator.Publish(MasterActor.MASTER, new ClearWorker(id)), getSelf()); return SupervisorStrategy.restart(); } } ); }
@Override public PolicySupervisorActor create() throws Exception { return new PolicySupervisorActor(pubSubMediator, minBackoff, maxBackoff, randomFactor, new OneForOneStrategy(true, DeciderBuilder .match(NullPointerException.class, e -> SupervisorStrategy.restart()) .match(ActorKilledException.class, e -> SupervisorStrategy.stop()) .matchAny(e -> SupervisorStrategy.escalate()) .build()), snapshotAdapter); } });
@Override public PolicySupervisorActor create() throws Exception { return new PolicySupervisorActor(pubSubMediator, minBackoff, maxBackoff, randomFactor, new OneForOneStrategy(true, DeciderBuilder .match(NullPointerException.class, e -> SupervisorStrategy.restart()) .match(ActorKilledException.class, e -> SupervisorStrategy.stop()) .matchAny(e -> SupervisorStrategy.escalate()) .build()), snapshotAdapter); } });
@Override public SupervisorStrategy supervisorStrategy() { return new OneForOneStrategy(true, DeciderBuilder .match(NullPointerException.class, e -> SupervisorStrategy.restart()) .match(ActorKilledException.class, e -> SupervisorStrategy.stop()) .matchAny(e -> SupervisorStrategy.escalate()) .build()); }
@Override public ConnectionSupervisorActor create() { return new ConnectionSupervisorActor(new OneForOneStrategy(true, DeciderBuilder .match(JMSRuntimeException.class, e -> SupervisorStrategy.resume()) .match(NullPointerException.class, e -> SupervisorStrategy.restart()) .match(JMSException.class, e -> SupervisorStrategy.stop()) .match(NamingException.class, e -> SupervisorStrategy.stop()) .match(ActorKilledException.class, e -> SupervisorStrategy.stop()) .matchAny(e -> SupervisorStrategy.escalate()) .build()), minBackoff, maxBackoff, randomFactor, pubSubMediator, pubSubTargetActorPath, jmsConnectionFactory); } });
@Override public ThingSupervisorActor create() { final OneForOneStrategy oneForOneStrategy = new OneForOneStrategy(true, DeciderBuilder .match(NullPointerException.class, e -> SupervisorStrategy.restart()) .match(ActorKilledException.class, e -> SupervisorStrategy.stop()) .matchAny(e -> SupervisorStrategy.escalate()) .build()); return new ThingSupervisorActor(minBackOff, maxBackOff, randomFactor, thingPersistenceActorPropsFactory, oneForOneStrategy); } });
@Override public ThingSupervisorActor create() { final OneForOneStrategy oneForOneStrategy = new OneForOneStrategy(true, DeciderBuilder .match(NullPointerException.class, e -> SupervisorStrategy.restart()) .match(ActorKilledException.class, e -> SupervisorStrategy.stop()) .matchAny(e -> SupervisorStrategy.escalate()) .build()); return new ThingSupervisorActor(minBackOff, maxBackOff, randomFactor, thingPersistenceActorPropsFactory, oneForOneStrategy, pubSubMediator); } });