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(); } } }); }
@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 boolean handleFailure(ActorContext context, ActorRef child, Throwable cause, ChildRestartStats stats, Iterable<ChildRestartStats> children) { String msg = String.format("RestcommSupervisorStrategy, actor exception handling. Actor path %s, exception cause %s, default exception handling strategy %s", child.path().toString(), cause, strategy.toString()); logger.error(msg); return super.handleFailure(context, child, cause, stats, children); }
@Override // - 3rd the Supervisor Strategy will execute processFailure() method. Useful for cleanup or logging public void processFailure(ActorContext context, boolean restart, ActorRef child, Throwable cause, ChildRestartStats stats, Iterable<ChildRestartStats> children) { String msg = String.format("RestcommSupervisor, actor exception handling. Restart %s, actor path %s, cause %s,", restart, child.path().toString(), cause); logger.error(msg); super.processFailure(context, restart, child, cause, stats, children); } }
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() { 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, 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(-1, Duration.Inf(), new Function<Throwable, Directive>() { @Override public Directive apply(Throwable t) { if (t instanceof ActorInitializationException || t instanceof DeathPactException) { return stop(); } else if (t instanceof Exception) { if (currentWorkId != null) { sendToMaster(new WorkFailed(workerId, workId())); } getContext().become(idle); return restart(); } else { return escalate(); } } }); }
@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(); } ); }
/** * set supervision strategy for worker actors and handle failed crawling actions * * @return */ @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); // save the failed status of a crawlingWorker during crawling if (t instanceof CrawlWrapperException) { CrawlWrapperException e = (CrawlWrapperException) t; log.warning("Handled breaking message: {}", e.getBreakingMessage()); log.warning("Exception was: {}", e.getException()); processCrawlUriMessage(e.getBreakingMessage()); return SupervisorStrategy.resume(); } // default behaviour in other cases return SupervisorStrategy.escalate(); } }); return supervisorStrategy; }
@Override public SupervisorStrategy create() { return new OneForOneStrategy(SupervisorStrategy.makeDecider(throwable -> { return SupervisorStrategy.escalate(); })); } }