use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationRequest.Builder in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method submitRequest.
/**
* Helper method to wrap the request and send the message.
*/
private ScmContainerLocationResponse submitRequest(StorageContainerLocationProtocolProtos.Type type, Consumer<Builder> builderConsumer) throws IOException {
final ScmContainerLocationResponse response;
try {
Builder builder = ScmContainerLocationRequest.newBuilder().setCmdType(type).setVersion(CURRENT_VERSION).setTraceID(TracingUtil.exportCurrentSpan());
builderConsumer.accept(builder);
ScmContainerLocationRequest wrapper = builder.build();
response = submitRpcRequest(wrapper);
} catch (ServiceException ex) {
throw ProtobufHelper.getRemoteException(ex);
}
return response;
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationRequest.Builder in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method getExistContainerWithPipelinesInBatch.
/**
* {@inheritDoc}
*/
@Override
public List<ContainerWithPipeline> getExistContainerWithPipelinesInBatch(List<Long> containerIDs) {
for (Long containerID : containerIDs) {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative");
}
GetExistContainerWithPipelinesInBatchRequestProto request = GetExistContainerWithPipelinesInBatchRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).addAllContainerIDs(containerIDs).build();
ScmContainerLocationResponse response = null;
List<ContainerWithPipeline> cps = new ArrayList<>();
try {
response = submitRequest(Type.GetExistContainerWithPipelinesInBatch, (builder) -> builder.setGetExistContainerWithPipelinesInBatchRequest(request));
} catch (IOException ex) {
return cps;
}
List<HddsProtos.ContainerWithPipeline> protoCps = response.getGetExistContainerWithPipelinesInBatchResponse().getContainerWithPipelinesList();
for (HddsProtos.ContainerWithPipeline cp : protoCps) {
try {
cps.add(ContainerWithPipeline.fromProtobuf(cp));
} catch (IOException uex) {
// "fromProtobuf" may throw an exception
// do nothing , just go ahead
}
}
return cps;
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationRequest.Builder in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method getScmInfo.
@Override
public ScmInfo getScmInfo() throws IOException {
HddsProtos.GetScmInfoRequestProto request = HddsProtos.GetScmInfoRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).build();
GetScmInfoResponseProto resp = submitRequest(Type.GetScmInfo, builder -> builder.setGetScmInfoRequest(request)).getGetScmInfoResponse();
ScmInfo.Builder builder = new ScmInfo.Builder().setClusterId(resp.getClusterId()).setScmId(resp.getScmId()).setRatisPeerRoles(resp.getPeerRolesList());
return builder.build();
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationRequest.Builder in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method getPipeline.
@Override
public Pipeline getPipeline(HddsProtos.PipelineID pipelineID) throws IOException {
GetPipelineRequestProto request = GetPipelineRequestProto.newBuilder().setPipelineID(pipelineID).setTraceID(TracingUtil.exportCurrentSpan()).build();
GetPipelineResponseProto response = submitRequest(Type.GetPipeline, builder -> builder.setGetPipelineRequest(request)).getGetPipelineResponse();
return Pipeline.getFromProtobuf(response.getPipeline());
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationRequest.Builder in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method forceExitSafeMode.
/**
* Force SCM out of Safe mode.
*
* @return returns true if operation is successful.
*/
@Override
public boolean forceExitSafeMode() throws IOException {
ForceExitSafeModeRequestProto request = ForceExitSafeModeRequestProto.getDefaultInstance();
ForceExitSafeModeResponseProto resp = submitRequest(Type.ForceExitSafeMode, builder -> builder.setForceExitSafeModeRequest(request)).getForceExitSafeModeResponse();
return resp.getExitedSafeMode();
}
Aggregations