本文整理汇总了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();
}
示例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()
);
}
示例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();
}
示例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);
}
};
}
示例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);
}
}
示例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);
}
}
示例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());
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
};
}
示例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);
}
};
}