public PKSAdapterService() { super(); super.toggleOption(ServiceOption.PERIODIC_MAINTENANCE, true); super.toggleOption(ServiceOption.INSTRUMENTATION, true); super.setMaintenanceIntervalMicros(MAINTENANCE_INTERVAL_MICROS); }
@Override public void handleStart(Operation startPost) { super.handleStart(startPost); // initialize pks client initClient(); }
@Override public void handleRequest(Operation op) { handleRequest(op, OperationProcessingStage.PROCESSING_FILTERS); }
/** * Value indicating whether GET on /available returns 200 or 503 * The method is a convenience method since it relies on STAT_NAME_AVAILABLE to report * availability. */ public void setAvailable(boolean isAvailable) { this.toggleOption(ServiceOption.INSTRUMENTATION, true); this.setStat(STAT_NAME_AVAILABLE, isAvailable ? STAT_VALUE_TRUE : STAT_VALUE_FALSE); }
/** * Runs after a DELETE operation, that is not a service stop, completes. * It guarantees that the handleStop handler will execute next, and the shared * completion that stops the service will run after the stop operation is completed */ protected void handleDeleteCompletion(Operation op) { op.nestCompletion((o) -> { handleStopCompletion(op); }); handleStop(op); }
public LuceneDocumentIndexService(String indexDirectory) { super(ServiceDocument.class); super.toggleOption(ServiceOption.CORE, true); super.toggleOption(ServiceOption.PERIODIC_MAINTENANCE, true); this.indexDirectory = indexDirectory; }
try { if (opProcessingStage == OperationProcessingStage.PROCESSING_FILTERS) { OperationProcessingChain opProcessingChain = getOperationProcessingChain(); if (opProcessingChain != null) { OperationProcessingContext context = opProcessingChain.createContext(getHost()); context.setService(this); opProcessingChain.processRequest(op, context, o -> { handleRequest(op, OperationProcessingStage.EXECUTING_SERVICE_HANDLER); }); return; handleGet(op); return; handleGetCompletion(op); }); handleGet(op); } else if (op.getAction() == Action.POST) { handlePost(op); } else if (op.getAction() == Action.DELETE) { if (ServiceHost.isForServiceNamespace(this, op)) { handleDelete(op); return; handleStopCompletion(op); }); handleStop(op); } else {
public NodeSelectorForwardingService(ConsistentHashingNodeSelectorService parent) { super(ServiceDocument.class); super.toggleOption(ServiceOption.UTILITY, true); this.parent = parent; super.setSelfLink(UriUtils.buildUriPath(this.parent.getSelfLink(), ServiceUriPaths.SERVICE_URI_SUFFIX_FORWARDING)); }
@Override public ServiceDocument getDocumentTemplate() { ServiceDocument d = super.getDocumentTemplate(); addServiceRequestRoute(d, Action.GET, String.format("Get container logs. Provide the ContainerState id in URI query " + "parameter with key \"%s\".", CONTAINER_ID_QUERY_PARAM), LogServiceState.class); return d; }
@Override public void handleStart(final Operation post) { super.setMaintenanceIntervalMicros(getHost().getMaintenanceIntervalMicros() * 5); this.uri = super.getUri();
@Override public void handleStart(final Operation post) { super.setMaintenanceIntervalMicros(getHost().getMaintenanceIntervalMicros() * 5); // index service getUri() will be invoked on every load and save call for every operation, // so its worth caching (plus we only have a very small number of index services this.uri = post.getUri(); ExecutorService es = new ThreadPoolExecutor(QUERY_THREAD_COUNT, QUERY_THREAD_COUNT, 1, TimeUnit.MINUTES, new ArrayBlockingQueue<>(QUERY_EXECUTOR_WORK_QUEUE_CAPACITY), new NamedThreadFactory(getUri() + "/queries")); this.privateQueryExecutor = TracingExecutor.create(es, getHost().getTracer()); es = new ThreadPoolExecutor(UPDATE_THREAD_COUNT, UPDATE_THREAD_COUNT, 1, TimeUnit.MINUTES, new ArrayBlockingQueue<>(UPDATE_EXECUTOR_WORK_QUEUE_CAPACITY), new NamedThreadFactory(getUri() + "/updates")); this.privateIndexingExecutor = TracingExecutor.create(es, getHost().getTracer()); post.complete(); }
@Override public void authorizeRequest(Operation op) { if (ConfigurationUtil.isEmbedded()) { op.complete(); return; } super.authorizeRequest(op); }
@Override public void handleStop(Operation delete) { initialized.set(false); super.handleStop(delete); }
public NodeSelectorSynchronizationService(Service parent) { super(NodeGroupSynchronizationState.class); super.toggleOption(ServiceOption.UTILITY, true); this.parent = parent; }
@Override public ServiceDocument getDocumentTemplate() { ServiceDocument d = super.getDocumentTemplate(); addServiceRequestRoute(d, Action.PUT, "Add container host. If host is added successfully, it's reference can be " + "acquired from \"Location\" response header.", null); return d; } }
@Override public void authorizeRequest(Operation op) { if (ConfigurationUtil.isEmbedded()) { op.complete(); return; } super.authorizeRequest(op); }
@Override public void handleStop(Operation delete) { if (serviceClientNoProxy != null) { serviceClientNoProxy.stop(); } if (serviceClientProxy != null) { serviceClientProxy.stop(); } super.handleStop(delete); }
public EpzComputeEnumerationPeriodicService() { super.toggleOption(ServiceOption.PERIODIC_MAINTENANCE, true); super.toggleOption(ServiceOption.PERSISTENCE, false); super.setMaintenanceIntervalMicros(MAINTENANCE_INTERVAL_MICROS); }
public MaintenanceProxyService(Consumer<Operation> parentHandler) { super.toggleOption(ServiceOption.CORE, true); super.toggleOption(ServiceOption.PERIODIC_MAINTENANCE, true); this.parentHandler = parentHandler; }
@Override public void handleRequest(Operation op) { if (!op.isNotification()) { super.handleRequest(op); return; } this.consumer.accept(op); }