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);
}
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));
}
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);
}
Aggregations