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


Java Terminated类代码示例

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


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

示例1: createReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public Receive createReceive() {
    return receiveBuilder().
            match(CreateGuest.class, createGuest -> {
                final ActorRef guest = createGuest(createGuest.favoriteCoffee, createGuest.caffeineLimit);
                addGuestToBookkeeper(guest);
                context().watch(guest);
            }).
            match(ApproveCoffee.class, this::coffeeApproved, approveCoffee ->
                    barista.forward(new Barista.PrepareCoffee(approveCoffee.coffee, approveCoffee.guest), context())
            ).
            match(ApproveCoffee.class, approveCoffee -> {
                log().info("Sorry, {}, but you have reached your limit.", approveCoffee.guest.path().name());
                context().stop(approveCoffee.guest);
            }).
            match(Terminated.class, terminated -> {
                log().info("Thanks, {}, for being our guest!", terminated.getActor());
                removeGuestFromBookkeeper(terminated.getActor());
            }).build();
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-with-akka,代码行数:21,代码来源:CoffeeHouse.java

示例2: CoffeeHouse

import akka.actor.Terminated; //导入依赖的package包/类
public CoffeeHouse(int caffeineLimit) {
        log().debug("CoffeeHouse Open");
        this.caffeineLimit = caffeineLimit;

        receive(ReceiveBuilder.
                match(CreateGuest.class, createGuest -> {
                    final ActorRef guest = createGuest(createGuest.favoriteCoffee);
//                    final ActorRef guest = createGuest(createGuest.favoriteCoffee, createGuest.caffeineLimit);
                    addGuestToBookkeeper(guest);
                    context().watch(guest);
                }).
                match(ApproveCoffee.class, this::coffeeApproved, approveCoffee ->
                        barista.forward(new Barista.PrepareCoffee(approveCoffee.coffee, approveCoffee.guest), context())
                ).
                match(ApproveCoffee.class, approveCoffee -> {
                    log().info("Sorry, {}, but you have reached your limit.", approveCoffee.guest.path().name());
                    context().stop(approveCoffee.guest);
                }).
                match(Terminated.class, terminated -> {
                    log().info("Thanks, {}, for being our guest!", terminated.getActor());
                    removeGuestFromBookkeeper(terminated.getActor());
                }).
                matchAny(this::unhandled).build()
        );
    }
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-old,代码行数:26,代码来源:CoffeeHouse.java

示例3: createReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public Receive createReceive() {
    return receiveBuilder().
            match(CreateGuest.class, createGuest -> {
                final ActorRef guest = createGuest(createGuest.favoriteCoffee);
                addGuestToBookkeeper(guest);
                context().watch(guest);
            }).
            match(ApproveCoffee.class, this::coffeeApproved, approveCoffee ->
                    barista.forward(new Barista.PrepareCoffee(approveCoffee.coffee, approveCoffee.guest), context())
            ).
            match(ApproveCoffee.class, approveCoffee -> {
                log().info("Sorry, {}, but you have reached your limit.", approveCoffee.guest.path().name());
                context().stop(approveCoffee.guest);
            }).
            match(Terminated.class, terminated -> {
                log().info("Thanks, {}, for being our guest!", terminated.getActor());
                removeGuestFromBookkeeper(terminated.getActor());
            }).build();
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-student,代码行数:21,代码来源:CoffeeHouse.java

示例4: testShardTransactionInactivity

import akka.actor.Terminated; //导入依赖的package包/类
@Test
public void testShardTransactionInactivity() {
    datastoreContext = DatastoreContext.newBuilder().shardTransactionIdleTimeout(
            500, TimeUnit.MILLISECONDS).build();

    new JavaTestKit(getSystem()) {
        {
            final ActorRef transaction = newTransactionActor(RW, readWriteTransaction(),
                    "testShardTransactionInactivity");

            watch(transaction);

            expectMsgClass(duration("3 seconds"), Terminated.class);
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:ShardTransactionTest.java

示例5: onReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public void onReceive(Object msg) throws Exception {
  if (msg instanceof SessionAwareMsg) {
    forwardToSessionActor((SessionAwareMsg) msg);
  } else if (msg instanceof SessionTerminationMsg) {
    onSessionTermination((SessionTerminationMsg) msg);
  } else if (msg instanceof Terminated) {
    onTermination((Terminated) msg);
  } else if (msg instanceof SessionTimeoutMsg) {
    onSessionTimeout((SessionTimeoutMsg) msg);
  } else if (msg instanceof SessionCtrlMsg) {
    onSessionCtrlMsg((SessionCtrlMsg) msg);
  } else if (msg instanceof ClusterEventMsg) {
    broadcast(msg);
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:17,代码来源:SessionManagerActor.java

示例6: onReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public void onReceive(Object msg) throws Exception {
  logger.debug("Received message: {}", msg);
  if (msg instanceof ToDeviceActorMsg) {
    processDeviceMsg((ToDeviceActorMsg) msg);
  } else if (msg instanceof ToAssetActorMsg) {
    processAssetMsg((ToAssetActorMsg) msg);
  } else if (msg instanceof ToPluginActorMsg) {
    onToPluginMsg((ToPluginActorMsg) msg);
  } else if (msg instanceof ToRuleActorMsg) {
    onToRuleMsg((ToRuleActorMsg) msg);
  } else if (msg instanceof ToDeviceActorNotificationMsg) {
    onToDeviceActorMsg((ToDeviceActorNotificationMsg) msg);
  } else if (msg instanceof Terminated) {
    processTermination((Terminated) msg);
  } else if (msg instanceof ClusterEventMsg) {
    broadcast(msg);
  } else if (msg instanceof ComponentLifecycleMsg) {
    onComponentLifecycleMsg((ComponentLifecycleMsg) msg);
  } else if (msg instanceof PluginTerminationMsg) {
    onPluginTerminated((PluginTerminationMsg) msg);
  } else {
    logger.warning("Unknown message: {}!", msg);
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:26,代码来源:AppActor.java

示例7: reLaunchActor

import akka.actor.Terminated; //导入依赖的package包/类
private void reLaunchActor(Terminated message) {
    //TODO: test this

    ActorRef bundleActor = this.getContext().actorOf(
            springExtension.props(ApplicationConfiguration.JETTY_SERVLET_BUNDLE_APP_SUPERVISOR_ACTOR));
    ApplicationOptions config = ApplicationConfiguration.CONFIGURATIONS.get(((Terminated) message).getActor());
    getContext().unwatch(((Terminated) message).getActor());

    if (config != null) {
        BundleMessageRequest request = new BundleMessageRequest();
        request.setBundleRequestType(BundleRequestType.RE_HYDRATE);
        request.setApplicationOptions(config);
        bundleActor.tell(request, this.getSelf());
        getContext().watch(bundleActor);
    }
    if (LOG.isDebugEnabled()) LOG.debug("Restarted actor {}", ((Terminated) message).actor());
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:18,代码来源:Supervisor.java

示例8: createReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public Receive createReceive() {
    return receiveBuilder()
            .matchEquals("instrument", message -> periodicInstrumentation())
            .match(PeriodicData.class, this::executePeriodicData)
            .match(Connect.class, this::executeConnect)
            .match(LogLine.class, this::executeLogLine)
            .match(MetricsListRequest.class, ignored -> executeMetricsListRequest())
            .match(LogsListRequest.class, ignored -> executeLogsListRequest())
            .match(LogFileAppeared.class, this::executeLogAdded)
            .match(LogFileDisappeared.class, this::executeLogRemoved)
            .match(Terminated.class, this::executeQuit)
            .matchAny(message -> {
                _metrics.incrementCounter(UNKNOWN_COUNTER);
                LOGGER.warn()
                        .setMessage("Unsupported message")
                        .addData("actor", self())
                        .addData("data", message)
                        .log();
                unhandled(message);
            })
            .build();
}
 
开发者ID:ArpNetworking,项目名称:metrics-aggregator-daemon,代码行数:24,代码来源:Telemetry.java

示例9: shutdownAkka

import akka.actor.Terminated; //导入依赖的package包/类
private void shutdownAkka() {
    LOGGER.info().setMessage("Stopping akka").log();

    if (_actorSystem != null) {
        final Future<Terminated> terminate = _actorSystem.terminate();
        try {
            Await.result(terminate, Duration.create(30, TimeUnit.SECONDS));
            // CHECKSTYLE.OFF: IllegalCatch - Await.result throws Exception
        } catch (final Exception e) {
            // CHECKSTYLE.ON: IllegalCatch
            LOGGER.warn()
                    .setMessage("Exception while shutting down actor system")
                    .setThrowable(e)
                    .log();
        }
        _actorSystem = null;
    }
}
 
开发者ID:ArpNetworking,项目名称:metrics-aggregator-daemon,代码行数:19,代码来源:Main.java

示例10: onReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public void onReceive(Object message) throws InterpreterException {
    if (message instanceof InterpreterInterface.SubmoduleOutPortHasSignal) {
        moduleOutPortHasSignal(((InterpreterInterface.SubmoduleOutPortHasSignal) message).getOutPortId());
    } else if (message instanceof InstanceProvider) {
        setInstanceProvider((InstanceProvider) message);
    } else if (message instanceof RuntimeContext) {
        setRuntimeContext((RuntimeContext) message);
    } else if (message == TopLevelInterpreterActorInterface.Start.INSTANCE) {
        startRunning();
    } else if (message instanceof Props) {
        start((Props) message);
    } else if (message instanceof Terminated) {
        childActorTerminated(((Terminated) message).actor());
    } else if (message instanceof Status.Failure) {
        failure(((Status.Failure) message).cause());
    } else {
        super.onReceive(message);
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:21,代码来源:TopLevelInterpreterActor.java

示例11: onReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public void onReceive(Object message) {
    if (message instanceof MasterInterpreterActorInterface.CreateExecution) {
        createExecution((MasterInterpreterActorInterface.CreateExecution) message);
    } else if (message instanceof MasterInterpreterActorInterface.StartExecution) {
        startExecution(((MasterInterpreterActorInterface.StartExecution) message).getExecutionId());
    } else if (message instanceof MasterInterpreterActorInterface.CancelWorkflow) {
        MasterInterpreterActorInterface.CancelWorkflow arguments
            = (MasterInterpreterActorInterface.CancelWorkflow) message;
        cancel(arguments.getExecutionId(), arguments.getThrowable());
    } else if (message instanceof Terminated) {
        terminated(((Terminated) message).getActor());
    } else {
        unhandled(message);
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:17,代码来源:MasterInterpreterActor.java

示例12: onReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public void onReceive(Object message) throws InterpreterException {
    if (message instanceof IterationStatus) {
        IterationStatus arguments = (IterationStatus) message;
        iterationStatus(arguments.iteration, arguments.hasAllInputs);
    } else if (message instanceof FoundIterationInStagingArea) {
        foundIterationInStagingArea(((FoundIterationInStagingArea) message).iteration);
    } else if (message instanceof CopyInputsForIteration) {
        copyInputsForIteration(((CopyInputsForIteration) message).iteration);
    } else if (message instanceof CopiedInPortToFirstIteration) {
        copiedInPortToFirstIteration(((CopiedInPortToFirstIteration) message).inPortId);
    } else if (message instanceof Terminated) {
        childActorTerminated(((Terminated) message).getActor());
    } else if (message instanceof FinishedLastIteration) {
        finished(((FinishedLastIteration) message).iteration);
    } else if (message == LocalMessages.PREPARE_TO_TERMINATE) {
        prepareToTerminate();
    } else {
        super.onReceive(message);
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:22,代码来源:LoopModuleInterpreterActor.java

示例13: onReceive

import akka.actor.Terminated; //导入依赖的package包/类
@Override
public void onReceive(Object message) {
	if (message instanceof Terminated) {
		try {
			Terminated term = (Terminated) message;
			String name = term.actor().path().toSerializationFormat();
			if (log != null) {
				log.error("Actor " + name + " terminated, stopping process...");

				// give the log some time to reach disk
				try {
					Thread.sleep(100);
				}
				catch (InterruptedException e) {
					// not really a problem if we don't sleep...
				}
			}
		}
		finally {
			System.exit(exitCode);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:ProcessReaper.java

示例14: test_sup_strategy_stop

import akka.actor.Terminated; //导入依赖的package包/类
@Test
public void test_sup_strategy_stop() throws Throwable
{
	javactor = new HandleRuntimeExceptionTestJavactor();
	final Props props = Props.create(new MyCreator(javactor));
	final ActorRef target = system.actorOf(props);
	
	new JavaTestKit(system)
	{
		{
			final JavaTestKit probe = new JavaTestKit(system);
			Duration timeout = Duration.create("5 second");
			final ActorRef child = (ActorRef) Await.result(
				Patterns.ask(target, BoomActor.class, 5000),
				timeout);
			probe.watch(child);
			target.tell(SupervisorDirective.STOP, probe.getRef());
			probe.expectMsgClass(Object.class);
			target.tell(new TestMsg(), null);
			final Terminated msg = probe.expectMsgClass(Terminated.class);
			assertEquals(msg.getActor(), child);
		}
	};
}
 
开发者ID:mrpantsuit,项目名称:javactor,代码行数:25,代码来源:JavactorUntypedActorTest.java

示例15: test_sup_strategy_on_exception_method_param_supertype_of_thrown_exception

import akka.actor.Terminated; //导入依赖的package包/类
@Test
public void test_sup_strategy_on_exception_method_param_supertype_of_thrown_exception() throws Throwable
{
	javactor = new HandleThrowableTestjavactor();
	final Props props = Props.create(new MyCreator(javactor));
	final ActorRef target = system.actorOf(props);
	
	new JavaTestKit(system)
	{
		{
			final JavaTestKit probe = new JavaTestKit(system);
			Duration timeout = Duration.create("5 second");
			final ActorRef child = (ActorRef) Await.result(
				Patterns.ask(target, BoomActor.class, 5000),
				timeout);
			probe.watch(child);
			target.tell(SupervisorDirective.STOP, probe.getRef());
			probe.expectMsgClass(Object.class);
			target.tell(new TestMsg(), null);
			final Terminated msg = probe.expectMsgClass(Terminated.class);
			assertEquals(msg.getActor(), child);
		}
	};
}
 
开发者ID:mrpantsuit,项目名称:javactor,代码行数:25,代码来源:JavactorUntypedActorTest.java


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