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


Java Function类代码示例

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


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

示例1: supervisorStrategy

import akka.japi.Function; //导入依赖的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.japi.Function; //导入依赖的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: initSupervisor

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

示例4: supervisorStrategy

import akka.japi.Function; //导入依赖的package包/类
@Override
public SupervisorStrategy supervisorStrategy() {
  return new OneForOneStrategy(-1, Duration.Inf(),
    new Function<Throwable, Directive>() {
      @Override
      public Directive apply(Throwable t) {
        if (t instanceof ActorInitializationException)
          return stop();
        else if (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();
        }
      }
    }
  );
}
 
开发者ID:typesafehub,项目名称:activator-akka-distributed-workers-java,代码行数:24,代码来源:Worker.java

示例5: run

import akka.japi.Function; //导入依赖的package包/类
public void run() {
	while (countDown > 0) {
		try {
			Thread.sleep(75);
		} catch (InterruptedException e) {
		}
		String x = Thread.currentThread().getName();
		stock.getPrice().send(new Function<Float, Float>() {
			public Float apply(Float i) {
				return i + 10;
			}
		});
		System.out.println("Quote update by thread (" + x
				+ "), current price " + stock.getPrice().get());
		countDown = countDown - 1;
	}
}
 
开发者ID:rokumar7,项目名称:trial,代码行数:18,代码来源:StockUpdater.java

示例6: supervisorStrategy

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

示例7: supervisorStrategy

import akka.japi.Function; //导入依赖的package包/类
@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();
          }
      }
   );
}
 
开发者ID:dhinojosa,项目名称:intro_to_reactive,代码行数:15,代码来源:AllForOneParentActor.java

示例8: supervisorStrategy

import akka.japi.Function; //导入依赖的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 escalate();
                    if (param instanceof ArithmeticException) return escalate();
                    if (param instanceof NullPointerException) return escalate();
                    else return stop();
                }
            }
    );
}
 
开发者ID:dhinojosa,项目名称:intro_to_reactive,代码行数:15,代码来源:OneForOneParentActor.java

示例9: supervisorStrategy

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

示例10: getSupervisorStrategy

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

示例11: getSupervisorStrategy

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

示例12: buildResumeOrEscalateStrategy

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

示例13: buildRestartOrEscalateStrategy

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

示例14: batch

import akka.japi.Function; //导入依赖的package包/类
public void batch(List<Object> args, Function<Object, Object> converter) throws Exception {
	if(args.size() != columnCount) {
		throw new RuntimeException("column count doesn't match, expected: " + columnCount + " received: " + args.size()); 
	}
	
	setObjects(args, converter);
	
	stmt.addBatch();
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:10,代码来源:PublisherTransaction.java

示例15: setObjects

import akka.japi.Function; //导入依赖的package包/类
private void setObjects(List<Object> args, Function<Object, Object> converter) throws Exception {
	int i = 1;
	
	for(Object arg : args) {
		stmt.setObject(i++, converter.apply(arg));
	}
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:8,代码来源:PublisherTransaction.java


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