EntityOwnershipShard extends Shard { public static Builder newBuilder() { return new Builder(); } protected  EntityOwnershipShard(final Builder builder); @Override void handleNonRaftCommand(final Object message); static Builder newBuilder();  }
@Test public void testDelayedEntityOwnerSelectionWhenMaxPeerRequestsReceived() { testLog.info("testDelayedEntityOwnerSelectionWhenMaxPeerRequestsReceived starting"); ShardTestKit kit = new ShardTestKit(getSystem()); EntityOwnerSelectionStrategyConfig.Builder builder = EntityOwnerSelectionStrategyConfig.newBuilder() .addStrategy(ENTITY_TYPE, LastCandidateSelectionStrategy.class, 500); ShardIdentifier leaderId = newShardId(LOCAL_MEMBER_NAME); ShardIdentifier peerId = newShardId(PEER_MEMBER_1_NAME); TestActorRef<TestEntityOwnershipShard> peer = actorFactory.createTestActor(TestEntityOwnershipShard.props( newShardBuilder(peerId, peerMap(leaderId.toString()), PEER_MEMBER_1_NAME)), peerId.toString()); peer.underlyingActor().startDroppingMessagesOfType(ElectionTimeout.class); TestActorRef<EntityOwnershipShard> leader = actorFactory.createTestActor( newShardProps(leaderId, peerMap(peerId.toString()), LOCAL_MEMBER_NAME, builder.build()), leaderId.toString()); ShardTestKit.waitUntilLeader(leader); DOMEntity entity = new DOMEntity(ENTITY_TYPE, ENTITY_ID1); peer.tell(new RegisterCandidateLocal(entity), kit.getRef()); kit.expectMsgClass(SuccessReply.class); leader.tell(new RegisterCandidateLocal(entity), kit.getRef()); kit.expectMsgClass(SuccessReply.class); verifyCommittedEntityCandidate(leader, entity.getType(), entity.getIdentifier(), PEER_MEMBER_1_NAME); verifyCommittedEntityCandidate(leader, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME); verifyOwner(leader, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME); testLog.info("testDelayedEntityOwnerSelectionWhenMaxPeerRequestsReceived ending"); }
@Test public void testDelayedEntityOwnerSelection() { testLog.info("testDelayedEntityOwnerSelection starting"); final ShardTestKit kit = new ShardTestKit(getSystem()); EntityOwnerSelectionStrategyConfig.Builder builder = EntityOwnerSelectionStrategyConfig.newBuilder() .addStrategy(ENTITY_TYPE, LastCandidateSelectionStrategy.class, 500); dataStoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(2); ShardIdentifier leaderId = newShardId(LOCAL_MEMBER_NAME); ShardIdentifier peerId1 = newShardId(PEER_MEMBER_1_NAME); ShardIdentifier peerId2 = newShardId(PEER_MEMBER_2_NAME); TestActorRef<TestEntityOwnershipShard> peer1 = actorFactory.createTestActor(TestEntityOwnershipShard.props( newShardBuilder(peerId1, peerMap(leaderId.toString(), peerId2.toString()), PEER_MEMBER_1_NAME)), peerId1.toString()); peer1.underlyingActor().startDroppingMessagesOfType(ElectionTimeout.class); TestActorRef<TestEntityOwnershipShard> peer2 = actorFactory.createTestActor(TestEntityOwnershipShard.props( newShardBuilder(peerId2, peerMap(leaderId.toString(), peerId1.toString()), PEER_MEMBER_2_NAME)), peerId2.toString()); peer2.underlyingActor().startDroppingMessagesOfType(ElectionTimeout.class); TestActorRef<EntityOwnershipShard> leader = actorFactory.createTestActor( newShardProps(leaderId, peerMap(peerId1.toString(), peerId2.toString()), LOCAL_MEMBER_NAME, builder.build()), leaderId.toString()); ShardTestKit.waitUntilLeader(leader); DOMEntity entity = new DOMEntity(ENTITY_TYPE, ENTITY_ID1); peer1.tell(new RegisterCandidateLocal(entity), kit.getRef()); kit.expectMsgClass(SuccessReply.class); leader.tell(new RegisterCandidateLocal(entity), kit.getRef()); kit.expectMsgClass(SuccessReply.class); verifyCommittedEntityCandidate(leader, entity.getType(), entity.getIdentifier(), PEER_MEMBER_1_NAME); verifyCommittedEntityCandidate(leader, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME); verifyOwner(leader, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME); testLog.info("testDelayedEntityOwnerSelection ending"); }