HDDS-71. Send ContainerType to Datanode during container creation. Contributed by Bharat Viswanadham.
This commit is contained in:
parent
73e9120ad7
commit
132a547dea
@ -243,6 +243,8 @@ public static void createContainer(XceiverClientSpi client, long containerID,
|
||||
ContainerProtos.ContainerData.Builder containerData = ContainerProtos
|
||||
.ContainerData.newBuilder();
|
||||
containerData.setContainerID(containerID);
|
||||
containerData.setContainerType(ContainerProtos.ContainerType
|
||||
.KeyValueContainer);
|
||||
createRequest.setContainerData(containerData.build());
|
||||
|
||||
String id = client.getPipeline().getLeader().getUuidString();
|
||||
|
@ -225,6 +225,12 @@ message ContainerData {
|
||||
optional int64 size = 7;
|
||||
optional int64 keyCount = 8;
|
||||
optional ContainerLifeCycleState state = 9 [default = OPEN];
|
||||
optional ContainerType containerType = 10 [default = KeyValueContainer];
|
||||
optional string containerDBType = 11;
|
||||
}
|
||||
|
||||
enum ContainerType {
|
||||
KeyValueContainer = 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
|
||||
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
|
||||
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos
|
||||
.ContainerType;
|
||||
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos
|
||||
.ContainerLifeCycleState;
|
||||
import org.apache.hadoop.ozone.OzoneConsts;
|
||||
@ -47,6 +49,8 @@ public class ContainerData {
|
||||
private long maxSize;
|
||||
private long containerID;
|
||||
private ContainerLifeCycleState state;
|
||||
private ContainerType containerType;
|
||||
private String containerDBType;
|
||||
|
||||
/**
|
||||
* Constructs a ContainerData Object.
|
||||
@ -99,9 +103,26 @@ public static ContainerData getFromProtBuf(
|
||||
if (protoData.hasSize()) {
|
||||
data.setMaxSize(protoData.getSize());
|
||||
}
|
||||
|
||||
if(protoData.hasContainerType()) {
|
||||
data.setContainerType(protoData.getContainerType());
|
||||
}
|
||||
|
||||
if(protoData.hasContainerDBType()) {
|
||||
data.setContainerDBType(protoData.getContainerDBType());
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getContainerDBType() {
|
||||
return containerDBType;
|
||||
}
|
||||
|
||||
public void setContainerDBType(String containerDBType) {
|
||||
this.containerDBType = containerDBType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ProtoBuf Message from ContainerData.
|
||||
*
|
||||
@ -141,9 +162,24 @@ public ContainerProtos.ContainerData getProtoBufMessage() {
|
||||
builder.setSize(this.getMaxSize());
|
||||
}
|
||||
|
||||
if(this.getContainerType() != null) {
|
||||
builder.setContainerType(containerType);
|
||||
}
|
||||
|
||||
if(this.getContainerDBType() != null) {
|
||||
builder.setContainerDBType(containerDBType);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void setContainerType(ContainerType containerType) {
|
||||
this.containerType = containerType;
|
||||
}
|
||||
|
||||
public ContainerType getContainerType() {
|
||||
return this.containerType;
|
||||
}
|
||||
/**
|
||||
* Adds metadata.
|
||||
*/
|
||||
|
@ -42,6 +42,7 @@
|
||||
import org.apache.hadoop.hdds.protocol.proto
|
||||
.StorageContainerDatanodeProtocolProtos.StorageTypeProto;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.apache.hadoop.ozone.OzoneConfigKeys;
|
||||
import org.apache.hadoop.ozone.OzoneConsts;
|
||||
import org.apache.hadoop.ozone.container.common.helpers.ContainerData;
|
||||
import org.apache.hadoop.ozone.container.common.helpers.ContainerUtils;
|
||||
@ -400,6 +401,12 @@ private void writeContainerInfo(ContainerData containerData,
|
||||
.toString());
|
||||
containerData.setContainerPath(containerFile.toString());
|
||||
|
||||
if(containerData.getContainerDBType() == null) {
|
||||
String impl = conf.getTrimmed(OzoneConfigKeys.OZONE_METADATA_STORE_IMPL,
|
||||
OzoneConfigKeys.OZONE_METADATA_STORE_IMPL_DEFAULT);
|
||||
containerData.setContainerDBType(impl);
|
||||
}
|
||||
|
||||
ContainerProtos.ContainerData protoData = containerData
|
||||
.getProtoBufMessage();
|
||||
protoData.writeDelimitedTo(dos);
|
||||
|
Loading…
Reference in New Issue
Block a user