HDFS-12901. Ozone: SCM: Expose StorageContainerManager#getScmId through container protocol. Contributed by Nanda kumar.
This commit is contained in:
parent
11473b8204
commit
74362cb503
@ -22,6 +22,7 @@
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.ozone.protocol.proto.StorageContainerLocationProtocolProtos.NotifyObjectCreationStageRequestProto;
|
||||
import org.apache.hadoop.scm.ScmInfo;
|
||||
import org.apache.hadoop.scm.container.common.helpers.ContainerInfo;
|
||||
import org.apache.hadoop.scm.container.common.helpers.Pipeline;
|
||||
import org.apache.hadoop.ozone.protocol.proto.OzoneProtos;
|
||||
@ -117,4 +118,12 @@ Pipeline createReplicationPipeline(OzoneProtos.ReplicationType type,
|
||||
* @throws IOException
|
||||
*/
|
||||
void closeContainer(String containerName) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns information about SCM.
|
||||
*
|
||||
* @return {@link ScmInfo}
|
||||
* @throws IOException
|
||||
*/
|
||||
ScmInfo getScmInfo() throws IOException;
|
||||
}
|
||||
|
@ -33,8 +33,6 @@
|
||||
import org.apache.hadoop.ozone.protocol.proto.ScmBlockLocationProtocolProtos.GetScmBlockLocationsRequestProto;
|
||||
import org.apache.hadoop.ozone.protocol.proto.ScmBlockLocationProtocolProtos.GetScmBlockLocationsResponseProto;
|
||||
import org.apache.hadoop.ozone.protocol.proto.ScmBlockLocationProtocolProtos.ScmLocatedBlockProto;
|
||||
import org.apache.hadoop.ozone.protocol.proto.ScmBlockLocationProtocolProtos.GetScmInfoRequestProto;
|
||||
import org.apache.hadoop.ozone.protocol.proto.ScmBlockLocationProtocolProtos.GetScmInfoRespsonseProto;
|
||||
import org.apache.hadoop.ozone.protocol.proto.ScmBlockLocationProtocolProtos.KeyBlocks;
|
||||
import org.apache.hadoop.scm.container.common.helpers.AllocatedBlock;
|
||||
import org.apache.hadoop.scm.ScmInfo;
|
||||
@ -185,9 +183,9 @@ public List<DeleteBlockGroupResult> deleteKeyBlocks(
|
||||
*/
|
||||
@Override
|
||||
public ScmInfo getScmInfo() throws IOException {
|
||||
GetScmInfoRequestProto request =
|
||||
GetScmInfoRequestProto.getDefaultInstance();
|
||||
GetScmInfoRespsonseProto resp;
|
||||
OzoneProtos.GetScmInfoRequestProto request =
|
||||
OzoneProtos.GetScmInfoRequestProto.getDefaultInstance();
|
||||
OzoneProtos.GetScmInfoRespsonseProto resp;
|
||||
try {
|
||||
resp = rpcProxy.getScmInfo(NULL_RPC_CONTROLLER, request);
|
||||
} catch (ServiceException e) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
import org.apache.hadoop.ipc.ProtocolTranslator;
|
||||
import org.apache.hadoop.ipc.RPC;
|
||||
import org.apache.hadoop.ozone.protocol.proto.OzoneProtos;
|
||||
import org.apache.hadoop.scm.ScmInfo;
|
||||
import org.apache.hadoop.scm.container.common.helpers.ContainerInfo;
|
||||
import org.apache.hadoop.scm.protocol.StorageContainerLocationProtocol;
|
||||
import org.apache.hadoop.ozone.protocol.proto.StorageContainerLocationProtocolProtos.CloseContainerRequestProto;
|
||||
@ -287,6 +288,23 @@ public void closeContainer(String containerName) throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScmInfo getScmInfo() throws IOException {
|
||||
OzoneProtos.GetScmInfoRequestProto request =
|
||||
OzoneProtos.GetScmInfoRequestProto.getDefaultInstance();
|
||||
try {
|
||||
OzoneProtos.GetScmInfoRespsonseProto resp = rpcProxy.getScmInfo(
|
||||
NULL_RPC_CONTROLLER, request);
|
||||
ScmInfo.Builder builder = new ScmInfo.Builder()
|
||||
.setClusterId(resp.getClusterId())
|
||||
.setScmId(resp.getScmId());
|
||||
return builder.build();
|
||||
} catch (ServiceException e) {
|
||||
throw ProtobufHelper.getRemoteException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getUnderlyingProxyObject() {
|
||||
return rpcProxy;
|
||||
|
@ -133,6 +133,15 @@ message SCMContainerInfo {
|
||||
optional Owner owner = 8 [default = OZONE];
|
||||
}
|
||||
|
||||
message GetScmInfoRequestProto {
|
||||
}
|
||||
|
||||
message GetScmInfoRespsonseProto {
|
||||
required string clusterId = 1;
|
||||
required string scmId = 2;
|
||||
}
|
||||
|
||||
|
||||
enum ReplicationType {
|
||||
RATIS = 1;
|
||||
STAND_ALONE = 2;
|
||||
|
@ -131,20 +131,6 @@ message AllocateScmBlockResponseProto {
|
||||
optional string errorMessage = 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request for cluster Id and SCM Id from SCM.
|
||||
*/
|
||||
message GetScmInfoRequestProto {
|
||||
}
|
||||
|
||||
/**
|
||||
* Response from SCM for cluster Id and SCM ID.
|
||||
*/
|
||||
message GetScmInfoRespsonseProto {
|
||||
required string clusterId = 1;
|
||||
required string scmId = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protocol used from KeySpaceManager to StorageContainerManager.
|
||||
* See request and response messages for details of the RPC calls.
|
||||
@ -174,6 +160,6 @@ service ScmBlockLocationProtocolService {
|
||||
/**
|
||||
* Gets the scmInfo from SCM.
|
||||
*/
|
||||
rpc getScmInfo(GetScmInfoRequestProto)
|
||||
returns (GetScmInfoRespsonseProto);
|
||||
rpc getScmInfo(hadoop.hdfs.ozone.GetScmInfoRequestProto)
|
||||
returns (hadoop.hdfs.ozone.GetScmInfoRespsonseProto);
|
||||
}
|
||||
|
@ -211,4 +211,10 @@ service StorageContainerLocationProtocolService {
|
||||
*/
|
||||
rpc allocatePipeline(PipelineRequestProto)
|
||||
returns (PipelineResponseProto);
|
||||
|
||||
/**
|
||||
* Returns information about SCM.
|
||||
*/
|
||||
rpc getScmInfo(hadoop.hdfs.ozone.GetScmInfoRequestProto)
|
||||
returns (hadoop.hdfs.ozone.GetScmInfoRespsonseProto);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
import com.google.protobuf.ServiceException;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.ozone.common.BlockGroup;
|
||||
import org.apache.hadoop.ozone.protocol.proto.OzoneProtos;
|
||||
import org.apache.hadoop.ozone.protocol.proto.ScmBlockLocationProtocolProtos.DeleteKeyBlocksResultProto;
|
||||
import org.apache.hadoop.scm.container.common.helpers.AllocatedBlock;
|
||||
import org.apache.hadoop.ozone.common.DeleteBlockGroupResult;
|
||||
@ -44,10 +45,6 @@
|
||||
.ScmBlockLocationProtocolProtos.GetScmBlockLocationsResponseProto;
|
||||
import org.apache.hadoop.ozone.protocol.proto
|
||||
.ScmBlockLocationProtocolProtos.ScmLocatedBlockProto;
|
||||
import org.apache.hadoop.ozone.protocol.proto
|
||||
.ScmBlockLocationProtocolProtos.GetScmInfoRequestProto;
|
||||
import org.apache.hadoop.ozone.protocol.proto
|
||||
.ScmBlockLocationProtocolProtos.GetScmInfoRespsonseProto;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@ -155,15 +152,16 @@ public DeleteScmKeyBlocksResponseProto deleteScmKeyBlocks(
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetScmInfoRespsonseProto getScmInfo(RpcController controller,
|
||||
GetScmInfoRequestProto req) throws ServiceException {
|
||||
public OzoneProtos.GetScmInfoRespsonseProto getScmInfo(
|
||||
RpcController controller, OzoneProtos.GetScmInfoRequestProto req)
|
||||
throws ServiceException {
|
||||
ScmInfo scmInfo;
|
||||
try {
|
||||
scmInfo = impl.getScmInfo();
|
||||
} catch (IOException ex) {
|
||||
throw new ServiceException(ex);
|
||||
}
|
||||
return GetScmInfoRespsonseProto.newBuilder()
|
||||
return OzoneProtos.GetScmInfoRespsonseProto.newBuilder()
|
||||
.setClusterId(scmInfo.getClusterId())
|
||||
.setScmId(scmInfo.getScmId())
|
||||
.build();
|
||||
|
@ -29,6 +29,7 @@
|
||||
import org.apache.hadoop.ozone.protocol.proto.OzoneProtos;
|
||||
import org.apache.hadoop.ozone.protocol.proto
|
||||
.StorageContainerLocationProtocolProtos;
|
||||
import org.apache.hadoop.scm.ScmInfo;
|
||||
import org.apache.hadoop.scm.container.common.helpers.ContainerInfo;
|
||||
import org.apache.hadoop.scm.protocol.StorageContainerLocationProtocol;
|
||||
|
||||
@ -195,4 +196,20 @@ public PipelineResponseProto allocatePipeline(
|
||||
// TODO : Wiring this up requires one more patch.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OzoneProtos.GetScmInfoRespsonseProto getScmInfo(
|
||||
RpcController controller, OzoneProtos.GetScmInfoRequestProto req)
|
||||
throws ServiceException {
|
||||
try {
|
||||
ScmInfo scmInfo = impl.getScmInfo();
|
||||
return OzoneProtos.GetScmInfoRespsonseProto.newBuilder()
|
||||
.setClusterId(scmInfo.getClusterId())
|
||||
.setScmId(scmInfo.getScmId())
|
||||
.build();
|
||||
} catch (IOException ex) {
|
||||
throw new ServiceException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user