use of com.google.spanner.v1.ListSessionsResponse 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);
}
use of com.google.spanner.v1.ListSessionsResponse in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerIntegrationTest method testListSessionsFuture.
@Test
public void testListSessionsFuture() throws Exception {
SpannerFutureStub stub = getSpannerFutureStub();
List<String> futureNames = createFutureSessions(stub);
ListSessionsResponse responseList = stub.listSessions(ListSessionsRequest.newBuilder().setDatabase(DATABASE_PATH).build()).get();
Set<String> trueNames = new HashSet<>();
deleteFutureSessions(stub, futureNames);
}
use of com.google.spanner.v1.ListSessionsResponse in project cloud-spanner-r2dbc by GoogleCloudPlatform.
the class SessionCleanupUtils method getSessionNames.
private static List<String> getSessionNames() throws Exception {
String databaseName = DatabaseName.format(ServiceOptions.getDefaultProjectId(), DatabaseProperties.INSTANCE, DatabaseProperties.DATABASE);
String nextPageToken = null;
List<String> sessionNames = new ArrayList<>();
do {
ListSessionsRequest.Builder requestBuilder = ListSessionsRequest.newBuilder().setDatabase(databaseName);
if (nextPageToken != null) {
requestBuilder.setPageToken(nextPageToken);
}
ListSessionsResponse listSessionsResponse = ObservableReactiveUtil.<ListSessionsResponse>unaryCall(obs -> spannerStub.listSessions(requestBuilder.build(), obs)).block();
nextPageToken = listSessionsResponse.getNextPageToken();
sessionNames.addAll(listSessionsResponse.getSessionsList().stream().map(Session::getName).collect(Collectors.toList()));
} while (nextPageToken != null && !"".equals(nextPageToken));
return sessionNames;
}
Aggregations