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


Java ActorNotFound类代码示例

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


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

示例1: testQueryActorShutdown

import akka.actor.ActorNotFound; //导入依赖的package包/类
/**
 * Tests that the query actor will be stopped when the MetricRegistry is shut down.
 */
@Test
public void testQueryActorShutdown() throws Exception {
	final FiniteDuration timeout = new FiniteDuration(10L, TimeUnit.SECONDS);

	MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());

	final ActorSystem actorSystem = AkkaUtils.createDefaultActorSystem();

	registry.startQueryService(actorSystem, null);

	ActorRef queryServiceActor = registry.getQueryService();

	registry.shutdown();

	try {
		Await.result(actorSystem.actorSelection(queryServiceActor.path()).resolveOne(timeout), timeout);

		fail("The query actor should be terminated resulting in a ActorNotFound exception.");
	} catch (ActorNotFound e) {
		// we expect the query actor to be shut down
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:MetricRegistryTest.java

示例2: testQueryActorShutdown

import akka.actor.ActorNotFound; //导入依赖的package包/类
/**
 * Tests that the query actor will be stopped when the MetricRegistry is shut down.
 */
@Test
public void testQueryActorShutdown() throws Exception {
	final FiniteDuration timeout = new FiniteDuration(10L, TimeUnit.SECONDS);

	MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());

	final ActorSystem actorSystem = AkkaUtils.createDefaultActorSystem();

	registry.startQueryService(actorSystem, null);

	ActorRef queryServiceActor = registry.getQueryService();

	registry.shutdown();

	try {
		Await.result(actorSystem.actorSelection(queryServiceActor.path()).resolveOne(timeout), timeout);

		fail("The query actor should be terminated resulting in a ActorNotFound exception.");
	} catch (ActorNotFound e) {
		// we expect the query actor to be shut down
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:MetricRegistryImplTest.java

示例3: queryStateFuture

import akka.actor.ActorNotFound; //导入依赖的package包/类
public Future<Object> queryStateFuture(final QueryState<K> queryState) {
	LOG.debug("Try to get ActorRef future for key {}.", queryState.getKey());

	Future<ActorRef> actorRefFuture = getActorRefFuture(queryState.getKey());

	@SuppressWarnings("unchecked")
	Future<Object> result =  actorRefFuture.flatMap(new Mapper<ActorRef, Future<Object>>() {
		public Future<Object> apply(ActorRef actorRef) {
			LOG.debug("Ask response actor for state for key {}.", queryState.getKey());
			return Patterns.ask(actorRef, queryState, new Timeout(askTimeout));
		}
	}, executor).recoverWith(new Recover<Future<Object>>() {
		@Override
		public Future<Object> recover(final Throwable failure) throws Throwable {
			if (failure instanceof WrongKeyPartitionException || failure instanceof ActorNotFound) {
				// wait askTimeout because we communicated with the wrong actor. This usually
				// indicates that not all actors have registered at the registry.
				return Patterns.after(
					askTimeout,
					getContext().system().scheduler(),
					executor,
					new Callable<Future<Object>>() {
						@Override
						public Future<Object> call() throws Exception {
							refreshCache();
							return Futures.failed(failure);
						}
					});
			} else if (failure instanceof AskTimeoutException) {
				LOG.debug("Ask timed out.", failure);
				handleAskTimeout();
				return Futures.failed(failure);
			} else {
				LOG.debug("State query failed with.", failure);
				refreshCache();
				return Futures.failed(failure);
			}
		}
	}, executor);

	return result;
}
 
开发者ID:dataArtisans,项目名称:query-window-example,代码行数:43,代码来源:QueryActor.java


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