public void run(Runnable task) { run(this.executor, task); }
private void checkOperationExpiration(long now, Iterator<Operation> iterator) { while (iterator.hasNext()) { Operation op = iterator.next(); if (op == null || op.getExpirationMicrosUtc() > now) { // not expired, and since we walk in ascending order, no other operations // are expired break; } iterator.remove(); this.host.run(() -> op.fail(new TimeoutException(op.toString()))); } }
void processPendingServiceStartOperations(String link, ProcessingStage processingStage, Service s) { SortedSet<Operation> ops = removeServiceStartCompletions(link); if (ops == null || ops.isEmpty()) { return; } for (Operation op : ops) { if (processingStage == ProcessingStage.AVAILABLE) { this.host.run(() -> { if (op.getUri() == null) { op.setUri(s.getUri()); } if (op.hasPragmaDirective(Operation.PRAGMA_DIRECTIVE_POST_TO_PUT)) { this.host.restoreActionOnChildServiceToPostOnFactory(link, op); } op.complete(); }); } else { this.host.run(() -> op.fail(new IllegalStateException(op.toString()))); } } }
this.host.run(() -> { if (this.authToken != null) { this.host.populateAuthorizationContext(this.authToken, ServiceUriPaths.CORE_WEB_SOCKET_ENDPOINT, authCtx -> {
void scheduleServiceOptionToggleMaintenance(String path, EnumSet<ServiceOption> newOptions, EnumSet<ServiceOption> removedOptions) { Service s = findService(path); if (s == null || s.getProcessingStage() == ProcessingStage.STOPPED) { return; } ServiceMaintenanceRequest body = ServiceMaintenanceRequest.create(); body.reasons.add(MaintenanceReason.SERVICE_OPTION_TOGGLE); if (newOptions != null && newOptions.contains(ServiceOption.DOCUMENT_OWNER)) { body.reasons.add(MaintenanceReason.NODE_GROUP_CHANGE); s.adjustStat(Service.STAT_NAME_DOCUMENT_OWNER_TOGGLE_ON_MAINT_COUNT, 1); } if (removedOptions != null && removedOptions.contains(ServiceOption.DOCUMENT_OWNER)) { body.reasons.add(MaintenanceReason.NODE_GROUP_CHANGE); s.adjustStat(Service.STAT_NAME_DOCUMENT_OWNER_TOGGLE_OFF_MAINT_COUNT, 1); } if (body.reasons.contains(MaintenanceReason.NODE_GROUP_CHANGE)) { s.adjustStat(Service.STAT_NAME_NODE_GROUP_CHANGE_MAINTENANCE_COUNT, 1); } body.configUpdate = new ServiceConfigUpdateRequest(); body.configUpdate.addOptions = newOptions; body.configUpdate.removeOptions = removedOptions; run(() -> { OperationContext.setAuthorizationContext(getSystemAuthorizationContext()); s.handleMaintenance(Operation.createPost(s.getUri()).setBody(body)); }); }
@Override public FilterReturnCode processRequest(Operation op, OperationProcessingContext context) { context.setSuspendConsumer(o -> { this.service.getHost().run(() -> { this.service.handleRequest(op, OperationProcessingStage.EXECUTING_SERVICE_HANDLER); }); }); return FilterReturnCode.SUSPEND_PROCESSING; } }
@Override public FilterReturnCode processRequest(Operation op, OperationProcessingContext context) { context.setSuspendConsumer(o -> { this.service.getHost().run(() -> { this.service.handleRequest(op, OperationProcessingStage.EXECUTING_SERVICE_HANDLER); }); }); return FilterReturnCode.SUSPEND_PROCESSING; } }
&& service.hasOption(ServiceOption.FACTORY) && service.hasOption(ServiceOption.REPLICATION)) { run(() -> { NodeGroupUtils .registerForReplicatedServiceAvailability(this, opTemplate.getId(), opTemplate.getContextId()); final Operation opFinal = opTemplate; run(() -> { Operation o = getOperationForServiceAvailability(opFinal, link, doOpClone); o.complete(); run(() -> { NodeGroupUtils .registerForReplicatedServiceAvailability(this, o, link, nodeSelectorPath);
run(() -> { if (op.getUri() == null) { op.setUri(s.getUri());
.run(() -> { OperationContext.setAuthorizationContext(this.host .getSystemAuthorizationContext());
/** * Final stage of operation completion processing. Notifications will be published and client * will receive operation response */ private void processCompletionStagePublishAndComplete(Operation op) { if (hasOption(ServiceOption.INSTRUMENTATION)) { updatePerOperationStats(op); } if (op.getAction() == Action.GET && !isIndexed()) { op.linkState(null); // run completions in parallel since non indexed GETs are serialized with updates getHost().run(op::complete); return; } publish(op); if (op.isFromReplication() && !op.isSynchronizeOwner()) { // avoid cost of sending the request body as a response op.setBodyNoCloning(null); } op.complete(); }
context.getHost().run(() -> { checkAndOnDemandStartService(op, finalServicePath, (FactoryService) parentService, context); });