use of org.apache.bookkeeper.clients.exceptions.StorageContainerException in project bookkeeper by apache.
the class StorageContainerChannel method handleFetchStorageContainerInfoSuccess.
private void handleFetchStorageContainerInfoSuccess(List<OneStorageContainerEndpointResponse> storageContainerEndpoints) {
if (storageContainerEndpoints.size() != 1) {
handleFetchStorageContainerInfoFailure(new Exception("Expected only one storage container endpoint. But found " + storageContainerEndpoints.size() + " storage container endpoints."));
return;
}
OneStorageContainerEndpointResponse response = storageContainerEndpoints.get(0);
if (StatusCode.SUCCESS != response.getStatusCode()) {
handleFetchStorageContainerInfoFailure(new StorageContainerException(response.getStatusCode(), "fail to fetch location for storage container (" + scId + ")"));
return;
}
StorageContainerEndpoint endpoint = response.getEndpoint();
if (null != scInfo && scInfo.getRevision() >= endpoint.getRevision()) {
handleFetchStorageContainerInfoFailure(new StorageContainerException(StatusCode.STALE_GROUP_INFO, "Fetched a stale storage container info : current = " + scInfo.getRevision() + ", fetched = " + endpoint.getRevision() + ""));
return;
}
// we got the updated location
List<Endpoint> readEndpoints = Lists.newArrayListWithExpectedSize(1 + endpoint.getRoEndpointCount());
readEndpoints.add(endpoint.getRwEndpoint());
readEndpoints.addAll(endpoint.getRoEndpointList());
scInfo = StorageContainerInfo.of(scId, endpoint.getRevision(), endpoint.getRwEndpoint(), readEndpoints);
// get the channel from channel manager (if it doesn't exist create one)
StorageServerChannel serverChannel = channelManager.getOrCreateChannel(endpoint.getRwEndpoint());
if (null == serverChannel) {
log.info("No channel found/created for range server {}. The channel manager must be shutting down." + " Stop the process of fetching storage container ({}).", endpoint.getRwEndpoint(), scId);
synchronized (this) {
rsChannelFuture.completeExceptionally(new ObjectClosedException("StorageServerChannelManager is closed"));
}
return;
}
// update the future
synchronized (this) {
rsChannelFuture.complete(serverChannel);
}
}
Aggregations