@RouteDocumentation(requestBodyType = ServiceConfigUpdateRequest.class, description = "just test that " + "requestBodyType is propagated") @Override public void handlePatch(Operation patch) { patch.fail(new UnsupportedOperationException("not implemented")); } }
@RouteDocumentation(requestBodyType = ServiceConfigUpdateRequest.class, description = "just test that " + "requestBodyType is propagated") @Override public void handlePatch(Operation patch) { patch.fail(new UnsupportedOperationException("not implemented")); } }
@RouteDocumentation( description = "Join a peer to this node group", requestBodyType = JoinPeerRequest.class)
/** * Shutdown the host. * * When host is the process owner, {@code System.exit(0);} is called at the end. */ @RouteDocumentation(description = "Shuts down this host. If the host is the process owner then the process" + " is terminated with exit code 0.") @Override public void handleDelete(Operation delete) { logInfo("Received shutdown request from %s", delete.getReferer()); boolean isProcessOwner = getHost().isProcessOwner(); // DELETE to this service causes a graceful host shutdown. // Because shut down can take several seconds on an active system // we complete the operation right away, and the remote client relies // on polling to determine when we really went down. That is the safest // option anyway, for clients that really do care delete.setStatusCode(Operation.STATUS_CODE_ACCEPTED); delete.complete(); getHost().stop(); if (isProcessOwner) { System.exit(0); } else { logInfo("This host is NOT the process owner. Skipping System.exit()"); } }
@Override @RouteDocumentation(description = "@PUT") public void handlePut(Operation put) { ExampleServiceState newState = getBody(put); ExampleServiceState currentState = getState(put); // example of structural validation: check if the new state is acceptable if (currentState.name != null && newState.name == null) { put.fail(new IllegalArgumentException("name must be set")); return; } updateCounter(newState, currentState, false); // replace current state, with the body of the request, in one step setState(put, newState); put.complete(); }
@RouteDocumentation( description = "Describe this host.", responses = { @ApiResponse(statusCode = 200, description = "OK", response = ServiceHostState.class) }) @Override public void handleGet(Operation get) { getHost().updateSystemInfo(false); ServiceHostState s = getHost().getState(); s.documentSelfLink = getSelfLink(); s.documentKind = Utils.buildKind(ServiceHostState.class); s.documentUpdateTimeMicros = Utils.getNowMicrosUtc(); get.setBody(s).complete(); }
@RouteDocumentation( path = "/users/{user}", pathParams = { @PathParam(name = "user", description = "The user id") }) @RouteDocumentation( path = "/tenants/{tenant}", pathParams = { @PathParam(name = "tenant", description = "The user id") }) @Override public void handleGet(Operation get) { get.fail(new UnsupportedOperationException("not implemented")); }
@RouteDocumentation( path = "/users/{user}", pathParams = { @PathParam(name = "user", description = "The user id") }) @RouteDocumentation( path = "/tenants/{tenant}", pathParams = { @PathParam(name = "tenant", description = "The user id") }) @Override public void handleGet(Operation get) { get.fail(new UnsupportedOperationException("not implemented")); }
@RouteDocumentation(description = "Delete this service instance") public void handleDelete(Operation delete) { delete.complete(); }
@RouteDocumentation(supportLevel = SupportLevel.NOT_SUPPORTED) public void handlePost(Operation post) { Operation.failActionNotSupported(post); }
@RouteDocumentation(supportLevel = SupportLevel.NOT_SUPPORTED) public void handlePut(Operation put) { Operation.failActionNotSupported(put); }
@RouteDocumentation(supportLevel = SupportLevel.NOT_SUPPORTED) public void handlePost(Operation post) { Operation.failActionNotSupported(post); }
@RouteDocumentation(supportLevel = SupportLevel.NOT_SUPPORTED) public void handlePatch(Operation patch) { Operation.failActionNotSupported(patch); }
@RouteDocumentation(supportLevel = SupportLevel.NOT_SUPPORTED) public void handlePatch(Operation patch) { Operation.failActionNotSupported(patch); }
@Override @RouteDocumentation(description = "Update selected fields of example document") public void handlePatch(Operation patch) { updateState(patch); // updateState method already set the response body with the merged state patch.complete(); }
@RouteDocumentation(description = "Read the service document") public void handleGet(Operation get) { if (!hasPendingTransactions()) { handleGetSimple(get); return; } handleGetWithinTransaction(this, get, this::handleGetSimple, this::failRequest, getHost().getSystemAuthorizationContext()); }
/** * Replace current state, with the body of the request, in one step */ @RouteDocumentation(description = "Replace current state with the body of the request") public void handlePut(Operation put) { ServiceDocument newState = put.getBody(this.context.stateType); setState(put, newState); put.complete(); }