akka.actor.ActorKilledException Java Examples

The following examples show how to use akka.actor.ActorKilledException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StoppingSupervisorWithoutLoggingActorKilledExceptionStrategy.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public SupervisorStrategy create() {
	return new OneForOneStrategy(
		false,
		new PFBuilder<Throwable, SupervisorStrategy.Directive>()
			.match(
				Exception.class,
				(Exception e) -> {
					if (e instanceof ActorKilledException) {
						LOG.debug("Actor was killed. Stopping it now.", e);
					} else {
						LOG.error("Actor failed with exception. Stopping it now.", e);
					}
					return SupervisorStrategy.Stop$.MODULE$;
				})
			.build());
}
 
Example #2
Source File: StoppingSupervisorWithoutLoggingActorKilledExceptionStrategy.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public SupervisorStrategy create() {
	return new OneForOneStrategy(
		false,
		new PFBuilder<Throwable, SupervisorStrategy.Directive>()
			.match(
				Exception.class,
				(Exception e) -> {
					if (e instanceof ActorKilledException) {
						LOG.debug("Actor was killed. Stopping it now.", e);
					} else {
						LOG.error("Actor failed with exception. Stopping it now.", e);
					}
					return SupervisorStrategy.Stop$.MODULE$;
				})
			.build());
}
 
Example #3
Source File: AbstractProxyActor.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public SupervisorStrategy supervisorStrategy() {
    return new OneForOneStrategy(true, DeciderBuilder
            .match(NullPointerException.class, e -> {
                log.error(e, "NullPointer in child actor - restarting it...", e.getMessage());
                log.info("Restarting child...");
                return SupervisorStrategy.restart();
            })
            .match(ActorKilledException.class, e -> {
                log.error(e.getCause(), "ActorKilledException in child actor - stopping it...");
                return SupervisorStrategy.stop();
            })
            .matchAny(e -> SupervisorStrategy.escalate())
            .build());
}
 
Example #4
Source File: SetupDocumentTypeWorkerActor.java    From searchanalytics-bigdata with MIT License 6 votes vote down vote up
@Override
public Directive apply(final Throwable t) {
	if (t instanceof DocumentTypeDataGenerationException) {
		return restart();
	} else if (t instanceof DocumentGenerationException) {
		return restart();
	} else if (t instanceof IndexDataException) {
		return restart();
	} else if (t instanceof ActorInitializationException) {
		return stop();
	} else if (t instanceof ActorKilledException) {
		return stop();
	} else if (t instanceof Exception) {
		return restart();
	} else {
		return escalate();
	}
}
 
Example #5
Source File: ClusterSingletonSupervisorActor.java    From ditto with Eclipse Public License 2.0 4 votes vote down vote up
private OneForOneStrategy buildDefaultSupervisorStrategy() {
    return new OneForOneStrategy(true, DeciderBuilder
            .match(NullPointerException.class, e -> {
                log.error(e, "NullPointer in singleton actor: {}", e.getMessage());
                return restartChild();
            }).match(IllegalArgumentException.class, e -> {
                log.warning("Illegal Argument in singleton actor: {}", e.getMessage());

                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                log.warning("Illegal Argument in singleton actor: {}", sw.toString());
                return SupervisorStrategy.resume();
            }).match(IllegalStateException.class, e -> {
                log.warning("Illegal State in singleton actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(IndexOutOfBoundsException.class, e -> {
                log.warning("IndexOutOfBounds in singleton actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(NoSuchElementException.class, e -> {
                log.warning("NoSuchElement in singleton actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(AskTimeoutException.class, e -> {
                log.warning("AskTimeoutException in singleton actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(ConnectException.class, e -> {
                log.warning("ConnectException in singleton actor: {}", e.getMessage());
                return restartChild();
            }).match(InvalidActorNameException.class, e -> {
                log.warning("InvalidActorNameException in singleton actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(ActorKilledException.class, e -> {
                log.error(e, "ActorKilledException in singleton actor: {}", e.message());
                return restartChild();
            }).match(DittoRuntimeException.class, e -> {
                log.error(e,
                        "DittoRuntimeException '{}' should not be escalated to SupervisorActor. Simply resuming Actor.",
                        e.getErrorCode());
                return SupervisorStrategy.resume();
            }).match(UnsupportedOperationException.class, e -> {
                log.error(e, "UnsupportedOperationException in singleton actor: {}",
                        e.getMessage());
                terminateActorSystem();
                return SupervisorStrategy.stop(); // only stopping as ActorSystem is terminated anyways
            }).match(Throwable.class, e -> {
                log.error(e, "Escalating above root actor!");
                terminateActorSystem();
                return SupervisorStrategy.stop(); // only stopping as ActorSystem is terminated anyways
            }).matchAny(e -> {
                log.error("Unknown message:'{}'! Escalating above root actor!", e);
                terminateActorSystem();
                return SupervisorStrategy.stop(); // only stopping as ActorSystem is terminated anyways
            }).build());
}
 
Example #6
Source File: RootSupervisorStrategyFactory.java    From ditto with Eclipse Public License 2.0 4 votes vote down vote up
public static OneForOneStrategy createStrategy(final LoggingAdapter log) {
    return new OneForOneStrategy(true, DeciderBuilder
            .match(NullPointerException.class, e -> {
                log.error(e, "NullPointer in child actor: {}", e.getMessage());
                log.info(RESTARTING_CHILD_MSG);
                return SupervisorStrategy.restart();
            }).match(IllegalArgumentException.class, e -> {
                log.warning("Illegal Argument in child actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(IndexOutOfBoundsException.class, e -> {
                log.warning("IndexOutOfBounds in child actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(IllegalStateException.class, e -> {
                log.warning("Illegal State in child actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(NoSuchElementException.class, e -> {
                log.warning("NoSuchElement in child actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(AskTimeoutException.class, e -> {
                log.warning("AskTimeoutException in child actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(ConnectException.class, e -> {
                log.warning("ConnectException in child actor: {}", e.getMessage());
                log.info(RESTARTING_CHILD_MSG);
                return SupervisorStrategy.restart();
            }).match(InvalidActorNameException.class, e -> {
                log.warning("InvalidActorNameException in child actor: {}", e.getMessage());
                return SupervisorStrategy.resume();
            }).match(ActorKilledException.class, e -> {
                log.error(e, "ActorKilledException in child actor: {}", e.message());
                log.info(RESTARTING_CHILD_MSG);
                return SupervisorStrategy.restart();
            }).match(DittoRuntimeException.class, e -> {
                log.error(e,
                        "DittoRuntimeException '{}' should not be escalated to RootActor. Simply resuming Actor.",
                        e.getErrorCode());
                return SupervisorStrategy.resume();
            }).match(Throwable.class, e -> {
                log.error(e, "Escalating above root actor!");
                return SupervisorStrategy.escalate();
            }).matchAny(e -> {
                log.error("Unknown message:'{}'! Escalating above root actor!", e);
                return SupervisorStrategy.escalate();
            }).build());
}