/** * Create a default factory service that starts instances of this task service on POST. */ public static FactoryService createFactory() { return TaskFactoryService.create(ExampleTaskService.class, ServiceOption.IDEMPOTENT_POST, ServiceOption.INSTRUMENTATION); }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService(ResourceEnumerationTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new ResourceEnumerationTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
ServiceStat st = getStat(STAT_NAME_ACTIVE_SUBSCRIPTION_COUNT); if (st != null && st.latestValue < 0) { setStat(STAT_NAME_ACTIVE_SUBSCRIPTION_COUNT, 0); .setCompletion((so, e) -> { if (e == null) { adjustStat(STAT_NAME_ACTIVE_SUBSCRIPTION_COUNT, 1); return; stopInDirectTaskSubscription(subscribe, nOp.getUri()); stopInDirectTaskSubscription(subscribe, nOp.getUri()); } else { if (this.hasChildOption(ServiceOption.OWNER_SELECTION)) { ReliableSubscriptionService notificationTarget = ReliableSubscriptionService.create( subscribe, sr, notifyC); getHost().startSubscriptionService(subscribe, notificationTarget, sr); } else { getHost().startSubscriptionService(subscribe, notifyC, sr);
private void stopInDirectTaskSubscription(Operation sub, URI notificationTarget) { if (getHost().getServiceStage(notificationTarget.getPath()) != ProcessingStage.AVAILABLE) { adjustStat(STAT_NAME_ACTIVE_SUBSCRIPTION_COUNT, -1); return; } getHost().stopSubscriptionService( sub.clone().setAction(Action.DELETE).setCompletion((o, e) -> { if (e != null) { return; } adjustStat(STAT_NAME_ACTIVE_SUBSCRIPTION_COUNT, -1); }), notificationTarget); }
@Override public void handleRequest(Operation op, OperationProcessingStage opProcessingStage) { opProcessingStage = OperationProcessingStage.EXECUTING_SERVICE_HANDLER; boolean isIdempotentPut = (op.getAction() == Action.PUT) && op.hasPragmaDirective(Operation.PRAGMA_DIRECTIVE_POST_TO_PUT); if (op.getAction() != Action.POST && !isIdempotentPut) { super.handleRequest(op, opProcessingStage); return; } if (!op.hasBody()) { op.fail(new IllegalArgumentException("body is required")); return; } TaskServiceState initState = (TaskServiceState) op.getBody(super.getStateType()); if (initState.taskInfo == null || !initState.taskInfo.isDirect) { super.handleRequest(op, opProcessingStage); return; } // handle only direct request from a client, not forwarded or replicated requests, to avoid // duplicate processing if (op.isFromReplication() || op.isForwarded()) { super.handleRequest(op, opProcessingStage); return; } handleDirectTaskPost(op, initState); }
public static FactoryService createFactory() { return TaskFactoryService.create(TaskDemoService.class); }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService(EndpointResourceDeletionRequest.class) { @Override public Service createServiceInstance() throws Throwable { return new ResourceGroomerTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
/** * Creates meta-data for a task service. It is a shortcut to * <code>factoryService(serviceClass, () -> TaskFactoryService.create(serviceClass))</code>. * * @return cached ServiceMetadata * * @see TaskFactoryService */ public static ServiceMetadata taskService(Class<? extends Service> serviceClass) { return factoryService(serviceClass, () -> TaskFactoryService.create(serviceClass)); }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService( SingleResourceStatsCollectionTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new SingleResourceStatsCollectionTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
public static void handleStartDocumentIndexService(ServiceHost host, Service documentIndexService, NodeSelectorService defaultNodeSelectorService, StartCoreServicesSynchronouslyHandler startCoreServicesSynchronously) throws Throwable { Service[] queryServiceArray = new Service[] { documentIndexService, new QueryTaskFactoryService() { @Override public void handlePost(Operation post) { updateQueryTask(post); super.handlePost(post); } }, new LocalQueryTaskFactoryService() { @Override public void handlePost(Operation post) { updateQueryTask(post); super.handlePost(post); } }, TaskFactoryService.create(GraphQueryTaskService.class), TaskFactoryService.create(SynchronizationTaskService.class), new QueryPageForwardingService(defaultNodeSelectorService) }; startCoreServicesSynchronously.accept(queryServiceArray); }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService( SingleResourceStatsAggregationTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new SingleResourceStatsAggregationTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
SshCommandTaskService.createFactory()); host.startFactory(ResourceAllocationTaskService.class, () -> TaskFactoryService.create(ResourceAllocationTaskService.class)); host.startFactory(ResourceEnumerationTaskService.class, () -> ResourceEnumerationTaskService.createFactory()); () -> ImageEnumerationTaskService.createFactory()); host.startFactory(ScheduledTaskService.class, () -> TaskFactoryService.create(ScheduledTaskService.class)); host.startFactory(ResourceRemovalTaskService.class, () -> TaskFactoryService.create(ResourceRemovalTaskService.class)); host.startFactory(ProvisionComputeTaskService.class, () -> TaskFactoryService.create(ProvisionComputeTaskService.class)); host.startFactory(ProvisionNetworkTaskService.class, () -> TaskFactoryService.create(ProvisionNetworkTaskService.class)); host.startFactory(ProvisionSubnetTaskService.class, () -> TaskFactoryService.create(ProvisionSubnetTaskService.class)); host.startFactory(ProvisionLoadBalancerTaskService.class, () -> TaskFactoryService.create(ProvisionLoadBalancerTaskService.class)); host.startFactory(SnapshotTaskService.class, () -> TaskFactoryService.create(SnapshotTaskService.class)); host.startFactory(ProvisionSecurityGroupTaskService.class, () -> TaskFactoryService.create(ProvisionSecurityGroupTaskService.class)); host.startFactory(EndpointAllocationTaskService.class, () -> TaskFactoryService.create(EndpointAllocationTaskService.class)); host.startFactory(EndpointRemovalTaskService.class, () -> TaskFactoryService.create(EndpointRemovalTaskService.class)); host.startFactory(SingleResourceStatsAggregationTaskService.class, () -> SingleResourceStatsAggregationTaskService.createFactory());
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService( SingleResourceStatsCollectionTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new SingleResourceStatsCollectionTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
/** * Start document index service. Allow to override the loading of the core query services. */ protected void startDocumentIndexService(Service documentIndexService, NodeSelectorService defaultNodeSelectorService) throws Throwable { if (documentIndexService instanceof LuceneDocumentIndexService) { Service[] queryServiceArray = new Service[] { documentIndexService, new LuceneDocumentIndexBackupService(), new QueryTaskFactoryService(), new LocalQueryTaskFactoryService(), TaskFactoryService.create(GraphQueryTaskService.class), TaskFactoryService.create(SynchronizationTaskService.class), new QueryPageForwardingService(defaultNodeSelectorService) }; startCoreServicesSynchronously(queryServiceArray); // register auto-backup consumer to the document index service // turning on/off the feature is checked in consumer to allow toggling at runtime this.registerForServiceAvailability((o, e) -> { URI subscriptionUri = UriUtils.buildSubscriptionUri(this, this.documentIndexService.getSelfLink()); Operation createSubscriptionOp = Operation.createPost(subscriptionUri).setReferer(getUri()); Consumer<Operation> autoBackupConsumer = LuceneDocumentIndexBackupService.createAutoBackupConsumer(this, this.managementService); startSubscriptionService(createSubscriptionOp, autoBackupConsumer); }, this.documentIndexService.getSelfLink()); } }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService(StatsAggregationTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new StatsAggregationTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService(TagDeletionRequest.class) { @Override public Service createServiceInstance() throws Throwable { return new TagGroomerTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService(StatsCollectionTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new StatsCollectionTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService(StatsAggregationTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new StatsAggregationTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService(ImageEnumerationTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new ImageEnumerationTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }
public static FactoryService createFactory() { TaskFactoryService fs = new TaskFactoryService( SingleResourceStatsAggregationTaskState.class) { @Override public Service createServiceInstance() throws Throwable { return new SingleResourceStatsAggregationTaskService(); } }; fs.setPeerNodeSelectorPath(ServiceUriPaths.DEFAULT_1X_NODE_SELECTOR); return fs; }