Java Code Examples for akka.cluster.singleton.ClusterSingletonManager#props()

The following examples show how to use akka.cluster.singleton.ClusterSingletonManager#props() . 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: ClusterUtil.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Start a cluster singleton actor.
 *
 * @param system the actor system.
 * @param actorRefFactory where the cluster singleton should be created.
 * @param role role of this cluster member.
 * @param actorName name of the singleton actor.
 * @param props Props of the singleton actor.
 * @param supervisorStrategy the {@link SupervisorStrategy} for the singleton actor.
 * @return reference of the singleton actor.
 */
public static ActorRef startSingleton(final ActorSystem system,
        final ActorRefFactory actorRefFactory,
        final String role,
        final String actorName,
        final Props props,
        final SupervisorStrategy supervisorStrategy) {

    final ClusterSingletonManagerSettings settings =
            ClusterSingletonManagerSettings.create(system).withRole(role);

    final Props supervisorProps = ClusterSingletonSupervisorActor.props(props, supervisorStrategy);
    final Props singletonManagerProps =
            ClusterSingletonManager.props(supervisorProps, PoisonPill.getInstance(), settings);
    return actorRefFactory.actorOf(singletonManagerProps, actorName);
}
 
Example 2
Source File: ClusterUtil.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Start a cluster singleton actor.
 *
 * @param system the actor system.
 * @param actorRefFactory where the cluster singleton should be created.
 * @param role role of this cluster member.
 * @param actorName name of the singleton actor.
 * @param props Props of the singleton actor.
 * @return reference of the singleton actor.
 */
public static ActorRef startSingleton(final ActorSystem system,
        final ActorRefFactory actorRefFactory,
        final String role,
        final String actorName,
        final Props props) {

    final ClusterSingletonManagerSettings settings =
            ClusterSingletonManagerSettings.create(system).withRole(role);

    final Props supervisorProps = ClusterSingletonSupervisorActor.props(props);
    final Props singletonManagerProps =
            ClusterSingletonManager.props(supervisorProps, PoisonPill.getInstance(), settings);
    return actorRefFactory.actorOf(singletonManagerProps, actorName);
}