Search in sources :

Example 81 with Query

use of com.vmware.xenon.services.common.QueryTask.Query in project photon-model by vmware.

the class SslTrustCertificateServiceUtils method subscribe.

/**
 * Subscribes a consumer to the given continuous query.
 */
static void subscribe(ServiceHost host, Consumer<Operation> consumer) {
    QueryTask task = getQueryTask();
    QueryUtils.createQueryTaskOperation(host, task, null).setReferer(host.getUri()).setCompletion((o, e) -> {
        if (e != null && o.getStatusCode() != Operation.STATUS_CODE_CONFLICT) {
            host.log(Level.SEVERE, Utils.toString(e));
            return;
        }
        String taskUriPath = UriUtils.buildUriPath(ServiceUriPaths.CORE_LOCAL_QUERY_TASKS, task.documentSelfLink);
        Operation subscribePost = Operation.createPost(host, taskUriPath).setReferer(host.getUri()).setConnectionSharing(true).setCompletion((op, ex) -> {
            if (ex != null) {
                host.log(Level.SEVERE, Utils.toString(ex));
            }
        });
        host.log(Level.INFO, "Subscribing to a continuous task: %s", taskUriPath);
        host.startSubscriptionService(subscribePost, consumer, ServiceSubscriber.create(false));
    }).sendWith(host);
}
Also used : Operation(com.vmware.xenon.common.Operation) QueryTask(com.vmware.xenon.services.common.QueryTask) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) SslTrustCertificateState(com.vmware.photon.controller.model.security.service.SslTrustCertificateService.SslTrustCertificateState) UUID(java.util.UUID) ServiceHost(com.vmware.xenon.common.ServiceHost) ServiceSubscriber(com.vmware.xenon.common.ServiceSubscriptionState.ServiceSubscriber) Level(java.util.logging.Level) ServiceUriPaths(com.vmware.xenon.services.common.ServiceUriPaths) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) QueryStrategy(com.vmware.photon.controller.model.query.QueryStrategy) Utils(com.vmware.xenon.common.Utils) Query(com.vmware.xenon.services.common.QueryTask.Query) UriUtils(com.vmware.xenon.common.UriUtils) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) QueryTask(com.vmware.xenon.services.common.QueryTask) Operation(com.vmware.xenon.common.Operation)

Aggregations

Query (com.vmware.xenon.services.common.QueryTask.Query)81 QueryTask (com.vmware.xenon.services.common.QueryTask)50 Operation (com.vmware.xenon.common.Operation)39 ArrayList (java.util.ArrayList)29 HashMap (java.util.HashMap)26 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)25 Utils (com.vmware.xenon.common.Utils)22 List (java.util.List)21 Map (java.util.Map)21 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)20 UriUtils (com.vmware.xenon.common.UriUtils)20 HashSet (java.util.HashSet)20 QueryByPages (com.vmware.photon.controller.model.query.QueryUtils.QueryByPages)19 ServiceTypeCluster (com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster)18 Set (java.util.Set)18 URI (java.net.URI)17 OperationJoin (com.vmware.xenon.common.OperationJoin)16 StatelessService (com.vmware.xenon.common.StatelessService)16 Collections (java.util.Collections)15 Collectors (java.util.stream.Collectors)15