• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OneForOneStrategy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



OneForOneStrategy类属于akka.actor包,在下文中一共展示了OneForOneStrategy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: supervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的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: buildResumeOnRuntimeErrorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
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();
        }
      }
    });
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:17,代码来源:SupervisionStrategyFactory.java


示例3: supervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@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();
                }
            }
    );
}
 
开发者ID:Abiy,项目名称:distGatling,代码行数:37,代码来源:Worker.java


示例4: create

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy create() {
	return new OneForOneStrategy(
		false,
		new PFBuilder<Throwable, SupervisorStrategy.Directive>()
			.match(
				Exception.class,
				(Exception e) -> {
					if (e instanceof ActorKilledException) {
						LOG.debug("Actor was killed. Stopping it now.", e);
					} else {
						LOG.error("Actor failed with exception. Stopping it now.", e);
					}
					return SupervisorStrategy.Stop$.MODULE$;
				})
			.build());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:StoppingSupervisorWithoutLoggingActorKilledExceptionStrategy.java


示例5: initSupervisor

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
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();
                    }
                }
            });
}
 
开发者ID:vlarin,项目名称:visualakka,代码行数:23,代码来源:VisualActor.java


示例6: supervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy()
{
	SupervisorStrategyInfo info = javactorInfoByJavactorType
		.get(javactor.getClass()).getSupervisorStrategyInfo().getInfo();
	Duration withinDuration = toDuration(info.getTimeRange(), info.getTimeUnit());
	final int maxNumRetries = info.getMaxNumRetries();
	final boolean loggingEnabled = info.isLoggingEnabled();
	return info.getType().equals(SupervisorStrategyType.ONE_FOR_ONE) ?
		new OneForOneStrategy(maxNumRetries, 
			withinDuration,
			myDecider(),
			loggingEnabled 
			) :
		new AllForOneStrategy(maxNumRetries, 
			withinDuration,
			myDecider(),
			loggingEnabled 
			);
}
 
开发者ID:mrpantsuit,项目名称:javactor,代码行数:21,代码来源:JavactorUntypedActor.java


示例7: supervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@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();
            });
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:ShardManager.java


示例8: supervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
    return new OneForOneStrategy(10, Duration.create("1 minute"), t -> {
        LOG.error("An exception happened actor will be resumed", t);
        return SupervisorStrategy.resume();
    });
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:RpcManager.java


示例9: supervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
  return new OneForOneStrategy(-1, Duration.Inf(), throwable -> {
    logger.error(throwable, "Unknown session error");
    if (throwable instanceof Error) {
      return OneForOneStrategy.escalate();
    } else {
      return OneForOneStrategy.resume();
    }
  });
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:12,代码来源:SessionActor.java


示例10: supervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
    return new OneForOneStrategy(-1, Duration.Inf(),
            throwable -> {
                logger.error(throwable, "Unknown session error");
                if (throwable instanceof Error) {
                    return OneForOneStrategy.escalate();
                } else {
                    return OneForOneStrategy.resume();
                }
            });
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:13,代码来源:SessionActor.java


示例11: supervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
    return new OneForOneStrategy(-1, Duration.create("1 minute"),
            t -> {
                log.error(t, "DroneActor failure caught by supervisor.");
                System.err.println(t.getMessage());
                return SupervisorStrategy.resume(); // Continue on all exceptions!
            });
}
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:10,代码来源:DroneActor.java


示例12: getSupervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
/**
 * 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();
        }
    });
}
 
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:19,代码来源:DefaultNotificationManagerPlugin.java


示例13: getSupervisorStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
/**
 * 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();
        }
    });
}
 
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:21,代码来源:PluginManagerServiceImpl.java


示例14: buildResumeOrEscalateStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
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();
        }
      }
    });
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:15,代码来源:SupervisionStrategyFactory.java


示例15: buildRestartOrEscalateStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
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();
        }
      }
    });
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:15,代码来源:SupervisionStrategyFactory.java


示例16: apply

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@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();
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:11,代码来源:Boot.java


示例17: getRestartChildStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Nonnull
public OneForOneStrategy getRestartChildStrategy() {
    return restartChildStrategy;
}
 
开发者ID:tomtom-international,项目名称:speedtools,代码行数:5,代码来源:SupervisorStrategies.java


示例18: getStopChildStrategy

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Nonnull
public OneForOneStrategy getStopChildStrategy() {
    return stopChildStrategy;
}
 
开发者ID:tomtom-international,项目名称:speedtools,代码行数:5,代码来源:SupervisorStrategies.java


示例19: defaultStrategy

import akka.actor.OneForOneStrategy; //导入依赖的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


示例20: apply

import akka.actor.OneForOneStrategy; //导入依赖的package包/类
@Override
public Directive apply(Throwable t) {
	return OneForOneStrategy.stop();
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:5,代码来源:MessageProtocolHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ComparisonTerm类代码示例发布时间:2022-05-21
下一篇:
Java BasicHttpClient类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap