Search in sources :

Example 6 with ListSessionsRequest

use of com.google.spanner.v1.ListSessionsRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerClientV1TestCases method testListSessions.

void testListSessions() throws InterruptedException {
    System.out.println("\nTestListSessions");
    SpannerClient client = getClient();
    ListSessionsRequest request = ListSessionsRequest.newBuilder().setDatabase(database).build();
    for (int i = 0; i < NUM_WARMUP; i++) {
        client.listSessions(request);
    }
    // for (Session element : spannerClient.listSessions(request).iterateAll())
    RpcCall<ListSessionsRequest, ListSessionsPagedResponse> rpcCall = (ListSessionsRequest req) -> client.listSessions(req);
    doTestBlocking(request, rpcCall);
    client.shutdown();
    client.awaitTermination(5, TimeUnit.SECONDS);
}
Also used : ListSessionsPagedResponse(com.google.cloud.spanner.v1.SpannerClient.ListSessionsPagedResponse) SpannerClient(com.google.cloud.spanner.v1.SpannerClient) ListSessionsRequest(com.google.spanner.v1.ListSessionsRequest)

Example 7 with ListSessionsRequest

use of com.google.spanner.v1.ListSessionsRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerClientV1TestCases method listSessionsSingleCall.

private void listSessionsSingleCall(SpannerClient client) {
    ListSessionsRequest request = ListSessionsRequest.newBuilder().setDatabase(database).build();
    long start = System.currentTimeMillis();
    client.listSessionsCallable().call(request);
    System.out.println(String.format("-- Finished executing listSessions in %d ms in another thread. -- ", System.currentTimeMillis() - start));
}
Also used : ListSessionsRequest(com.google.spanner.v1.ListSessionsRequest)

Example 8 with ListSessionsRequest

use of com.google.spanner.v1.ListSessionsRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerTestCases method testListSessionsAsync.

void testListSessionsAsync() throws InterruptedException {
    System.out.println("\nTestListSessionsAsync");
    ManagedChannel channel = getChannel();
    SpannerStub stub = getStub(channel);
    ListSessionsRequest request = ListSessionsRequest.newBuilder().setDatabase(database).build();
    for (int i = 0; i < NUM_WARMUP; i++) {
        AsyncResponseObserver<ListSessionsResponse> respList = new AsyncResponseObserver<>();
        stub.listSessions(request, respList);
        respList.get();
    }
    AsyncCall<ListSessionsRequest, ListSessionsResponse> asyncCall = (ListSessionsRequest req, AsyncResponseObserver<ListSessionsResponse> resp) -> stub.listSessions(req, resp);
    Func func = (List<Long> result) -> doAsyncCalls(result, numOfRpcs, request, asyncCall);
    runTest(channel, func);
    channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
Also used : ListSessionsResponse(com.google.spanner.v1.ListSessionsResponse) SpannerStub(com.google.spanner.v1.SpannerGrpc.SpannerStub) ManagedChannel(io.grpc.ManagedChannel) GcpManagedChannel(com.google.grpc.gcp.GcpManagedChannel) ListSessionsRequest(com.google.spanner.v1.ListSessionsRequest)

Aggregations

ListSessionsRequest (com.google.spanner.v1.ListSessionsRequest)7 ListSessionsResponse (com.google.spanner.v1.ListSessionsResponse)4 ListSessionsPagedResponse (com.google.cloud.spanner.v1.SpannerClient.ListSessionsPagedResponse)3 Session (com.google.spanner.v1.Session)3 GcpManagedChannel (com.google.grpc.gcp.GcpManagedChannel)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 ManagedChannel (io.grpc.ManagedChannel)2 Test (org.junit.Test)2 SpannerClient (com.google.cloud.spanner.v1.SpannerClient)1 ByteString (com.google.protobuf.ByteString)1 DatabaseName (com.google.spanner.v1.DatabaseName)1 SpannerBlockingStub (com.google.spanner.v1.SpannerGrpc.SpannerBlockingStub)1 SpannerStub (com.google.spanner.v1.SpannerGrpc.SpannerStub)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 ArrayList (java.util.ArrayList)1