@Override public Directive apply(final Throwable t) { if (t instanceof DocumentTypeDataGenerationException) { return restart(); } else if (t instanceof DocumentGenerationException) { return restart(); } else if (t instanceof IndexDataException) { return restart(); } else if (t instanceof ActorInitializationException) { return stop(); } else if (t instanceof ActorKilledException) { return stop(); } else if (t instanceof Exception) { return restart(); } else { return escalate(); } }
@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(); } } ); }
@Override public Directive apply(Throwable t) throws Exception { if(t instanceof ActorInitializationException) { return OneForOneStrategy.stop(); } else if(t instanceof Exception) { return OneForOneStrategy.restart(); } return OneForOneStrategy.escalate(); }
private Function<Throwable, Directive> myDecider() { return new Function<Throwable, Directive>() { @Override public Directive apply(Throwable t) { if ( t instanceof ActorInitializationException || t instanceof ActorKilledException || t instanceof DeathPactException ) { return SupervisorStrategy.stop(); } else if ( t instanceof Exception ) { Class<? extends Throwable> clazz = t.getClass(); ImmutableSet<Entry<Class<?>, Method>> entrySet = javactorInfoByJavactorType .get(javactor.getClass()).getSupervisorStrategyInfo().getOnExceptionMethods() .entrySet(); for (Entry<Class<?>, Method> entry : entrySet) { if (entry.getKey().isAssignableFrom(clazz)) { final Method method = entry.getValue(); try { return map((SupervisorDirective) methodInvoke( method, javactor, t)); } catch (Exception e) { throw new RuntimeException(e); } } } return SupervisorStrategy.restart(); } else { return SupervisorStrategy.escalate(); } } }; }