HDFS-12901. Ozone: SCM: Expose StorageContainerManager#getScmId through container protocol. Contributed by Nanda kumar.

This commit is contained in:
Anu Engineer 2017-12-06 13:59:29 -08:00 committed by Owen O'Malley
parent 11473b8204
commit 74362cb503
8 changed files with 69 additions and 28 deletions

View File

@ -22,6 +22,7 @@ import java.util.EnumSet;
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 @@ public interface StorageContainerLocationProtocol {
* @throws IOException
*/
void closeContainer(String containerName) throws IOException;
/**
* Returns information about SCM.
*
* @return {@link ScmInfo}
* @throws IOException
*/
ScmInfo getScmInfo() throws IOException;
}

View File

@ -33,8 +33,6 @@ import org.apache.hadoop.ozone.protocol.proto.ScmBlockLocationProtocolProtos.Del
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 final class ScmBlockLocationProtocolClientSideTranslatorPB
*/
@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) {

View File

@ -25,6 +25,7 @@ import org.apache.hadoop.ipc.ProtobufHelper;
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 final class StorageContainerLocationProtocolClientSideTranslatorPB
}
}
@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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -22,6 +22,7 @@ import com.google.protobuf.RpcController;
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 @@ 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 java.io.IOException;
import java.util.List;
@ -155,15 +152,16 @@ public final class ScmBlockLocationProtocolServerSideTranslatorPB
}
@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();

View File

@ -29,6 +29,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
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 final class StorageContainerLocationProtocolServerSideTranslatorPB
// 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);
}
}
}