@Test public void patchDeleteThenPost() throws Throwable { int nodeCount = 3; this.host.setPeerSynchronizationEnabled(true); this.host.setUpPeerHosts(nodeCount); this.host.joinNodesAndVerifyConvergence(nodeCount, true); this.host.setNodeGroupQuorum(nodeCount); for (VerificationHost host : this.host.getInProcessHostMap().values()) { host.waitForServiceAvailable(ExampleService.FACTORY_LINK); } TestRequestSender sender = this.host.getTestRequestSender(); VerificationHost targetHost = this.host.getPeerHost(); List<Operation> posts = new ArrayList<>(); List<Operation> patches = new ArrayList<>(); List<Operation> deletes = new ArrayList<>(); List<Operation> newPosts = new ArrayList<>(); List<Operation> gets = new ArrayList<>(); for (int i = 0; i < this.serviceCount; i++) { String name = "doc-" + i; String selfLink = UriUtils.buildUriPath(ExampleService.FACTORY_LINK, name); ExampleServiceState doc = new ExampleServiceState(); doc.name = name; doc.documentSelfLink = selfLink; posts.add(Operation.createPost(targetHost, ExampleService.FACTORY_LINK).setBody(doc)); doc.name += "-patch"; patches.add(Operation.createPatch(targetHost, selfLink) .setBody(doc)); deletes.add(Operation.createDelete(targetHost, selfLink) .addRequestHeader(Operation.REPLICATION_QUORUM_HEADER, Operation.REPLICATION_QUORUM_HEADER_VALUE_ALL) ); for (VerificationHost host : this.host.getInProcessHostMap().values()) { gets.add(Operation.createGet(host, selfLink).addPragmaDirective(PRAGMA_DIRECTIVE_NO_FORWARDING)); } doc = new ExampleServiceState(); doc.name = name + "-new-post"; doc.documentSelfLink = selfLink; newPosts.add(Operation.createPost(targetHost, ExampleService.FACTORY_LINK) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FORCE_INDEX_UPDATE) .setBody(doc) ); } sender.sendAndWait(posts); sender.sendAndWait(patches); sender.sendAndWait(deletes); for (Operation get : gets) { FailureResponse res = sender.sendAndWaitFailure(get); assertEquals("service should be deleted. uri=" + get.getUri(), 404, res.op.getStatusCode()); } sender.sendAndWait(newPosts); }
@Override public URI getUri() { if (this.context.host == null) { return null; } return UriUtils.buildUri(this.context.host, this.context.selfLink); }
StatefulService implements Service { @Override public URI getUri() { if (this.context.host == null) { return null; } return UriUtils.buildUri(this.context.host, this.context.selfLink); } }
StatefulService implements Service { @Override public URI getUri() { if (this.context.host == null) { return null; } return UriUtils.buildUri(this.context.host, this.context.selfLink); } StatefulService(Class<? extends ServiceDocument> stateType);  StatefulService(Class<? extends ServiceDocument> stateType,
            EnumSet<ServiceOption> options); }
StatefulService implements Service { @Override public URI getUri() { if (this.context.host == null) { return null; } return UriUtils.buildUri(this.context.host, this.context.selfLink); } StatefulService(Class<? extends ServiceDocument> stateType);  StatefulService(Class<? extends ServiceDocument> stateType,
            EnumSet<ServiceOption> options); @Override OperationProcessingChain getOperationProcessingChain(); @Override Service.ProcessingStage getProcessingStage(); @Override void handleCreate(Operation post); @Override void handleStart(Operation post); @Override void authorizeRequest(Operation op); @Override boolean queueRequest(Operation op); @Override void handleRequest(Operation request); @Override void handleRequest(Operation request, OperationProcessingStage opProcessingStage); void handlePost(Operation post); void handleDelete(Operation delete); @Override void handleStop(Operation delete); void handlePatch(Operation patch); void handleOptions(Operation options); void handlePut(Operation put); void handleGet(Operation get); @Override Operation dequeueRequest(); @Override void setStat(String name, double newValue); @Override void setStat(ServiceStat s, double newValue); @Override void adjustStat(ServiceStat s, double delta); @Override void adjustStat(String name, double delta); @Override ServiceStat getStat(String name); ServiceStat getStat(String name, boolean create); @Override String getSelfLink(); @Override URI getUri(); @Override ServiceHost getHost(); @Override boolean hasOption(Service.ServiceOption cap); @Override void toggleOption(ServiceOption option, boolean enable); @Override void setSelfLink(String path); @Override void setHost(ServiceHost serviceHost); @Override void setOperationProcessingChain(OperationProcessingChain opProcessingChain); @Override void setProcessingStage(ProcessingStage stage); @Override Service getUtilityService(String uriPath, boolean allocate); @Override void sendRequest(Operation op); ServiceDocumentDescription getStateDescription(); @Override ServiceStats getStats(); @Override ServiceDocument getDocumentTemplate(); void logSevere(Throwable e); void logSevere(String fmt, Object... args); void logSevere(Supplier<String> messageSupplier); void logInfo(String fmt, Object... args); void logInfo(Supplier<String> messageSupplier); void logFine(String fmt, Object... args); void logFine(Supplier<String> messageSupplier); void logWarning(String fmt, Object... args); void logWarning(Supplier<String> messageSupplier); void log(Level level, String fmt, Object... args); void log(Level level, Supplier<String> messageSupplier); @Override void handleMaintenance(Operation post); void handlePeriodicMaintenance(Operation post); void handleNodeGroupMaintenance(Operation post); @Override ServiceDocument setInitialState(Object state, Long version); @Override String getPeerNodeSelectorPath(); @Override void setPeerNodeSelectorPath(String link); @Override String getDocumentIndexPath(); @Override void setDocumentIndexPath(String link); @Override EnumSet<ServiceOption> getOptions(); @Override void setState(Operation op, ServiceDocument newState); @SuppressWarnings("unchecked") @Override T getState(Operation op); void setAvailable(boolean isAvailable); boolean isAvailable(); @Override void setMaintenanceIntervalMicros(long micros); @Override void setCacheClearDelayMicros(long micros); @Override long getMaintenanceIntervalMicros(); @Override long getCacheClearDelayMicros(); @Override Class<? extends ServiceDocument> getStateType(); @Override void handleConfigurationRequest(Operation request); @Override final void setAuthorizationContext(Operation op, AuthorizationContext ctx); final Signer getTokenSigner(); @Override final AuthorizationContext getSystemAuthorizationContext(); final AuthorizationContext getAuthorizationContextForSubject(String subject); }
StatefulService implements Service { @Override public URI getUri() { if (this.context.host == null) { return null; } return UriUtils.buildUri(this.context.host, this.context.selfLink); } StatefulService(Class<? extends ServiceDocument> stateType);  StatefulService(Class<? extends ServiceDocument> stateType,
            EnumSet<ServiceOption> options); @Override OperationProcessingChain getOperationProcessingChain(); @Override Service.ProcessingStage getProcessingStage(); @Override void handleCreate(Operation post); @Override void handleStart(Operation post); @Override void authorizeRequest(Operation op); @Override boolean queueRequest(Operation op); @Override void handleRequest(Operation request); @Override void handleRequest(Operation request, OperationProcessingStage opProcessingStage); void handlePost(Operation post); void handleDelete(Operation delete); @Override void handleStop(Operation delete); void handlePatch(Operation patch); void handleOptions(Operation options); void handlePut(Operation put); void handleGet(Operation get); @Override Operation dequeueRequest(); @Override void setStat(String name, double newValue); @Override void setStat(ServiceStat s, double newValue); @Override void adjustStat(ServiceStat s, double delta); @Override void adjustStat(String name, double delta); @Override ServiceStat getStat(String name); ServiceStat getStat(String name, boolean create); @Override String getSelfLink(); @Override URI getUri(); @Override ServiceHost getHost(); @Override boolean hasOption(Service.ServiceOption cap); @Override void toggleOption(ServiceOption option, boolean enable); @Override void setSelfLink(String path); @Override void setHost(ServiceHost serviceHost); @Override void setOperationProcessingChain(OperationProcessingChain opProcessingChain); @Override void setProcessingStage(ProcessingStage stage); @Override Service getUtilityService(String uriPath, boolean allocate); @Override void sendRequest(Operation op); ServiceDocumentDescription getStateDescription(); @Override ServiceStats getStats(); @Override ServiceDocument getDocumentTemplate(); void logSevere(Throwable e); void logSevere(String fmt, Object... args); void logSevere(Supplier<String> messageSupplier); void logInfo(String fmt, Object... args); void logInfo(Supplier<String> messageSupplier); void logFine(String fmt, Object... args); void logFine(Supplier<String> messageSupplier); void logWarning(String fmt, Object... args); void logWarning(Supplier<String> messageSupplier); void log(Level level, String fmt, Object... args); void log(Level level, Supplier<String> messageSupplier); @Override void handleMaintenance(Operation post); void handlePeriodicMaintenance(Operation post); void handleNodeGroupMaintenance(Operation post); @Override ServiceDocument setInitialState(Object state, Long version); @Override String getPeerNodeSelectorPath(); @Override void setPeerNodeSelectorPath(String link); @Override String getDocumentIndexPath(); @Override void setDocumentIndexPath(String link); @Override EnumSet<ServiceOption> getOptions(); @Override void setState(Operation op, ServiceDocument newState); @SuppressWarnings("unchecked") @Override T getState(Operation op); void setAvailable(boolean isAvailable); boolean isAvailable(); @Override void setMaintenanceIntervalMicros(long micros); @Override void setCacheClearDelayMicros(long micros); @Override long getMaintenanceIntervalMicros(); @Override long getCacheClearDelayMicros(); @Override Class<? extends ServiceDocument> getStateType(); @Override void handleConfigurationRequest(Operation request); @Override final void setAuthorizationContext(Operation op, AuthorizationContext ctx); final Signer getTokenSigner(); @Override final AuthorizationContext getSystemAuthorizationContext(); final AuthorizationContext getAuthorizationContextForSubject(String subject);  }