Search in sources :

Example 1 with FunctionInstanceStatsData

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

the class FunctionsImpl method getFunctionStatsAsync.

@Override
public CompletableFuture<FunctionInstanceStatsData> getFunctionStatsAsync(String tenant, String namespace, String function, int id) {
    WebTarget path = functions.path(tenant).path(namespace).path(function).path(Integer.toString(id)).path("stats");
    final CompletableFuture<FunctionInstanceStatsData> 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(FunctionInstanceStatsDataImpl.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) WebTarget(javax.ws.rs.client.WebTarget) FunctionInstanceStatsData(org.apache.pulsar.common.policies.data.FunctionInstanceStatsData)

Example 2 with FunctionInstanceStatsData

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

the class FunctionsImpl method getFunctionStatsAsync.

@Override
public CompletableFuture<FunctionInstanceStatsData> getFunctionStatsAsync(String tenant, String namespace, String function, int id) {
    WebTarget path = functions.path(tenant).path(namespace).path(function).path(Integer.toString(id)).path("stats");
    final CompletableFuture<FunctionInstanceStatsData> 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(FunctionInstanceStatsDataImpl.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) WebTarget(javax.ws.rs.client.WebTarget) FunctionInstanceStatsData(org.apache.pulsar.common.policies.data.FunctionInstanceStatsData)

Example 3 with FunctionInstanceStatsData

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

the class FunctionsImpl method getFunctionStatsAsync.

@Override
public CompletableFuture<FunctionInstanceStatsData> getFunctionStatsAsync(String tenant, String namespace, String function, int id) {
    WebTarget path = functions.path(tenant).path(namespace).path(function).path(Integer.toString(id)).path("stats");
    final CompletableFuture<FunctionInstanceStatsData> 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(FunctionInstanceStatsDataImpl.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) WebTarget(javax.ws.rs.client.WebTarget) FunctionInstanceStatsData(org.apache.pulsar.common.policies.data.FunctionInstanceStatsData)

Aggregations

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