javax.ws.rs.client.InvocationCallback Java Examples

The following examples show how to use javax.ws.rs.client.InvocationCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClustersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<List<BrokerNamespaceIsolationData>> getBrokersWithNamespaceIsolationPolicyAsync(
        String cluster) {
    WebTarget path = adminClusters.path(cluster).path("namespaceIsolationPolicies").path("brokers");
    final CompletableFuture<List<BrokerNamespaceIsolationData>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<List<BrokerNamespaceIsolationData>>() {
                @Override
                public void completed(List<BrokerNamespaceIsolationData> brokerNamespaceIsolationData) {
                    future.complete(brokerNamespaceIsolationData);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #2
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<List<String>> getNamespacesAsync(String tenant) {
    WebTarget path = adminV2Namespaces.path(tenant);
    final CompletableFuture<List<String>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<List<String>>() {
                @Override
                public void completed(List<String> namespaces) {
                    future.complete(namespaces);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #3
Source File: WorkerImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Map<String, Collection<String>>> getAssignmentsAsync() {
    WebTarget path = worker.path("assignments");
    final CompletableFuture<Map<String, Collection<String>>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Response>() {
                @Override
                public void completed(Response response) {
                    if (!response.getStatusInfo().equals(Response.Status.OK)) {
                        future.completeExceptionally(new ClientErrorException(response));
                    } else {
                        future.complete(response.readEntity(
                                new GenericType<Map<String, Collection<String>>>() {}));
                    }
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #4
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Policies> getPoliciesAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    WebTarget path = namespacePath(ns);
    final CompletableFuture<Policies> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Policies>() {
                @Override
                public void completed(Policies policies) {
                    future.complete(policies);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #5
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Map<String, Set<AuthAction>>> getPermissionsAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    WebTarget path = namespacePath(ns, "permissions");
    final CompletableFuture<Map<String, Set<AuthAction>>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Map<String, Set<AuthAction>>>() {
                @Override
                public void completed(Map<String, Set<AuthAction>> permissions) {
                    future.complete(permissions);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #6
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<List<String>> getTopicsAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    String action = ns.isV2() ? "topics" : "destinations";
    WebTarget path = namespacePath(ns, action);
    final CompletableFuture<List<String>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<List<String>>() {
                @Override
                public void completed(List<String> topics) {
                    future.complete(topics);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #7
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<DispatchRate> getSubscriptionDispatchRateAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    WebTarget path = namespacePath(ns, "subscriptionDispatchRate");
    final CompletableFuture<DispatchRate> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<DispatchRate>() {
                @Override
                public void completed(DispatchRate dispatchRate) {
                    future.complete(dispatchRate);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #8
Source File: NonPersistentTopicsImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<PersistentTopicInternalStats> getInternalStatsAsync(String topic) {
    TopicName topicName = validateTopic(topic);
    final CompletableFuture<PersistentTopicInternalStats> future = new CompletableFuture<>();
    WebTarget path = topicPath(topicName, "internalStats");
    asyncGetRequest(path,
            new InvocationCallback<PersistentTopicInternalStats>() {

                @Override
                public void completed(PersistentTopicInternalStats response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #9
Source File: NonPersistentTopicsImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<NonPersistentTopicStats> getStatsAsync(String topic) {
    TopicName topicName = validateTopic(topic);
    final CompletableFuture<NonPersistentTopicStats> future = new CompletableFuture<>();
    WebTarget path = topicPath(topicName, "stats");
    asyncGetRequest(path,
            new InvocationCallback<NonPersistentTopicStats>() {

                @Override
                public void completed(NonPersistentTopicStats response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #10
Source File: SinksImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<List<String>> listSinksAsync(String tenant, String namespace) {
    WebTarget path = sink.path(tenant).path(namespace);
    final CompletableFuture<List<String>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Response>() {
                @Override
                public void completed(Response response) {
                    if (!response.getStatusInfo().equals(Response.Status.OK)) {
                        future.completeExceptionally(getApiException(response));
                    } else {
                        future.complete(response.readEntity(new GenericType<List<String>>() {}));
                    }
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #11
Source File: NonPersistentTopicsImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<List<String>> getListAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    final CompletableFuture<List<String>> future = new CompletableFuture<>();
    WebTarget path = namespacePath("non-persistent", ns);
    asyncGetRequest(path,
            new InvocationCallback<List<String>>() {
                @Override
                public void completed(List<String> response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #12
Source File: ClustersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<FailureDomain> getFailureDomainAsync(String cluster, String domainName) {
    WebTarget path = adminClusters.path(cluster).path("failureDomains").path(domainName);
    final CompletableFuture<FailureDomain> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<FailureDomain>() {
                @Override
                public void completed(FailureDomain failureDomain) {
                    future.complete(failureDomain);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #13
Source File: ClustersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Map<String, FailureDomain>> getFailureDomainsAsync(String cluster) {
    WebTarget path = adminClusters.path(cluster).path("failureDomains");
    final CompletableFuture<Map<String, FailureDomain>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Map<String, FailureDomain>>() {
                @Override
                public void completed(Map<String, FailureDomain> failureDomains) {
                    future.complete(failureDomains);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #14
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Long> getOffloadThresholdAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    WebTarget path = namespacePath(ns, "offloadThreshold");
    final CompletableFuture<Long> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Long>() {
                @Override
                public void completed(Long threshold) {
                    future.complete(threshold);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #15
Source File: ClustersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<BrokerNamespaceIsolationData> getBrokerWithNamespaceIsolationPolicyAsync(
        String cluster, String broker) {
    WebTarget path = adminClusters.path(cluster).path("namespaceIsolationPolicies").path("brokers").path(broker);
    final CompletableFuture<BrokerNamespaceIsolationData> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<BrokerNamespaceIsolationData>() {
                @Override
                public void completed(BrokerNamespaceIsolationData brokerNamespaceIsolationData) {
                    future.complete(brokerNamespaceIsolationData);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #16
Source File: BrokerStatsImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<JsonArray> getMetricsAsync() {
    WebTarget path = adminV2BrokerStats.path("/metrics");
    final CompletableFuture<JsonArray> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<String>() {
                @Override
                public void completed(String s) {
                    future.complete(new Gson().fromJson(s, JsonArray.class));
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #17
Source File: ClustersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Map<String, NamespaceIsolationData>> getNamespaceIsolationPoliciesAsync(String cluster) {
    WebTarget path = adminClusters.path(cluster).path("namespaceIsolationPolicies");
    final CompletableFuture<Map<String, NamespaceIsolationData>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Map<String, NamespaceIsolationData>>() {
                @Override
                public void completed(Map<String, NamespaceIsolationData> stringNamespaceIsolationDataMap) {
                    future.complete(stringNamespaceIsolationDataMap);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #18
Source File: SchemasImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Void> deleteSchemaAsync(String topic) {
    TopicName tn = TopicName.get(topic);
    final CompletableFuture<Void> future = new CompletableFuture<>();
    try {
        request(schemaPath(tn)).async().delete(new InvocationCallback<DeleteSchemaResponse>() {
            @Override
            public void completed(DeleteSchemaResponse deleteSchemaResponse) {
                future.complete(null);
            }

            @Override
            public void failed(Throwable throwable) {
                future.completeExceptionally(getApiException(throwable.getCause()));
            }
        });
    } catch (PulsarAdminException cae) {
        future.completeExceptionally(cae);
    }
    return future;
}
 
Example #19
Source File: ClustersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<ClusterData> getClusterAsync(String cluster) {
    WebTarget path = adminClusters.path(cluster);
    final CompletableFuture<ClusterData> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<ClusterData>() {
                @Override
                public void completed(ClusterData clusterData) {
                    future.complete(clusterData);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #20
Source File: ClustersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<List<String>> getClustersAsync() {
    final CompletableFuture<List<String>> future = new CompletableFuture<>();
    asyncGetRequest(adminClusters,
            new InvocationCallback<List<String>>() {
                @Override
                public void completed(List<String> clusters) {
                    future.complete(clusters);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #21
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<PersistencePolicies> getPersistenceAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    WebTarget path = namespacePath(ns, "persistence");
    final CompletableFuture<PersistencePolicies> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<PersistencePolicies>() {
                @Override
                public void completed(PersistencePolicies persistencePolicies) {
                    future.complete(persistencePolicies);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #22
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Integer> getMaxConsumersPerTopicAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    WebTarget path = namespacePath(ns, "maxConsumersPerTopic");
    final CompletableFuture<Integer> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Integer>() {
                @Override
                public void completed(Integer max) {
                    future.complete(max);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #23
Source File: SchemasImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<IsCompatibilityResponse> testCompatibilityAsync(String topic, PostSchemaPayload payload) {
    TopicName tn = TopicName.get(topic);
    final CompletableFuture<IsCompatibilityResponse> future = new CompletableFuture<>();
    try {
        request(compatibilityPath(tn)).async().post(Entity.json(payload),
                new InvocationCallback<IsCompatibilityResponse>() {
                    @Override
                    public void completed(IsCompatibilityResponse isCompatibilityResponse) {
                        future.complete(isCompatibilityResponse);
                    }

                    @Override
                    public void failed(Throwable throwable) {
                        future.completeExceptionally(getApiException(throwable.getCause()));
                    }
                });
    } catch (PulsarAdminException cae) {
        future.completeExceptionally(cae);
    }
    return future;
}
 
Example #24
Source File: SourcesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<SourceConfig> getSourceAsync(String tenant, String namespace, String sourceName) {
    WebTarget path = source.path(tenant).path(namespace).path(sourceName);
    final CompletableFuture<SourceConfig> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Response>() {
                @Override
                public void completed(Response response) {
                    if (!response.getStatusInfo().equals(Response.Status.OK)) {
                        future.completeExceptionally(getApiException(response));
                    } else {
                        future.complete(response.readEntity(SourceConfig.class));
                    }
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #25
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<DispatchRate> getDispatchRateAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    WebTarget path = namespacePath(ns, "dispatchRate");
    final CompletableFuture<DispatchRate> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<DispatchRate>() {
                @Override
                public void completed(DispatchRate dispatchRate) {
                    future.complete(dispatchRate);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #26
Source File: BrokersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Void> healthcheckAsync() {
    WebTarget path = adminBrokers.path("health");
    final CompletableFuture<Void> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<String>() {
                @Override
                public void completed(String result) {
                    if (!"ok".equalsIgnoreCase(result.trim())) {
                        future.completeExceptionally(
                                new PulsarAdminException("Healthcheck returned unexpected result: " + result));
                    } else {
                        future.complete(null);
                    }
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #27
Source File: BrokersImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<InternalConfigurationData> getInternalConfigurationDataAsync() {
    WebTarget path = adminBrokers.path("internal-configuration");
    final CompletableFuture<InternalConfigurationData> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<InternalConfigurationData>() {
                @Override
                public void completed(InternalConfigurationData internalConfigurationData) {
                    future.complete(internalConfigurationData);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #28
Source File: SinksImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<SinkStatus> getSinkStatusAsync(String tenant, String namespace, String sinkName) {
    WebTarget path = sink.path(tenant).path(namespace).path(sinkName).path("status");
    final CompletableFuture<SinkStatus> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Response>() {
                @Override
                public void completed(Response response) {
                    if (!response.getStatusInfo().equals(Response.Status.OK)) {
                        future.completeExceptionally(getApiException(response));
                    } else {
                        future.complete(response.readEntity(SinkStatus.class));
                    }
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #29
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<List<String>> getAntiAffinityNamespacesAsync(
        String tenant, String cluster, String namespaceAntiAffinityGroup) {
    WebTarget path = adminNamespaces.path(cluster)
            .path("antiAffinity").path(namespaceAntiAffinityGroup).queryParam("property", tenant);
    final CompletableFuture<List<String>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<List<String>>() {
                @Override
                public void completed(List<String> antiNamespaces) {
                    future.complete(antiNamespaces);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example #30
Source File: NamespacesImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Map<BacklogQuotaType, BacklogQuota>> getBacklogQuotaMapAsync(String namespace) {
    NamespaceName ns = NamespaceName.get(namespace);
    WebTarget path = namespacePath(ns, "backlogQuotaMap");
    final CompletableFuture<Map<BacklogQuotaType, BacklogQuota>> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<Map<BacklogQuotaType, BacklogQuota>>() {
                @Override
                public void completed(Map<BacklogQuotaType, BacklogQuota> quotaMap) {
                    future.complete(quotaMap);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}