@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" ); }
public static Props mkProps(ActorSystem system, ActorRef commandDispatcher, SagaRepository repository, ActorRef eventstore, String packageScanPath, String dispatcher) { Props singletonProps = Props.create(SagaManager.class, commandDispatcher, repository, eventstore, packageScanPath); if(dispatcher != null){ singletonProps = singletonProps.withDispatcher(dispatcher); } try { final ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create(system); system.actorOf(ClusterSingletonManager.props( singletonProps, "shutdown", settings), "sagamanagersingelton"); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create(system); proxySettings.withBufferSize(10000); return ClusterSingletonProxy.props("/user/eventstoresingelton", proxySettings); } catch (ConfigurationException e) { log.info("not cluster system"); return singletonProps; } }
/** * 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 singletonManagerProps = ClusterSingletonManager.props(props, PoisonPill.getInstance(), settings); return actorRefFactory.actorOf(singletonManagerProps, actorName); }
@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" ); }
private void startClusterSingletonActor(final String actorName, final Props props) { final ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create(getContext().system()).withRole(ConfigKeys.SEARCH_ROLE); getContext().actorOf(ClusterSingletonManager.props(props, PoisonPill.getInstance(), settings), actorName); }
@Override public void preStart() { try { Cluster cluster = Cluster.get(getContext().system()); cluster.subscribe(self(), ClusterEvent.MemberRemoved.class); log.info("{} subscribes to cluster events", self()); } catch (ConfigurationException e) { } final ActorSystem system = context().system(); try { Cluster cluster = Cluster.get(system); final ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create(system); system.actorOf(ClusterSingletonManager.props( EventstoreSingelton.mkProps(storage), "shutdown", settings), "eventstoresingelton"); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create(system); proxySettings.withBufferSize(10000); eventstoresingeltonProxy = system.actorOf(ClusterSingletonProxy.props("/user/eventstoresingelton", proxySettings), "eventstoresingeltonProxy"); } catch (ConfigurationException e) { log.info("not cluster system"); eventstoresingeltonProxy = system.actorOf(EventstoreSingelton.mkProps(storage)); } log.debug("Eventstore started with adress {}", getSelf().path()); }
@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" ); }
public AkkaDistributedPluginOrchestrator(String hostname, String port) { super(); index = getIndex(); model = getModel(); storage = getStorage(); String role = "backend"; String systemName = "ClusterSystem"; String systemPath = systemName + "@" + hostname + ":" + port; Config conf = ConfigFactory.parseString("akka.cluster.roles=[" + role + "]") .withFallback(ConfigFactory.parseString("akka.cluster.seed-nodes=[\"akka.tcp://" + systemPath + "\"]")) .withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.hostname=" + hostname)) .withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.port=" + port)) .withFallback(ConfigFactory.load("config/orchestrator/application")); clusterSystem = ActorSystem.create(systemName, conf); startupSharedJournal(getClusterSystem(), true, ActorPaths.fromString("akka.tcp://" + systemPath + "/user/store")); FiniteDuration workTimeout = Duration.create(10, "seconds"); getClusterSystem().actorOf(ClusterSingletonManager.props(Master.props(workTimeout), PoisonPill.getInstance(), ClusterSingletonManagerSettings.create(getClusterSystem()).withRole(role)), "master"); frontend = clusterSystem.actorOf(Props.create(Frontend.class), "frontend"); }
@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 ); }
public static void startup(String[] ports) { for (String port : ports) { // Override the configuration of the port Config config = ConfigFactory.parseString( "akka.remote.netty.tcp.port=" + port + "\n" + "akka.remote.artery.canonical.port=" + port) .withFallback( ConfigFactory.parseString("akka.cluster.roles = [compute]")) .withFallback(ConfigFactory.load("stats2")); ActorSystem system = ActorSystem.create("ClusterSystem", config); ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create(system) .withRole("compute"); system.actorOf(ClusterSingletonManager.props( Props.create(StatsService.class), PoisonPill.getInstance(), settings), "statsService"); ClusterSingletonProxySettings proxySettings = ClusterSingletonProxySettings.create(system).withRole("compute"); system.actorOf(ClusterSingletonProxy.props("/user/statsService", proxySettings), "statsServiceProxy"); } } }