本文整理匯總了Java中akka.actor.Kill類的典型用法代碼示例。如果您正苦於以下問題:Java Kill類的具體用法?Java Kill怎麽用?Java Kill使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Kill類屬於akka.actor包,在下文中一共展示了Kill類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: stopServer
import akka.actor.Kill; //導入依賴的package包/類
@Override
public void stopServer(RpcServer selfGateway) {
if (selfGateway instanceof AkkaBasedEndpoint) {
final AkkaBasedEndpoint akkaClient = (AkkaBasedEndpoint) selfGateway;
final RpcEndpoint rpcEndpoint;
synchronized (lock) {
if (stopped) {
return;
} else {
rpcEndpoint = actors.remove(akkaClient.getActorRef());
}
}
if (rpcEndpoint != null) {
akkaClient.getActorRef().tell(Kill.getInstance(), ActorRef.noSender());
} else {
LOG.debug("RPC endpoint {} already stopped or from different RPC service", selfGateway.getAddress());
}
}
}
示例2: testTerminationOnFatalError
import akka.actor.Kill; //導入依賴的package包/類
@Test
public void testTerminationOnFatalError() {
highAvailabilityServices.setJobMasterLeaderRetriever(
HighAvailabilityServices.DEFAULT_JOB_ID,
new TestingLeaderRetrievalService());
new JavaTestKit(system){{
final ActorGateway taskManager = TestingUtils.createTaskManager(
system,
highAvailabilityServices, // no jobmanager
new Configuration(),
true,
false);
try {
watch(taskManager.actor());
taskManager.tell(new FatalError("test fatal error", new Exception("something super bad")));
expectTerminated(d, taskManager.actor());
}
finally {
taskManager.tell(Kill.getInstance());
}
}};
}
示例3: onReceive
import akka.actor.Kill; //導入依賴的package包/類
@Override
public void onReceive(Object msg) throws Exception {
if(msg instanceof Restart) {
log.info("killing application");
app.tell(Kill.getInstance(), getSelf());
} else if(msg instanceof GetActorTree) {
log.info("actor tree requested");
// we have to manually forward the message
// as the monitor actor isn't allowed to talk
// to the publisher service directly.
ActorRef self = getSelf(), sender = getSender();
f.ask(monitor, new GetTree(), Tree.class).thenAccept(tree -> {
sender.tell(tree, self);
});
} else {
unhandled(msg);
}
}
示例4: shutdown
import akka.actor.Kill; //導入依賴的package包/類
/**
* Shuts down this registry and the associated {@link MetricReporter}.
*/
public void shutdown() {
synchronized (lock) {
Future<Boolean> stopFuture = null;
FiniteDuration stopTimeout = null;
if (queryService != null) {
stopTimeout = new FiniteDuration(1L, TimeUnit.SECONDS);
try {
stopFuture = Patterns.gracefulStop(queryService, stopTimeout);
} catch (IllegalStateException ignored) {
// this can happen if the underlying actor system has been stopped before shutting
// the metric registry down
// TODO: Pull the MetricQueryService actor out of the MetricRegistry
LOG.debug("The metric query service actor has already been stopped because the " +
"underlying ActorSystem has already been shut down.");
}
}
if (reporters != null) {
for (MetricReporter reporter : reporters) {
try {
reporter.close();
} catch (Throwable t) {
LOG.warn("Metrics reporter did not shut down cleanly", t);
}
}
reporters = null;
}
shutdownExecutor();
if (stopFuture != null) {
boolean stopped = false;
try {
stopped = Await.result(stopFuture, stopTimeout);
} catch (Exception e) {
LOG.warn("Query actor did not properly stop.", e);
}
if (!stopped) {
// the query actor did not stop in time, let's kill him
queryService.tell(Kill.getInstance(), ActorRef.noSender());
}
}
}
}
示例5: stopActor
import akka.actor.Kill; //導入依賴的package包/類
private static void stopActor(ActorRef actor) {
if (actor != null) {
actor.tell(Kill.getInstance(), ActorRef.noSender());
}
}