Java 类akka.actor.SupervisorStrategy.Directive 实例源码

项目:visualakka    文件:VisualActor.java   
protected void initSupervisor(final String supervising,
        int nRetries, String maxDuration) {

    strategy = new OneForOneStrategy(nRetries == -1 ? Integer.MAX_VALUE : nRetries,
            ("-1".equals(maxDuration) ? Duration.Inf() : Duration.create(maxDuration)), new Function<Throwable, Directive>() {
                @Override
                public Directive apply(Throwable t) {
                    switch (supervising) {
                        case ESCALATE:
                            return escalate();
                        case RESTART:
                            return restart();
                        case RESUME:
                            return resume();
                        case STOP:
                            return stop();
                        default:
                            return escalate();
                    }
                }
            });
}
项目:searchanalytics-bigdata    文件:SetupDocumentTypeWorkerActor.java   
@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();
    }
}
项目:kaa    文件:SupervisionStrategyFactory.java   
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();
        }
      }
    });
}
项目:hashsdn-controller    文件:ShardManager.java   
@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();
            });
}
项目:iotplatform    文件:AppActor.java   
@Override
public Directive apply(Throwable t) {
  logger.error(t, "Unknown failure");
  if (t instanceof RuntimeException) {
    return SupervisorStrategy.restart();
  } else {
    return SupervisorStrategy.stop();
  }
}
项目:intro_to_reactive    文件:AllForOneParentActor.java   
@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();
          }
      }
   );
}
项目:thingsboard    文件:AppActor.java   
@Override
public Directive apply(Throwable t) {
    logger.error(t, "Unknown failure");
    if (t instanceof RuntimeException) {
        return SupervisorStrategy.restart();
    } else {
        return SupervisorStrategy.stop();
    }
}
项目:app-framework    文件:DefaultNotificationManagerPlugin.java   
/**
 * 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();
        }
    });
}
项目:app-framework    文件:PluginManagerServiceImpl.java   
/**
 * Creates a {@link OneForOneStrategy} using the specified parameters.
 * 
 * @param numberOfRetry
 *            a number of retry
 * @param withinTimeRange
 *            the time range
 * @param pluginConfigurationId
 *            the unique id of the plugin configuration
 */
private static SupervisorStrategy getSupervisorStrategy(int numberOfRetry, Duration withinTimeRange, Long pluginConfigurationId) {
    final String errorMessage = String.format("An provisioning processor of the plugin %d reported an exception, retry", pluginConfigurationId);
    return new OneForOneStrategy(numberOfRetry, withinTimeRange, new Function<Throwable, Directive>() {
        @Override
        public Directive apply(Throwable t) {
            log.error(errorMessage, t);
            return resume();
        }
    });
}
项目:elasticsearch-akka    文件:SetupDocumentTypeWorkerActor.java   
@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();
    }
}
项目:karajan    文件:OrchestratorImpl.java   
@Override
public Directive apply(Throwable t) {
 if (t instanceof ArithmeticException) {
    return SupervisorStrategy.resume() ; 
 } else if (t instanceof NullPointerException) {
    return SupervisorStrategy.stop();
 } else if (t instanceof IllegalArgumentException) {
    return SupervisorStrategy.stop();
 } else {
    return SupervisorStrategy.escalate();
 }
}
项目:kaa    文件:SupervisionStrategyFactory.java   
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();
        }
      }
    });
}
项目:kaa    文件:SupervisionStrategyFactory.java   
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();
        }
      }
    });
}
项目:geo-publisher    文件:Boot.java   
@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();
}
项目:trial    文件:SupervisorActor.java   
public Directive apply(Throwable t) {
    if (t instanceof ArithmeticException) {
        return resume();
    } else if (t instanceof NullPointerException) {
        return restart();
    } else if (t instanceof IllegalArgumentException) {
        return stop();
    } else {
        return escalate();
    }
}
项目:trial    文件:SupervisorActor.java   
public Directive apply(Throwable t) {
    if (t instanceof ArithmeticException) {
        return resume();
    } else if (t instanceof NullPointerException) {
        return restart();
    } else if (t instanceof IllegalArgumentException) {
        return stop();
    } else {
        return escalate();
    }
}
项目:trial    文件:SupervisorActor2.java   
public Directive apply(Throwable t) {
    if (t instanceof ArithmeticException) {
        return resume();
    } else if (t instanceof NullPointerException) {
        return restart();
    } else if (t instanceof IllegalArgumentException) {
        return stop();
    } else {
        return escalate();
    }
}
项目:trial    文件:TransferActor.java   
public Directive apply(Throwable t) {
    if (t instanceof CoordinatedTransactionException) {
        return resume();
    } else if (t instanceof IllegalStateException) {
        return resume();
    } else if (t instanceof IllegalArgumentException) {
        return stop();
    } else {
        return escalate();
    }
}
项目:trial    文件:BankActor.java   
public Directive apply(Throwable t) {
    if (t instanceof CoordinatedTransactionException) {
        return resume();
    } else if (t instanceof IllegalStateException) {
        return stop();
    } else if (t instanceof IllegalArgumentException) {
        return stop();
    } else {
        return escalate();
    }
}
项目:trial    文件:TransferActor.java   
public Directive apply(Throwable t) {
    if (t instanceof CoordinatedTransactionException) {
        return resume();
    } else if (t instanceof IllegalStateException) {
        return resume();
    } else if (t instanceof IllegalArgumentException) {
        return stop();
    } else {
        return escalate();
    }
}
项目:trial    文件:BankActor.java   
public Directive apply(Throwable t) {
    if (t instanceof CoordinatedTransactionException) {
        return resume();
    } else if (t instanceof IllegalStateException) {
        return stop();
    } else if (t instanceof IllegalArgumentException) {
        return stop();
    } else {
        return escalate();
    }
}
项目:trial    文件:SupervisorActor.java   
public Directive apply(Throwable t) {
    if (t instanceof ArithmeticException) {
        return resume();
    } else if (t instanceof IllegalArgumentException) {
        return restart();
    } else if (t instanceof NullPointerException) {
        return stop();
    } else {
        return escalate();
    }
}
项目:trial    文件:SupervisorActor.java   
public Directive apply(Throwable t) {
    if (t instanceof IllegalArgumentException) {
        return stop();
    } else if (t instanceof NullPointerException) {
        return resume();
    } else
        return escalate();
}
项目:twitter-analyst    文件:TweetSupervisor.java   
public Directive apply(Throwable t) {
    if (t instanceof Exception) {
        return stop();
    }
    return escalate();
}
项目:javactor    文件:JavactorUntypedActor.java   
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();
            }
        }
    };
}
项目:javactor    文件:JavactorUntypedActor.java   
private Directive map(SupervisorDirective supDirective)
{
    return JAVACTOR_DIRECTIVES_TO_AKKA.get(supDirective);
}
项目:geo-publisher    文件:MessageProtocolHandler.java   
@Override
public Directive apply(Throwable t) {
    return OneForOneStrategy.stop();
}
项目:geo-publisher    文件:JdbcDatabase.java   
@Override
public Directive apply(Throwable t) {
    return OneForOneStrategy.stop();
}
项目:geo-publisher    文件:ProvisioningSystem.java   
@Override
public Directive apply(Throwable t) throws Exception {          
    return AllForOneStrategy.restart();
}
项目:geo-publisher    文件:ProvisioningManager.java   
@Override
public Directive apply(Throwable t) throws Exception {          
    return AllForOneStrategy.escalate();
}
项目:geo-publisher    文件:InfoCollector.java   
@Override
public Directive apply(Throwable t) throws Exception {          
    return AllForOneStrategy.escalate();
}