当前位置: 首页>>代码示例>>Java>>正文


Java SupervisorStrategy.escalate方法代码示例

本文整理汇总了Java中akka.actor.SupervisorStrategy.escalate方法的典型用法代码示例。如果您正苦于以下问题:Java SupervisorStrategy.escalate方法的具体用法?Java SupervisorStrategy.escalate怎么用?Java SupervisorStrategy.escalate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在akka.actor.SupervisorStrategy的用法示例。


在下文中一共展示了SupervisorStrategy.escalate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: apply

import akka.actor.SupervisorStrategy; //导入方法依赖的package包/类
@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();
 }
}
 
开发者ID:awltech,项目名称:karajan,代码行数:13,代码来源:OrchestratorImpl.java

示例7: myDecider

import akka.actor.SupervisorStrategy; //导入方法依赖的package包/类
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();
			}
		}
	};
}
 
开发者ID:mrpantsuit,项目名称:javactor,代码行数:42,代码来源:JavactorUntypedActor.java

示例8: defaultStrategy

import akka.actor.SupervisorStrategy; //导入方法依赖的package包/类
public static final SupervisorStrategy defaultStrategy() {
final ExceptionElement exceptionElement=matchExceptionToErrorHadling();
Function<Throwable, Directive> behavior=new Function<Throwable, Directive>(){
	@Override
	public Directive apply(Throwable t) throws Exception {
		ProcessorException e=(ProcessorException)t;
		if ( exceptionElement.getStategy()==ErrorStrategy.ONE && exceptionElement.getAction()==Action.SKIP) {
			
		    stepexcmanager.tell(new MasterWorkerProtocol.WorkFailed(e.getWorkerId(), e.getWorkId()), ActorRef.noSender());
		   return SupervisorStrategy.resume();
	    }
		else if( exceptionElement.getStategy()==ErrorStrategy.ONE && exceptionElement.getAction()==Action.RETRY){
			
			if(currentrestrart < exceptionElement.getTrynumber()-1){
				executor.tell(new StepExecutionManager.Work(UUID.randomUUID().toString(),3), stepexcmanager);
				return SupervisorStrategy.restart();
			}else{
				stepexcmanager.tell(new MasterWorkerProtocol.WorkFailed(e.getWorkerId(), e.getWorkId()), ActorRef.noSender());
				return SupervisorStrategy.resume();
			}
	    }
		else if(exceptionElement.getStategy()==ErrorStrategy.ALL && exceptionElement.getAction()==Action.SKIP){
			 stepexcmanager.tell(new OrchestratorMasterProtocol.BatchFail(Action.SKIP), ActorRef.noSender());
			 return SupervisorStrategy.resume();
		}
		else if(exceptionElement.getStategy()==ErrorStrategy.ALL && exceptionElement.getAction()==Action.RETRY){
			 stepexcmanager.tell(new OrchestratorMasterProtocol.BatchFail(Action.RETRY), ActorRef.noSender());
		}
		return SupervisorStrategy.escalate();
	}
	
};

if(exceptionElement!=null){
	//AllForOneStrategy: The strategy is applied to all the children
	if(exceptionElement.getStategy()==ErrorStrategy.ALL){
		return new AllForOneStrategy(exceptionElement.getTrynumber(),Duration.create(5,TimeUnit.SECONDS),behavior);
	}
	//OneForOneStrategy: The strategy is applied to only the children that fail
	else if(exceptionElement.getStategy()==ErrorStrategy.ONE){
	return new OneForOneStrategy(exceptionElement.getTrynumber(), Duration.create(5,TimeUnit.SECONDS),behavior);
	}
}

// The Manager does not know how to handle this error
return SupervisorStrategy.defaultStrategy();
	
}
 
开发者ID:awltech,项目名称:karajan,代码行数:49,代码来源:CustomSupervisorStrategy.java


注:本文中的akka.actor.SupervisorStrategy.escalate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。