@Test public void replicationWithOutOfOrderPostAndUpdates() throws Throwable { setUp(this.nodeCount); this.host.joinNodesAndVerifyConvergence(this.host.getPeerCount()); this.host.setNodeGroupQuorum(this.nodeCount / 2 + 1); waitForReplicatedFactoryServiceAvailable( this.host.getPeerServiceUri(ExampleService.FACTORY_LINK), ServiceUriPaths.DEFAULT_NODE_SELECTOR); waitForReplicationFactoryConvergence(); ExampleServiceState state = new ExampleServiceState(); state.name = "testing"; state.counter = 1L; VerificationHost peer = this.host.getPeerHost(); Map<String, ExampleServiceState> exampleStatesPerSelfLink = new HashMap<>(); TestContext ctx = this.host.testCreate(this.serviceCount * this.updateCount); for (int i = 0; i < this.serviceCount; i++) { Operation post = Operation .createPost(peer, ExampleService.FACTORY_LINK) .setBody(state) .setReferer(this.host.getUri()) .setCompletion((o, e) -> { if (e != null) { ctx.failIteration(e); return; } ExampleServiceState rsp = o.getBody(ExampleServiceState.class); for (int k = 0; k < this.updateCount; k++) { ExampleServiceState update = new ExampleServiceState(); state.counter = (long) k; Operation patch = Operation .createPatch(peer, rsp.documentSelfLink) .setBody(update) .setReferer(this.host.getUri()) .setCompletion((op, ex) -> { if (ex != null) { ctx.failIteration(ex); return; } ExampleServiceState updatedState = op.getBody(ExampleServiceState.class); exampleStatesPerSelfLink.put(rsp.documentSelfLink, updatedState); ctx.completeIteration(); }); this.host.sendRequest(patch); } }); this.host.sendRequest(post); } ctx.await(); this.host.waitForReplicatedFactoryChildServiceConvergence( getFactoriesPerNodeGroup(ExampleService.FACTORY_LINK), exampleStatesPerSelfLink, this.exampleStateConvergenceChecker, exampleStatesPerSelfLink.size(), this.updateCount, this.replicationFactor); }
@Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; }
NodeGroupService extends StatefulService { @Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; } }
NodeGroupService extends StatefulService { @Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; } NodeGroupService(); }
NodeGroupService extends StatefulService { @Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; } NodeGroupService(); @Override URI getUri(); @Override void handleStart(Operation startPost); @Override void handleGet(Operation get); @Override void handlePatch(Operation patch); @Override void handlePost(Operation post); @Override void handleMaintenance(Operation maint); void handleGossipPatchCompletion(long sendTimeMicros, Operation maint, Operation patch,
            Throwable e,
            NodeGroupState localState, NodeGroupState patchBody, AtomicInteger remaining,
            NodeState remotePeer); }
NodeGroupService extends StatefulService { @Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; } NodeGroupService(); @Override URI getUri(); @Override void handleStart(Operation startPost); @Override void handleGet(Operation get); @Override void handlePatch(Operation patch); @Override void handlePost(Operation post); @Override void handleMaintenance(Operation maint); void handleGossipPatchCompletion(long sendTimeMicros, Operation maint, Operation patch,
            Throwable e,
            NodeGroupState localState, NodeGroupState patchBody, AtomicInteger remaining,
            NodeState remotePeer); static final String STAT_NAME_JOIN_RETRY_COUNT; static final String STAT_NAME_REMOTE_FALSE_UNAVAILABLE_COUNT; static final String PROPERTY_NAME_PEER_REQUEST_TIMEOUT_MICROS; static final long PEER_REQUEST_TIMEOUT_MICROS; static final int MIN_PEER_GOSSIP_COUNT; static final String STAT_NAME_RESTARTING_SERVICES_COUNT; static final String STAT_NAME_RESTARTING_SERVICES_FAILURE_COUNT; static final String STAT_NAME_PREFIX_GOSSIP_PATCH_DURATION; }