akka.cluster.singleton.ClusterSingletonManagerSettings Java Examples
The following examples show how to use
akka.cluster.singleton.ClusterSingletonManagerSettings.
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: QueueActorRouterProducer.java From usergrid with Apache License 2.0 | 8 votes |
@Override public void produceRouter(ActorSystem system, String role) { ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create( system ).withRole( "io" ); system.actorOf( ClusterSingletonManager.props( Props.create( GuiceActorProducer.class, QueueActorRouter.class ), PoisonPill.getInstance(), settings ), "queueActorRouter" ); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create( system ).withRole( role ); system.actorOf( ClusterSingletonProxy.props( "/user/queueActorRouter", proxySettings ), "queueActorRouterProxy" ); }
Example #2
Source File: ClusterUtil.java From ditto with Eclipse Public License 2.0 | 6 votes |
/** * 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 #3
Source File: ClusterSingleton.java From ts-reaktive with MIT License | 6 votes |
/** * Starts and returns the an {@link ActorRef} to the {@link ClusterSingletonManager} (and backoff supervisor) * that manage this actor singleton. * * Note that you can't send this ActorRef messages that should go to your actor: use {@link StartProxy} for that. * * @param constructor Constructor to pass to Props in order to actually create the actor */ public ActorRef start(ActorSystem system, Supplier<T> constructor) { Config config = system.settings().config().getConfig("ts-reaktive.actors.singleton"); Props backoffSupervisorProps = BackoffSupervisor.props( Backoff.onStop( Props.create(type, () -> constructor.get()), "actor", FiniteDuration.create(config.getDuration("min-backoff", SECONDS), SECONDS), FiniteDuration.create(config.getDuration("max-backoff", SECONDS), SECONDS), 0.2 ).withSupervisorStrategy(new OneForOneStrategy( DeciderBuilder .matchAny(e -> { log.info("{}: Stopping and awaiting restart.", name, e); return stop(); }) .build() )) ); return system.actorOf( ClusterSingletonManager.props(backoffSupervisorProps, PoisonPill.getInstance(), ClusterSingletonManagerSettings.create(system) ), name); }
Example #4
Source File: DataCenterForwarder.java From ts-reaktive with MIT License | 6 votes |
/** * Starts a DataCenterForwarder for each of the known data centers in the {@link DataCenterRepository}. * @param system Actor system to create the DataCenterForwarder actors in * @param dataRepo Repository that knows about all data centers * @param materializer Akka streams materializer to use * @param visibilityRepo Repository that stores the current visiblity of aggregates * @param eventRepo Classifier that determines which additional datacenters an event should trigger replication for * @param eventsByTagQuery Query to use to find a continuous stream of all events * @param tag Tag to pass to {@link EventsByTagQuery} (all events must be tagged by this) * @param currentEventsByPersistenceIdQuery Query to find all current events for a specific persistenceId */ public static <E> void startAll(ActorSystem system, Materializer materializer, DataCenterRepository dataRepo, VisibilityRepository visibilityRepo, Class<E> eventType, EventsByTagQuery eventsByTagQuery, CurrentEventsByPersistenceIdQuery currentEventsByPersistenceIdQuery) { String tag = Replication.get(system).getEventTag(eventType); for (DataCenter dataCenter: dataRepo.getRemotes().values()) { system.actorOf(ClusterSingletonManager.props( BackoffSupervisor.props( Backoff.onFailure( Props.create(DataCenterForwarder.class, () -> new DataCenterForwarder<>(materializer, dataCenter, visibilityRepo, eventType, eventsByTagQuery, currentEventsByPersistenceIdQuery)), "f", Duration.create(1, TimeUnit.SECONDS), Duration.create(1, TimeUnit.SECONDS), // TODO make these 3 configurable 0.2) ), Done.getInstance(), ClusterSingletonManagerSettings.create(system).withSingletonName("s")), "forwarder_" + dataCenter.getName() + "_" + tag); } }
Example #5
Source File: QueueWriterRouterProducer.java From usergrid with Apache License 2.0 | 6 votes |
@Override public void produceRouter(ActorSystem system, String role) { ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create( system ).withRole( "io" ); system.actorOf( ClusterSingletonManager.props( Props.create( GuiceActorProducer.class, QueueWriterRouter.class ), PoisonPill.getInstance(), settings ), "queueWriterRouter" ); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create( system ).withRole( role ); system.actorOf( ClusterSingletonProxy.props( "/user/queueWriterRouter", proxySettings ), "queueWriterRouterProxy" ); }
Example #6
Source File: QueueSenderRouterProducer.java From usergrid with Apache License 2.0 | 6 votes |
@Override public void produceRouter(ActorSystem system, String role) { ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create( system ).withRole( "io" ); system.actorOf( ClusterSingletonManager.props( Props.create( GuiceActorProducer.class, QueueSenderRouter.class ), PoisonPill.getInstance(), settings ), "queueSenderRouter" ); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create( system ).withRole( role ); system.actorOf( ClusterSingletonProxy.props( "/user/queueSenderRouter", proxySettings ), "queueSenderRouterProxy" ); }
Example #7
Source File: UniqueValuesServiceImpl.java From usergrid with Apache License 2.0 | 6 votes |
@Override public void produceRouter( ActorSystem system, String role ) { ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create( system ).withRole("io"); system.actorOf( ClusterSingletonManager.props( Props.create( GuiceActorProducer.class, UniqueValuesRouter.class ), PoisonPill.getInstance(), settings ), "uvRouter" ); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create( system ).withRole( role ); system.actorOf( ClusterSingletonProxy.props( "/user/uvRouter", proxySettings ), "uvProxy" ); subscribeToReservations( system ); }
Example #8
Source File: ClusterUtil.java From ditto with Eclipse Public License 2.0 | 5 votes |
/** * 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); }
Example #9
Source File: S3Backup.java From ts-reaktive with MIT License | 5 votes |
/** * Starts a ClusterSingletonManager + BackoffSupervisor that manages a continous backup to S3, restarting * and resuming automatically on crash or failure. * * @param system The actor system to create the singleton for * @param query The akka persistence query journal to read events from * @param tag Tag to pass to the above query * @param s3 Service interface to communicate with S3 */ public static void start(ActorSystem system, EventsByTagQuery query, String tag, S3 s3) { system.actorOf(ClusterSingletonManager.props( BackoffSupervisor.props( Backoff.onFailure( Props.create(S3Backup.class, () -> new S3Backup(query, tag, s3)), "a", FiniteDuration.create(1, TimeUnit.SECONDS), FiniteDuration.create(1, TimeUnit.SECONDS), // TODO make these 3 configurable 0.2) ), Done.getInstance(), ClusterSingletonManagerSettings.create(system).withSingletonName("s")), "s3backup"); }
Example #10
Source File: EventSchedulerRegistryImpl.java From flux with Apache License 2.0 | 5 votes |
@Override public void initialize() { ActorSystem actorSystem = actorSystemManager.retrieveActorSystem(); //create cluster singleton actor of {@link AkkaEventSchedulerService} Props actorProps = Props.create(AkkaEventSchedulerService.class, eventSchedulerService); ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create(actorSystem); actorSystem.actorOf(ClusterSingletonManager.props(actorProps, PoisonPill.getInstance(), settings), "eventSchedulerServiceActor"); }
Example #11
Source File: RedriverRegistryImpl.java From flux with Apache License 2.0 | 5 votes |
/** * Initialize the singleton actor wrapping redriverService. * * @see AkkaRedriverService */ @Override public void initialize() { ActorSystem actorSystem = actorSystemManager.retrieveActorSystem(); Props actorProps = Props.create(AkkaRedriverService.class, redriverService); ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create(actorSystem); actorSystem.actorOf(ClusterSingletonManager.props(actorProps, PoisonPill.getInstance(), settings), "redriverServiceActor"); }