diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocol/StorageContainerLocationProtocol.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocol/StorageContainerLocationProtocol.java index 90023bc565..07d3f0d719 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocol/StorageContainerLocationProtocol.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocol/StorageContainerLocationProtocol.java @@ -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; } diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java index c47abd4691..061f0fe359 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java @@ -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 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) { diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java index 53fd20283c..0ac322de9c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java @@ -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; diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/Ozone.proto b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/Ozone.proto index 29bc284c2f..cf5a1e98ad 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/Ozone.proto +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/Ozone.proto @@ -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; diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/ScmBlockLocationProtocol.proto b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/ScmBlockLocationProtocol.proto index b6fd1bd524..8a6359b908 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/ScmBlockLocationProtocol.proto +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/ScmBlockLocationProtocol.proto @@ -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); } diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/StorageContainerLocationProtocol.proto b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/StorageContainerLocationProtocol.proto index 735d5bc4c2..e65f51be6b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/StorageContainerLocationProtocol.proto +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/proto/StorageContainerLocationProtocol.proto @@ -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); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/protocolPB/ScmBlockLocationProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/protocolPB/ScmBlockLocationProtocolServerSideTranslatorPB.java index 9bf1e8dbb7..9bdfe983f5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/protocolPB/ScmBlockLocationProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/protocolPB/ScmBlockLocationProtocolServerSideTranslatorPB.java @@ -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(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/protocolPB/StorageContainerLocationProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/protocolPB/StorageContainerLocationProtocolServerSideTranslatorPB.java index f73bf22e71..df1fa40418 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/protocolPB/StorageContainerLocationProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/protocolPB/StorageContainerLocationProtocolServerSideTranslatorPB.java @@ -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); + } + + } }