use of com.google.spanner.v1.ListSessionsResponse in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerIntegrationTest method cleanupSessions.
private static void cleanupSessions() {
ManagedChannel channel = builder.build();
GoogleCredentials creds = getCreds();
SpannerBlockingStub stub = SpannerGrpc.newBlockingStub(channel).withCallCredentials(MoreCallCredentials.from(creds));
ListSessionsResponse responseList = stub.listSessions(ListSessionsRequest.newBuilder().setDatabase(DATABASE_PATH).build());
for (Session s : responseList.getSessionsList()) {
deleteSession(stub, s);
}
channel.shutdownNow();
}
use of com.google.spanner.v1.ListSessionsResponse in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerIntegrationTest method testListSessionsAsync.
@Test
public void testListSessionsAsync() throws Exception {
SpannerStub stub = getSpannerStub();
List<String> respNames = createAsyncSessions(stub);
AsyncResponseObserver<ListSessionsResponse> respList = new AsyncResponseObserver<>();
stub.listSessions(ListSessionsRequest.newBuilder().setDatabase(DATABASE_PATH).build(), respList);
ListSessionsResponse responseList = respList.get();
deleteAsyncSessions(stub, respNames);
}
use of com.google.spanner.v1.ListSessionsResponse in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerTestCases method testListSessions.
void testListSessions() throws InterruptedException {
System.out.println("\nTestListSessions");
ManagedChannel channel = getChannel();
SpannerBlockingStub stub = getBlockingStub(channel);
ListSessionsRequest request = ListSessionsRequest.newBuilder().setDatabase(database).build();
for (int i = 0; i < NUM_WARMUP; i++) {
stub.listSessions(request);
}
BlockingCall<ListSessionsRequest, ListSessionsResponse> blockingCall = (ListSessionsRequest req) -> stub.listSessions(req);
Func func = (List<Long> result) -> doBlockingCalls(result, numOfRpcs, request, blockingCall);
runTest(channel, func);
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
use of com.google.spanner.v1.ListSessionsResponse in project java-spanner by googleapis.
the class MockSpannerServiceImpl method listSessions.
@Override
public void listSessions(ListSessionsRequest request, StreamObserver<ListSessionsResponse> responseObserver) {
requests.add(request);
try {
listSessionsExecutionTime.simulateExecutionTime(exceptions, stickyGlobalExceptions, freezeLock);
List<Session> res = new ArrayList<>();
for (Session session : sessions.values()) {
if (session.getName().startsWith(request.getDatabase())) {
res.add(session.toBuilder().setApproximateLastUseTime(getCurrentGoogleTimestamp()).build());
}
}
res.sort(Comparator.comparing(Session::getName));
responseObserver.onNext(ListSessionsResponse.newBuilder().addAllSessions(res).build());
responseObserver.onCompleted();
} catch (StatusRuntimeException e) {
responseObserver.onError(e);
} catch (Throwable t) {
responseObserver.onError(Status.INTERNAL.asRuntimeException());
}
}
use of com.google.spanner.v1.ListSessionsResponse in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerProbesTest method testSessionManagement.
@Test
public void testSessionManagement() throws Exception {
ListSessionsResponse sessions = ListSessionsResponse.newBuilder().addSessions(session).build();
serviceImpl.addResponse(session);
serviceImpl.addResponse(session);
serviceImpl.addResponse(sessions);
serviceImpl.addResponse(emptyResponse);
SpannerProbes.sessionManagementProber(stub);
verify(serviceImpl, times(1)).createSession(any(), any());
verify(serviceImpl, times(1)).getSession(any(), any());
verify(serviceImpl, times(1)).listSessions(any(), any());
verify(serviceImpl, times(1)).deleteSession(any(), any());
}
Aggregations