HDFS-8456. Introduce STORAGE_CONTAINER_SERVICE as a new NodeType. (Contributed by Arpit Agarwal)

This commit is contained in:
Arpit Agarwal 2015-06-15 11:04:02 -07:00
parent e01c6ea688
commit e2f494c2c4
6 changed files with 77 additions and 8 deletions

View File

@ -0,0 +1,9 @@
Breakdown of HDFS-7240 sub-tasks:
HDFS-8210. Ozone: Implement storage container manager. (Jitendra Pandey)
HDFS-8392. Ozone: DataNode support for multiple datasets. (Arpit Agarwal)
HDFS-8456. Ozone: Introduce STORAGE_CONTAINER_SERVICE as a new NodeType.
(Arpit Agarwal)

View File

@ -157,7 +157,8 @@ public class PBHelper {
public static StorageInfoProto convert(StorageInfo info) { public static StorageInfoProto convert(StorageInfo info) {
return StorageInfoProto.newBuilder().setClusterID(info.getClusterID()) return StorageInfoProto.newBuilder().setClusterID(info.getClusterID())
.setCTime(info.getCTime()).setLayoutVersion(info.getLayoutVersion()) .setCTime(info.getCTime()).setLayoutVersion(info.getLayoutVersion())
.setNamespceID(info.getNamespaceID()).build(); .setNamespceID(info.getNamespaceID())
.setNodeType(convert(info.getNodeType())).build();
} }
public static StorageInfo convert(StorageInfoProto info, NodeType type) { public static StorageInfo convert(StorageInfoProto info, NodeType type) {
@ -334,9 +335,43 @@ public class PBHelper {
public static NamespaceInfo convert(NamespaceInfoProto info) { public static NamespaceInfo convert(NamespaceInfoProto info) {
StorageInfoProto storage = info.getStorageInfo(); StorageInfoProto storage = info.getStorageInfo();
// The default node type must be NAME_NODE for wire compatibility.
return new NamespaceInfo(storage.getNamespceID(), storage.getClusterID(), return new NamespaceInfo(storage.getNamespceID(), storage.getClusterID(),
info.getBlockPoolID(), storage.getCTime(), info.getBuildVersion(), info.getBlockPoolID(), storage.getCTime(), info.getBuildVersion(),
info.getSoftwareVersion(), info.getCapabilities()); info.getSoftwareVersion(),
storage.hasNodeType() ? convert(storage.getNodeType()) : NodeType.NAME_NODE,
info.getCapabilities());
}
public static NodeType convert(StorageInfoProto.NodeTypeProto nodeType) {
switch(nodeType) {
case NAME_NODE:
return NodeType.NAME_NODE;
case DATA_NODE:
return NodeType.DATA_NODE;
case JOURNAL_NODE:
return NodeType.JOURNAL_NODE;
case STORAGE_CONTAINER_SERVICE:
return NodeType.STORAGE_CONTAINER_SERVICE;
default:
throw new IllegalArgumentException("Unrecognized NodeType " + nodeType);
}
}
public static StorageInfoProto.NodeTypeProto convert(NodeType nodeType) {
switch(nodeType) {
case NAME_NODE:
return StorageInfoProto.NodeTypeProto.NAME_NODE;
case DATA_NODE:
return StorageInfoProto.NodeTypeProto.DATA_NODE;
case JOURNAL_NODE:
return StorageInfoProto.NodeTypeProto.JOURNAL_NODE;
case STORAGE_CONTAINER_SERVICE:
return StorageInfoProto.NodeTypeProto.STORAGE_CONTAINER_SERVICE;
default:
throw new IllegalArgumentException("Unrecognized NodeType " + nodeType);
}
} }
public static NamenodeCommand convert(NamenodeCommandProto cmd) { public static NamenodeCommand convert(NamenodeCommandProto cmd) {

View File

@ -92,7 +92,8 @@ public interface HdfsServerConstants {
enum NodeType { enum NodeType {
NAME_NODE, NAME_NODE,
DATA_NODE, DATA_NODE,
JOURNAL_NODE JOURNAL_NODE,
STORAGE_CONTAINER_SERVICE
} }
/** Startup options for rolling upgrade. */ /** Startup options for rolling upgrade. */

View File

@ -256,4 +256,8 @@ public class StorageInfo {
} }
return props; return props;
} }
public NodeType getNodeType() {
return storageType;
}
} }

View File

@ -76,7 +76,12 @@ public class NamespaceInfo extends StorageInfo {
// defaults to enabled capabilites since this ctor is for server // defaults to enabled capabilites since this ctor is for server
public NamespaceInfo() { public NamespaceInfo() {
super(NodeType.NAME_NODE); this(NodeType.NAME_NODE);
}
// defaults to enabled capabilites since this ctor is for server
public NamespaceInfo(NodeType nodeType) {
super(nodeType);
buildVersion = null; buildVersion = null;
capabilities = CAPABILITIES_SUPPORTED; capabilities = CAPABILITIES_SUPPORTED;
} }
@ -84,16 +89,17 @@ public class NamespaceInfo extends StorageInfo {
// defaults to enabled capabilites since this ctor is for server // defaults to enabled capabilites since this ctor is for server
public NamespaceInfo(int nsID, String clusterID, String bpID, public NamespaceInfo(int nsID, String clusterID, String bpID,
long cT, String buildVersion, String softwareVersion) { long cT, String buildVersion, String softwareVersion) {
this(nsID, clusterID, bpID, cT, buildVersion, softwareVersion, this(nsID, clusterID, bpID, cT, buildVersion,
CAPABILITIES_SUPPORTED); softwareVersion, NodeType.NAME_NODE,
CAPABILITIES_SUPPORTED);
} }
// for use by server and/or client // for use by server and/or client
public NamespaceInfo(int nsID, String clusterID, String bpID, public NamespaceInfo(int nsID, String clusterID, String bpID,
long cT, String buildVersion, String softwareVersion, long cT, String buildVersion, String softwareVersion,
long capabilities) { NodeType nodeType, long capabilities) {
super(HdfsServerConstants.NAMENODE_LAYOUT_VERSION, nsID, clusterID, cT, super(HdfsServerConstants.NAMENODE_LAYOUT_VERSION, nsID, clusterID, cT,
NodeType.NAME_NODE); nodeType);
blockPoolID = bpID; blockPoolID = bpID;
this.buildVersion = buildVersion; this.buildVersion = buildVersion;
this.softwareVersion = softwareVersion; this.softwareVersion = softwareVersion;
@ -106,6 +112,12 @@ public class NamespaceInfo extends StorageInfo {
VersionInfo.getVersion()); VersionInfo.getVersion());
} }
public NamespaceInfo(int nsID, String clusterID, String bpID,
long cT, NodeType nodeType) {
this(nsID, clusterID, bpID, cT, Storage.getBuildVersion(),
VersionInfo.getVersion(), nodeType, CAPABILITIES_SUPPORTED);
}
public long getCapabilities() { public long getCapabilities() {
return capabilities; return capabilities;
} }

View File

@ -184,6 +184,14 @@ message StorageInfoProto {
required uint32 namespceID = 2; // File system namespace ID required uint32 namespceID = 2; // File system namespace ID
required string clusterID = 3; // ID of the cluster required string clusterID = 3; // ID of the cluster
required uint64 cTime = 4; // File system creation time required uint64 cTime = 4; // File system creation time
enum NodeTypeProto {
NAME_NODE = 1;
DATA_NODE = 2;
JOURNAL_NODE = 3;
STORAGE_CONTAINER_SERVICE = 4;
}
optional NodeTypeProto nodeType = 5;
} }
/** /**