Refine search
@Override public void handleStart(Operation start) { if (!start.hasBody()) { start.fail(new IllegalStateException("no body given")); return; } LocalFileServiceState state = start.getBody(LocalFileServiceState.class); if (state.localFileUri == null) { start.fail(new IllegalStateException("file scheme uri is required")); return; } start.complete(); }
private CheckpointState validateState(Operation op) { if (!op.hasBody()) { op.fail(new IllegalArgumentException("initial state is required")); return null; } CheckpointState body = op.getBody(CheckpointState.class); if (body.timestamp == null) { op.fail(new IllegalArgumentException("timestamp is required")); return null; } return body; }
@Override public void handlePost(Operation post) { if (!post.hasBody()) { Operation.failActionNotSupported(post); return; } QueryRequest body = post.getBody(QueryRequest.class); if (!QueryRequest.KIND.equals(body.kind)) { post.fail(new IllegalArgumentException("kind is not recognized")); return; } EnumSet<ServiceOption> options = EnumSet.of(ServiceOption.FACTORY); getHost().queryServiceUris(options, false, post); } }
@Override public void handleStart(Operation post) { if (!post.hasBody()) { post.fail(new IllegalArgumentException("body is required")); return; } TenantState newState = post.getBody(TenantState.class); if (newState.id == null || newState.id.isEmpty()) { newState.id = UUID.randomUUID().toString(); } post.setBody(newState).complete(); }
@Override public void handleDelete(Operation delete) { if (!delete.hasBody()) { delete.complete(); return; } // A DELETE can be used to both stop the service, mark it deleted in the index // so its excluded from queries, but it can also set its expiration so its state // history is permanently removed ExampleServiceState currentState = getState(delete); ExampleServiceState st = delete.getBody(ExampleServiceState.class); if (st.documentExpirationTimeMicros > 0) { currentState.documentExpirationTimeMicros = st.documentExpirationTimeMicros; } delete.complete(); }
@Override public void handlePatch(Operation patch) { if (!patch.hasBody()) { patch.fail(new IllegalArgumentException("Body is required")); return; } ServiceDocument s = patch.getBody(ServiceDocument.class); if (s.documentKind == null) { patch.fail(new IllegalArgumentException("Kind is required")); return; } if (UpdateReplicationQuorumRequest.KIND.equals(s.documentKind)) { updateReplicationQuorum(patch, patch.getBody(UpdateReplicationQuorumRequest.class)); return; } patch.fail(new IllegalArgumentException("Unexpected request kind " + s.documentKind)); }
@Override public void handlePost(Operation op) { if (op.hasBody()) { ServiceDocument body = op.getBody(this.stateType); if (body == null) { op.fail(new IllegalArgumentException("structured body is required")); return; } if (body.documentSourceLink != null) { op.fail(new IllegalArgumentException("clone request not supported")); return; } } // the real work is done in the completion op.complete(); }
@Override public void handleStart(Operation op) { if (op.hasBody()) { LoaderServiceState s = op.getBody(LoaderServiceState.class); if (s.loaderType == null) { s.loaderType = LoaderType.FILESYSTEM; } logFine("Initial path is %s", s.path); } super.setMaintenanceIntervalMicros(MAINTENANCE_INTERVAL_MICROS); op.complete(); }
@Override public void handlePost(Operation post) { if (!post.hasBody()) { post.fail(new IllegalArgumentException("body is required")); return; } AuthContentBody body = post.getBody(AuthContentBody.class); if (body == null) { post.fail(new IllegalArgumentException("body not supported")); return; } if (body.roles != null && !body.roles.isEmpty()) { handleRoles(body, post); return; } handleProjects(body, post); }
@Override public void handlePost(Operation op) { logFine("Post called"); if (!op.hasBody()) { op.fail(new IllegalArgumentException("body is required")); return; } LoaderServiceState localState = getState(op); if (localState == null || localState.loaderType == null || localState.path == null) { op.fail(new IllegalStateException("Service state is null or invalid")); return; } // Acknowledge the request and complete the operation before actual loading op.setStatusCode(Operation.STATUS_CODE_ACCEPTED).complete(); loadServices(localState); }