use of org.apache.bookkeeper.stream.proto.storage.OneStorageContainerEndpointRequest in project bookkeeper by apache.
the class TestProtocolInternalUtils method testCreateGetStorageContainerEndpointRequest.
//
// Test Location Server Requests
//
@Test
public void testCreateGetStorageContainerEndpointRequest() {
List<Revisioned<Long>> scs = Lists.newArrayList(Revisioned.of(1000L, 1L), Revisioned.of(2000L, 2L), Revisioned.of(3000L, 3L));
GetStorageContainerEndpointRequest request = createGetStorageContainerEndpointRequest(scs);
assertEquals(3, request.getRequestsCount());
int i = 1;
for (OneStorageContainerEndpointRequest oneRequest : request.getRequestsList()) {
assertEquals(1000L * i, oneRequest.getStorageContainer());
assertEquals(1L * i, oneRequest.getRevision());
++i;
}
}
use of org.apache.bookkeeper.stream.proto.storage.OneStorageContainerEndpointRequest in project bookkeeper by apache.
the class GrpcClientTestBase method setUp.
@Before
public void setUp() throws Exception {
fakeServer = InProcessServerBuilder.forName(serverName).fallbackHandlerRegistry(serviceRegistry).directExecutor().build().start();
scheduler = OrderedScheduler.newSchedulerBuilder().name("scheduler-" + getClass()).numThreads(Runtime.getRuntime().availableProcessors()).build();
settings = StorageClientSettings.newBuilder().managedChannelBuilder(InProcessChannelBuilder.forName(serverName).directExecutor()).usePlaintext(true).build();
serverManager = new StorageServerClientManagerImpl(settings, resources.scheduler(), endpoint -> new StorageServerChannel(InProcessChannelBuilder.forName(serverName).directExecutor().build(), Optional.empty()));
StorageContainerServiceImplBase scService = new StorageContainerServiceImplBase() {
@Override
public void getStorageContainerEndpoint(GetStorageContainerEndpointRequest request, StreamObserver<GetStorageContainerEndpointResponse> responseObserver) {
GetStorageContainerEndpointResponse.Builder respBuilder = GetStorageContainerEndpointResponse.newBuilder();
respBuilder.setStatusCode(StatusCode.SUCCESS);
for (OneStorageContainerEndpointRequest oneReq : request.getRequestsList()) {
OneStorageContainerEndpointResponse oneResp = OneStorageContainerEndpointResponse.newBuilder().setEndpoint(StorageContainerEndpoint.newBuilder().setStorageContainerId(oneReq.getStorageContainer()).setRevision(oneReq.getRevision() + 1).setRwEndpoint(ENDPOINT)).build();
respBuilder.addResponses(oneResp);
}
responseObserver.onNext(respBuilder.build());
responseObserver.onCompleted();
}
};
serviceRegistry.addService(scService.bindService());
doSetup();
}
Aggregations