use of com.google.cloud.spanner.r2dbc.util.ObservableReactiveUtil 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