/** * Add the new worker to the router mechanism * * @param address */ private void addWorkerRoute(String address) { // send the stop message to all the worker actors if (workerRouterActor != null) { for (int i = 0; i < workerAddressMap.size(); i++) workerRouterActor.tell("STOP"); } // add the address to the Map workerAddressMap.put(address, AddressFromURIString.parse(address)); Address[] addressNodes = new Address[workerAddressMap.size()]; Address[] workerAddress = workerAddressMap.values().toArray( addressNodes); // update the workerRouter actor with the information on all workers workerRouterActor = getContext().system().actorOf( new Props(WorkerActor.class).withRouter(new RemoteRouterConfig( new RoundRobinRouter(workerAddress.length), workerAddress))); }
public MemberNode build() throws Exception { Preconditions.checkNotNull(moduleShardsConfig, "moduleShardsConfig must be specified"); Preconditions.checkNotNull(akkaConfig, "akkaConfig must be specified"); Preconditions.checkNotNull(testName, "testName must be specified"); if (schemaContext == null) { schemaContext = SchemaContextHelper.full(); } MemberNode node = new MemberNode(); node.datastoreContextBuilder = datastoreContextBuilder; Config baseConfig = ConfigFactory.load(); Config config; if (useAkkaArtery) { config = baseConfig.getConfig(akkaConfig); } else { config = baseConfig.getConfig(akkaConfig + "-without-artery") .withFallback(baseConfig.getConfig(akkaConfig)); } ActorSystem system = ActorSystem.create("cluster-test", config); String member1Address = useAkkaArtery ? MEMBER_1_ADDRESS : MEMBER_1_ADDRESS.replace("akka", "akka.tcp"); Cluster.get(system).join(AddressFromURIString.parse(member1Address)); node.kit = new IntegrationTestKit(system, datastoreContextBuilder); String memberName = new ClusterWrapperImpl(system).getCurrentMemberName().getName(); node.kit.getDatastoreContextBuilder().shardManagerPersistenceId("shard-manager-config-" + memberName); node.configDataStore = node.kit.setupAbstractDataStore(DistributedDataStore.class, "config_" + testName, moduleShardsConfig, true, schemaContext, waitForshardLeader); if (createOperDatastore) { node.kit.getDatastoreContextBuilder().shardManagerPersistenceId("shard-manager-oper-" + memberName); node.operDataStore = node.kit.setupAbstractDataStore(DistributedDataStore.class, "oper_" + testName, moduleShardsConfig, true, schemaContext, waitForshardLeader); } members.add(node); return node; }
public static MemberRemoved createMemberRemoved(final String memberName, final String address) { UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L); Member member = new Member(uniqueAddress, 1, MemberStatus.removed(), setOf(memberName)); return new MemberRemoved(member, MemberStatus.up()); }
public static MemberUp createMemberUp(final String memberName, final String address) { UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L); Member member = new Member(uniqueAddress, 1, MemberStatus.up(), setOf(memberName)); return new MemberUp(member); }
public static UnreachableMember createUnreachableMember(final String memberName, final String address) { UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L); Member member = new Member(uniqueAddress, 1, MemberStatus.up(), setOf(memberName)); return new UnreachableMember(member); }
public static ReachableMember createReachableMember(final String memberName, final String address) { UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L); Member member = new Member(uniqueAddress, 1, MemberStatus.up(), setOf(memberName)); return new ReachableMember(member); }