@Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { ctx.channel().close(); } ctx.channel() .closeFuture() .addListener(f -> { for (java.util.Map.Entry<URI, Set<String>> e : NettyWebSocketRequestHandler.this.serviceSubscriptions .entrySet()) { WebSocketService svc = NettyWebSocketRequestHandler.this.webSocketServices .get(e.getKey()); if (svc != null) { deleteServiceSubscriptions(svc); } NettyWebSocketRequestHandler.this.host.stopService(svc); } }); } });
@Override public void handleMaintenance(Operation op) { op.complete(); getHost().stopService(this); }
@Override public void handleMaintenance(Operation op) { op.complete(); // This service only lives as long as its parent QueryTask getHost().stopService(this); }
public void handleDeleteImpl(Operation delete) throws Exception { setProcessingStage(ProcessingStage.STOPPED); this.privateIndexingExecutor.shutdown(); this.privateQueryExecutor.shutdown(); getHost().stopService(this); delete.complete(); }
@Override public void handlePeriodicMaintenance(Operation op) { op.complete(); // This service only lives as long as its parent QueryTask getHost().stopService(this); }
/** * Stops the service */ protected void handleStopCompletion(Operation op) { getHost().stopService(this); op.complete(); }
public void handleDeleteImpl(Operation delete) throws Exception { setProcessingStage(ProcessingStage.STOPPED); this.privateIndexingExecutor.shutdown(); this.privateQueryExecutor.shutdown(); IndexWriter w = this.writer; this.writer = null; close(w); this.getHost().stopService(this); delete.complete(); }
private void handleStopCompletion(Operation op) { if (checkServiceStopped(op, true)) { return; } getHost().stopService(this); op.complete(); }
@Override public void handleDelete(Operation delete) { for (Service childService : childServices) { // delete child service as well getHost().stopService(childService); } super.handleDelete(delete); }
@Override public void handleDelete(Operation delete) { for (Service childService : childServices) { // delete child service as well getHost().stopService(childService); } super.handleDelete(delete); }
@Override public void handleDelete(Operation delete) { for (Service childService : childServices) { // delete child service as well getHost().stopService(childService); } super.handleDelete(delete); }
private void stopCoreServices() { int coreServiceCount = this.coreServices.size(); final CountDownLatch cLatch = new CountDownLatch(coreServiceCount); final Operation.CompletionHandler c = (o, e) -> { cLatch.countDown(); }; // now do core service shutdown in parallel for (String coreServiceLink : this.coreServices) { AttachedServiceInfo coreServiceInfo = this.attachedServices.get(coreServiceLink); Service coreService = coreServiceInfo != null ? coreServiceInfo.service : null; if (coreService == null || coreService instanceof ServiceHostManagementService) { // a DELETE to the management service will cause a recursive stop() c.handle(null, null); continue; } sendServiceStop(c, coreService); } log(Level.INFO, "Waiting for DELETE from %d core services", coreServiceCount); this.coreServices.clear(); waitForServiceStop(cLatch); // stopping management service Service managementService = getManagementService(); if (managementService != null && managementService.getSelfLink() != null) { stopService(managementService); } log(Level.INFO, "All core services stopped"); }
service.setCompletionCallback(() -> getHost().stopService(service)); getHost().startService(startPost, service);
private void scheduleTaskExpiration(QueryTask task) { if (task.taskInfo.isDirect) { getHost().stopService(this); return; } if (getHost().isStopping()) { return; } Operation delete = Operation.createDelete(getUri()).setBody(new ServiceDocument()); long delta = task.documentExpirationTimeMicros - Utils.getSystemNowMicrosUtc(); delta = Math.max(1, delta); getHost().scheduleCore(() -> { if (task.querySpec.options.contains(QueryOption.CONTINUOUS) || task.querySpec.options.contains(QueryOption.CONTINUOUS_STOP_MATCH)) { cancelContinuousQueryOnIndex(task); } sendRequest(delete); }, delta, TimeUnit.MICROSECONDS); }
service.setCompletionCallback(() -> serviceHost.stopService(service)); serviceHost.startService(startPost, service);
private boolean handleDeleteCompletion(Operation op) { if (op.isFromReplication() && hasOption(ServiceOption.OWNER_SELECTION)) { if (!op.isCommit()) { return false; } } if (checkServiceStopped(op, true)) { return true; } // DELETE completion runs when a DELETE was issued by a client, not local host shutdown. // It needs to stop the service now, since the handleDelete() and handleStop() handlers // have already run. getHost().markAsPendingDelete(this); getHost().stopService(this); return false; }
private void startAndCreateCallbackHandlerService( BiConsumer<CallbackServiceHandlerState, ServiceErrorResponse> actualCallback, Consumer<ServiceTaskCallback> caller) { if (actualCallback == null) { caller.accept(ServiceTaskCallback.createEmpty()); return; } CallbackServiceHandlerState body = new CallbackServiceHandlerState(); String callbackLink = ManagementUriParts.REQUEST_CALLBACK_HANDLER_TASKS + UUID.randomUUID().toString(); body.documentSelfLink = callbackLink; URI callbackUri = UriUtils.buildUri(getHost(), callbackLink); Operation startPost = Operation .createPost(callbackUri) .setAuthorizationContext(getSystemAuthorizationContext()) .setBodyNoCloning(body) .setCompletion((o, e) -> { if (e != null) { logWarning("Failure creating callback handler. Error %s", Utils.toString(e)); return; } logInfo("Callback task created with uri: %s, %s", callbackUri, o.getUri()); caller.accept(ServiceTaskCallback.create(callbackUri.toString())); }); HostInfoUpdatedCallbackHandler service = new HostInfoUpdatedCallbackHandler(actualCallback); service.setCompletionCallback(() -> getHost().stopService(service)); getHost().startService(startPost, service); }
@Override public void handleGet(Operation get) { ServiceDocument emptyDoc = new ServiceDocument(); // stop this service to simulate the case that op has returned but target service is not in attachedService. getHost().stopService(this); // return a doc that doesn't have documentKind get.setBody(Utils.toJson(emptyDoc)).complete(); } };
boolean singleUse = task.querySpec.options.contains(QueryOption.SINGLE_USE); if (singleUse) { getHost().stopService(this);
boolean singleUse = task.querySpec.options.contains(QueryOption.SINGLE_USE); if (singleUse) { getHost().stopService(this);