Search in sources :

Example 1 with FunctionStats

use of org.apache.pulsar.common.policies.data.FunctionStats in project pulsar by apache.

the class FunctionsImpl method getFunctionStatsAsync.

@Override
public CompletableFuture<FunctionStats> getFunctionStatsAsync(String tenant, String namespace, String function) {
    WebTarget path = functions.path(tenant).path(namespace).path(function).path("stats");
    final CompletableFuture<FunctionStats> future = new CompletableFuture<>();
    asyncGetRequest(path, new InvocationCallback<Response>() {

        @Override
        public void completed(Response response) {
            if (response.getStatus() != Response.Status.OK.getStatusCode()) {
                future.completeExceptionally(getApiException(response));
            } else {
                future.complete(response.readEntity(FunctionStatsImpl.class));
            }
        }

        @Override
        public void failed(Throwable throwable) {
            future.completeExceptionally(getApiException(throwable.getCause()));
        }
    });
    return future;
}
Also used : Response(javax.ws.rs.core.Response) CompletableFuture(java.util.concurrent.CompletableFuture) FunctionStats(org.apache.pulsar.common.policies.data.FunctionStats) WebTarget(javax.ws.rs.client.WebTarget)

Example 2 with FunctionStats

use of org.apache.pulsar.common.policies.data.FunctionStats in project incubator-pulsar by apache.

the class FunctionsImpl method getFunctionStatsAsync.

@Override
public CompletableFuture<FunctionStats> getFunctionStatsAsync(String tenant, String namespace, String function) {
    WebTarget path = functions.path(tenant).path(namespace).path(function).path("stats");
    final CompletableFuture<FunctionStats> future = new CompletableFuture<>();
    asyncGetRequest(path, new InvocationCallback<Response>() {

        @Override
        public void completed(Response response) {
            if (response.getStatus() != Response.Status.OK.getStatusCode()) {
                future.completeExceptionally(getApiException(response));
            } else {
                future.complete(response.readEntity(FunctionStatsImpl.class));
            }
        }

        @Override
        public void failed(Throwable throwable) {
            future.completeExceptionally(getApiException(throwable.getCause()));
        }
    });
    return future;
}
Also used : Response(javax.ws.rs.core.Response) CompletableFuture(java.util.concurrent.CompletableFuture) FunctionStats(org.apache.pulsar.common.policies.data.FunctionStats) WebTarget(javax.ws.rs.client.WebTarget)

Example 3 with FunctionStats

use of org.apache.pulsar.common.policies.data.FunctionStats in project pulsar by yahoo.

the class FunctionsImpl method getFunctionStatsAsync.

@Override
public CompletableFuture<FunctionStats> getFunctionStatsAsync(String tenant, String namespace, String function) {
    WebTarget path = functions.path(tenant).path(namespace).path(function).path("stats");
    final CompletableFuture<FunctionStats> future = new CompletableFuture<>();
    asyncGetRequest(path, new InvocationCallback<Response>() {

        @Override
        public void completed(Response response) {
            if (response.getStatus() != Response.Status.OK.getStatusCode()) {
                future.completeExceptionally(getApiException(response));
            } else {
                future.complete(response.readEntity(FunctionStatsImpl.class));
            }
        }

        @Override
        public void failed(Throwable throwable) {
            future.completeExceptionally(getApiException(throwable.getCause()));
        }
    });
    return future;
}
Also used : Response(javax.ws.rs.core.Response) CompletableFuture(java.util.concurrent.CompletableFuture) FunctionStats(org.apache.pulsar.common.policies.data.FunctionStats) WebTarget(javax.ws.rs.client.WebTarget)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)3 WebTarget (javax.ws.rs.client.WebTarget)3 Response (javax.ws.rs.core.Response)3 FunctionStats (org.apache.pulsar.common.policies.data.FunctionStats)3