-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-6611. Remove chunksPath and metadataPath from container yaml file #7930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
08d012b
22932f7
8edb068
25ff254
55720bd
b3c584d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -243,6 +243,9 @@ private OzoneConsts() { | |||||||||||||||||||||||
| // V3: Column families definitions are close to V2, | ||||||||||||||||||||||||
| // but have containerID as key prefixes. | ||||||||||||||||||||||||
| public static final String SCHEMA_V3 = "3"; | ||||||||||||||||||||||||
| // V4: Column families is same as V3, | ||||||||||||||||||||||||
| // removed chunkPath and metadataPath in .container file | ||||||||||||||||||||||||
|
Comment on lines
+246
to
+247
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| public static final String SCHEMA_V4 = "4"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Supported store types. | ||||||||||||||||||||||||
| public static final String OZONE = "ozone"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -201,7 +201,7 @@ public static void verifyChecksum(ContainerData containerData, | |||||||
| String storedChecksum = containerData.getChecksum(); | ||||||||
|
|
||||||||
| Yaml yaml = ContainerDataYaml.getYamlForContainerType( | ||||||||
| containerData.getContainerType(), | ||||||||
| containerData.getContainerType(), containerData, | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| containerData instanceof KeyValueContainerData && | ||||||||
| ((KeyValueContainerData)containerData).getReplicaIndex() > 0); | ||||||||
| containerData.computeAndSetChecksum(yaml); | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,12 @@ | |||||
|
|
||||||
| package org.apache.hadoop.ozone.container.common.impl; | ||||||
|
|
||||||
| import static org.apache.hadoop.ozone.OzoneConsts.CHUNKS_PATH; | ||||||
| import static org.apache.hadoop.ozone.OzoneConsts.METADATA_PATH; | ||||||
| import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER; | ||||||
| import static org.apache.hadoop.ozone.OzoneConsts.REPLICA_INDEX; | ||||||
| import static org.apache.hadoop.ozone.OzoneConsts.SCHEMA_V4; | ||||||
| import static org.apache.hadoop.ozone.OzoneConsts.STORAGE_DIR_CHUNKS; | ||||||
| import static org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerData.KEYVALUE_YAML_TAG; | ||||||
|
|
||||||
| import com.google.common.base.Preconditions; | ||||||
|
|
@@ -88,7 +93,7 @@ public static void createContainerFile(ContainerType containerType, | |||||
| ((KeyValueContainerData) containerData).getReplicaIndex() > 0; | ||||||
|
|
||||||
| // Create Yaml for given container type | ||||||
| Yaml yaml = getYamlForContainerType(containerType, withReplicaIndex); | ||||||
| Yaml yaml = getYamlForContainerType(containerType, containerData, withReplicaIndex); | ||||||
| // Compute Checksum and update ContainerData | ||||||
| containerData.computeAndSetChecksum(yaml); | ||||||
|
|
||||||
|
|
@@ -122,9 +127,16 @@ public static ContainerData readContainerFile(File containerFile) | |||||
| throws IOException { | ||||||
| Preconditions.checkNotNull(containerFile, "containerFile cannot be null"); | ||||||
| try (FileInputStream inputFileStream = new FileInputStream(containerFile)) { | ||||||
| return readContainer(inputFileStream); | ||||||
| KeyValueContainerData containerData = (KeyValueContainerData) readContainer(inputFileStream); | ||||||
| if (containerData.getChunksPath() == null) { | ||||||
| containerData.setChunksPath(containerFile.getParentFile().getParentFile().getAbsolutePath() | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move |
||||||
| .concat(OZONE_URI_DELIMITER).concat(STORAGE_DIR_CHUNKS)); | ||||||
| } | ||||||
| if (containerData.getMetadataPath() == null) { | ||||||
| containerData.setMetadataPath(containerFile.getParentFile().getAbsolutePath()); | ||||||
| } | ||||||
| return containerData; | ||||||
| } | ||||||
|
|
||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -183,11 +195,12 @@ public static ContainerData readContainer(InputStream input) | |||||
| * the container properties. | ||||||
| * | ||||||
| * @param containerType type of container | ||||||
| * @parm ContainerData container data | ||||||
| * @param withReplicaIndex in the container yaml | ||||||
| * @return Yamal representation of container properties | ||||||
| * @throws StorageContainerException if the type is unrecognized | ||||||
| */ | ||||||
| public static Yaml getYamlForContainerType(ContainerType containerType, | ||||||
| public static Yaml getYamlForContainerType(ContainerType containerType, ContainerData containerData, | ||||||
| boolean withReplicaIndex) | ||||||
| throws StorageContainerException { | ||||||
| PropertyUtils propertyUtils = new PropertyUtils(); | ||||||
|
|
@@ -201,6 +214,11 @@ public static Yaml getYamlForContainerType(ContainerType containerType, | |||||
| yamlFields = new ArrayList<>(yamlFields); | ||||||
| yamlFields.add(REPLICA_INDEX); | ||||||
| } | ||||||
| if (((KeyValueContainerData)containerData).olderSchemaThan(SCHEMA_V4)) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| yamlFields = new ArrayList<>(yamlFields); | ||||||
| yamlFields.add(METADATA_PATH); | ||||||
| yamlFields.add(CHUNKS_PATH); | ||||||
| } | ||||||
| Representer representer = new ContainerDataRepresenter(yamlFields); | ||||||
| representer.setPropertyUtils(propertyUtils); | ||||||
| representer.addClassTag( | ||||||
|
|
@@ -299,9 +317,12 @@ public Object construct(Node node) { | |||||
|
|
||||||
| kvData.setContainerDBType((String)nodes.get( | ||||||
| OzoneConsts.CONTAINER_DB_TYPE)); | ||||||
| kvData.setMetadataPath((String) nodes.get( | ||||||
| OzoneConsts.METADATA_PATH)); | ||||||
| kvData.setChunksPath((String) nodes.get(OzoneConsts.CHUNKS_PATH)); | ||||||
| String schemaVersion = (String) nodes.get(OzoneConsts.SCHEMA_VERSION); | ||||||
| kvData.setSchemaVersion(schemaVersion); | ||||||
| if (kvData.olderSchemaThan(SCHEMA_V4)) { | ||||||
| kvData.setMetadataPath((String) nodes.get(OzoneConsts.METADATA_PATH)); | ||||||
| kvData.setChunksPath((String) nodes.get(OzoneConsts.CHUNKS_PATH)); | ||||||
| } | ||||||
| Map<String, String> meta = (Map) nodes.get(OzoneConsts.METADATA); | ||||||
| kvData.setMetadata(meta); | ||||||
| kvData.setChecksum((String) nodes.get(OzoneConsts.CHECKSUM)); | ||||||
|
|
@@ -310,8 +331,6 @@ public Object construct(Node node) { | |||||
| String state = (String) nodes.get(OzoneConsts.STATE); | ||||||
| kvData | ||||||
| .setState(ContainerProtos.ContainerDataProto.State.valueOf(state)); | ||||||
| String schemaVersion = (String) nodes.get(OzoneConsts.SCHEMA_VERSION); | ||||||
| kvData.setSchemaVersion(schemaVersion); | ||||||
| final Object replicaIndex = nodes.get(REPLICA_INDEX); | ||||||
| if (replicaIndex != null) { | ||||||
| kvData.setReplicaIndex( | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,8 +31,10 @@ | |||||||
| import static org.apache.hadoop.ozone.OzoneConsts.SCHEMA_V1; | ||||||||
| import static org.apache.hadoop.ozone.OzoneConsts.SCHEMA_V2; | ||||||||
| import static org.apache.hadoop.ozone.OzoneConsts.SCHEMA_V3; | ||||||||
| import static org.apache.hadoop.ozone.OzoneConsts.SCHEMA_V4; | ||||||||
| import static org.apache.hadoop.ozone.OzoneConsts.SCHEMA_VERSION; | ||||||||
| import static org.apache.hadoop.ozone.container.metadata.DatanodeSchemaThreeDBDefinition.getContainerKeyPrefix; | ||||||||
| import static org.apache.hadoop.ozone.container.upgrade.VersionedDatanodeFeatures.isFinalized; | ||||||||
|
|
||||||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | ||||||||
| import com.google.common.base.Preconditions; | ||||||||
|
|
@@ -46,7 +48,9 @@ | |||||||
| import java.util.concurrent.ConcurrentHashMap; | ||||||||
| import java.util.concurrent.atomic.AtomicLong; | ||||||||
| import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos; | ||||||||
| import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto; | ||||||||
| import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos | ||||||||
| .ContainerDataProto; | ||||||||
| import org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature; | ||||||||
| import org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilter; | ||||||||
| import org.apache.hadoop.hdds.utils.db.BatchOperation; | ||||||||
| import org.apache.hadoop.hdds.utils.db.Table; | ||||||||
|
|
@@ -68,6 +72,8 @@ public class KeyValueContainerData extends ContainerData { | |||||||
|
|
||||||||
| // Fields need to be stored in .container file. | ||||||||
| private static final List<String> KV_YAML_FIELDS; | ||||||||
| // Fields need to be stored in .container file for Schema V4; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| private static final List<String> KV_YAML_FIELDS_SCHEMA_V4; | ||||||||
|
|
||||||||
| // Path to Container metadata Level DB/RocksDB Store and .container file. | ||||||||
| private String metadataPath; | ||||||||
|
|
@@ -98,6 +104,11 @@ public class KeyValueContainerData extends ContainerData { | |||||||
| KV_YAML_FIELDS.add(CHUNKS_PATH); | ||||||||
| KV_YAML_FIELDS.add(CONTAINER_DB_TYPE); | ||||||||
| KV_YAML_FIELDS.add(SCHEMA_VERSION); | ||||||||
|
|
||||||||
| KV_YAML_FIELDS_SCHEMA_V4 = Lists.newArrayList(); | ||||||||
| KV_YAML_FIELDS_SCHEMA_V4.addAll(YAML_FIELDS); | ||||||||
| KV_YAML_FIELDS_SCHEMA_V4.add(CONTAINER_DB_TYPE); | ||||||||
| KV_YAML_FIELDS_SCHEMA_V4.add(SCHEMA_VERSION); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
|
|
@@ -150,7 +161,7 @@ public String getSchemaVersion() { | |||||||
| * @throws UnsupportedOperationException If no valid schema version is found. | ||||||||
| */ | ||||||||
| public String getSupportedSchemaVersionOrDefault() { | ||||||||
| String[] versions = {SCHEMA_V1, SCHEMA_V2, SCHEMA_V3}; | ||||||||
| String[] versions = {SCHEMA_V1, SCHEMA_V2, SCHEMA_V3, SCHEMA_V4}; | ||||||||
|
|
||||||||
| for (String version : versions) { | ||||||||
| if (this.hasSchema(version)) { | ||||||||
|
|
@@ -336,7 +347,10 @@ public ContainerDataProto getProtoBufMessage() { | |||||||
| } | ||||||||
|
|
||||||||
| public static List<String> getYamlFields() { | ||||||||
| return Collections.unmodifiableList(KV_YAML_FIELDS); | ||||||||
| List<String> list = isFinalized(HDDSLayoutFeature.DATANODE_SCHEMA_V4) | ||||||||
| ? KV_YAML_FIELDS_SCHEMA_V4 | ||||||||
| : KV_YAML_FIELDS; | ||||||||
| return Collections.unmodifiableList(list); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
|
|
@@ -426,7 +440,7 @@ public KeyPrefixFilter getDeletingBlockKeyFilter() { | |||||||
| * for other schemas just return null. | ||||||||
| */ | ||||||||
| public String startKeyEmpty() { | ||||||||
| if (hasSchema(SCHEMA_V3)) { | ||||||||
| if (sharedDB()) { | ||||||||
| return getContainerKeyPrefix(getContainerID()); | ||||||||
| } | ||||||||
| return null; | ||||||||
|
|
@@ -437,7 +451,7 @@ public String startKeyEmpty() { | |||||||
| * for other schemas just return null. | ||||||||
| */ | ||||||||
| public String containerPrefix() { | ||||||||
| if (hasSchema(SCHEMA_V3)) { | ||||||||
| if (sharedDB()) { | ||||||||
| return getContainerKeyPrefix(getContainerID()); | ||||||||
| } | ||||||||
| return ""; | ||||||||
|
|
@@ -451,7 +465,7 @@ public String containerPrefix() { | |||||||
| * @return formatted key | ||||||||
| */ | ||||||||
| private String formatKey(String key) { | ||||||||
| if (hasSchema(SCHEMA_V3)) { | ||||||||
| if (sharedDB()) { | ||||||||
| key = getContainerKeyPrefix(getContainerID()) + key; | ||||||||
| } | ||||||||
| return key; | ||||||||
|
|
@@ -461,4 +475,17 @@ public boolean hasSchema(String version) { | |||||||
| return KeyValueContainerUtil.isSameSchemaVersion(schemaVersion, version); | ||||||||
| } | ||||||||
|
|
||||||||
| public boolean sharedDB() { | ||||||||
| return KeyValueContainerUtil.isSameSchemaVersion(schemaVersion, SCHEMA_V3) || | ||||||||
| KeyValueContainerUtil.isSameSchemaVersion(schemaVersion, SCHEMA_V4); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Whether this container's schema version is lower than @param version. | ||||||||
| */ | ||||||||
| public boolean olderSchemaThan(String version) { | ||||||||
| String target = version != null ? version : SCHEMA_V1; | ||||||||
| String self = schemaVersion != null ? schemaVersion : SCHEMA_V1; | ||||||||
| return Integer.parseInt(self) < Integer.parseInt(target); | ||||||||
| } | ||||||||
| } | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.