@Test public void testMultiNodeNonReplicatedExpiration() throws Throwable { setUp(this.nodeCount); this.host.joinNodesAndVerifyConvergence(this.host.getPeerCount()); this.host.setNodeGroupQuorum(this.nodeCount); this.host.waitForNodeGroupConvergence(this.nodeCount); this.replicationTargetFactoryLink = NonPersistedExampleFactoryService.SELF_LINK; for (VerificationHost h : this.host.getInProcessHostMap().values()) { h.startServiceAndWait(NonPersistedExampleFactoryService.class, NonPersistedExampleFactoryService.SELF_LINK); } for (URI hostUri : this.host.getNodeGroupMap().keySet()) { waitForReplicatedFactoryServiceAvailable( UriUtils.buildUri(hostUri, this.replicationTargetFactoryLink), ServiceUriPaths.DEFAULT_NODE_SELECTOR); } VerificationHost targetHost = this.host.getPeerHost(); URI targetHostUri = targetHost.getUri(); Map<String, ExampleServiceState> initialStates = createExampleServices(targetHostUri); this.host.log(Level.INFO, "Waiting for %d services to replicate", initialStates.size()); for (URI hostUri : this.host.getNodeGroupMap().keySet()) { URI factoryUri = UriUtils.extendUri(hostUri, this.replicationTargetFactoryLink); this.host.waitFor("Services failed to replicate", () -> { ServiceDocumentQueryResult result = this.host.getServiceState( EnumSet.noneOf(TestProperty.class), ServiceDocumentQueryResult.class, factoryUri); return result.documentLinks.size() == initialStates.size(); }); } long expirationMicros = Utils.fromNowMicrosUtc(TimeUnit.MILLISECONDS.toMicros( this.host.maintenanceIntervalMillis)); ExampleServiceState patchBody = new ExampleServiceState(); patchBody.documentExpirationTimeMicros = expirationMicros; this.host.log(Level.INFO, "Patching expiration time on %d services", initialStates.size()); TestContext ctx = this.host.testCreate(initialStates.size()); for (String selfLink : initialStates.keySet()) { Operation patchOp = Operation.createPatch(targetHost, selfLink) .setBody(patchBody) .setReferer(this.host.getReferer()) .setCompletion(ctx.getCompletion()); this.host.send(patchOp); } ctx.await(); for (URI hostUri : this.host.getNodeGroupMap().keySet()) { URI factoryUri = UriUtils.extendUri(hostUri, this.replicationTargetFactoryLink); this.host.waitFor("Services failed to expire", () -> { ServiceDocumentQueryResult result = this.host.getServiceState( EnumSet.noneOf(TestProperty.class), ServiceDocumentQueryResult.class, factoryUri); this.host.log(Level.INFO, "Query response: %s", Utils.toJsonHtml(result)); return result.documentLinks.size() == 0; }); } }
@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; }