From 7e228e54c56598e263d66e3ef74476e12a3b1f30 Mon Sep 17 00:00:00 2001 From: Bharat Viswanadham Date: Mon, 11 Jun 2018 13:14:03 -0700 Subject: [PATCH] HDDS-136:Rename dbPath,containerFilePath. Contributed by Bharat Viswanadham --- .../common/impl/KeyValueContainerData.java | 34 +++++++++---------- .../container/common/impl/KeyValueYaml.java | 9 ++--- .../common/TestKeyValueContainerData.java | 8 ++--- .../common/impl/TestKeyValueYaml.java | 16 ++++----- .../test/resources/additionalfields.container | 7 ++-- .../src/test/resources/incorrect.container | 7 ++-- 6 files changed, 41 insertions(+), 40 deletions(-) diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyValueContainerData.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyValueContainerData.java index 57b5264331..08899138fb 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyValueContainerData.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyValueContainerData.java @@ -30,11 +30,11 @@ */ public class KeyValueContainerData extends ContainerData { - // Path to Level DB/RocksDB Store. - private String dbPath; + // Path to Container metadata Level DB/RocksDB Store and .container file. + private String metadataPath; - // Path to Physical file system where container and checksum are stored. - private String containerFilePath; + // Path to Physical file system where chunks are stored. + private String chunksPath; //Type of DB used to store key to chunks mapping private String containerDBType; @@ -64,37 +64,37 @@ public KeyValueContainerData(ContainerProtos.ContainerType type, long id, this.numPendingDeletionBlocks = 0; } /** - * Returns path. + * Returns container metadata path. * * @return - path */ - public String getDbPath() { - return dbPath; + public String getMetadataPath() { + return metadataPath; } /** - * Sets path. + * Sets container metadata path. * * @param path - String. */ - public void setDbPath(String path) { - this.dbPath = path; + public void setMetadataPath(String path) { + this.metadataPath = path; } /** - * Get container file path. + * Get chunks path. * @return - Physical path where container file and checksum is stored. */ - public String getContainerFilePath() { - return containerFilePath; + public String getChunksPath() { + return chunksPath; } /** - * Set container Path. - * @param containerPath - File path. + * Set chunks Path. + * @param chunkPath - File path. */ - public void setContainerFilePath(String containerPath) { - this.containerFilePath = containerPath; + public void setChunksPath(String chunkPath) { + this.chunksPath = chunkPath; } /** diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyValueYaml.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyValueYaml.java index b7ce0d96cb..d22092c265 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyValueYaml.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyValueYaml.java @@ -144,8 +144,8 @@ protected Set getProperties(Class type) // When a new field needs to be added, it needs to be added here. if (name.equals("containerType") || name.equals("containerId") || name.equals("layOutVersion") || name.equals("state") || - name.equals("metadata") || name.equals("dbPath") || - name.equals("containerFilePath") || name.equals( + name.equals("metadata") || name.equals("metadataPath") || + name.equals("chunksPath") || name.equals( "containerDBType")) { filtered.add(prop); } @@ -186,8 +186,9 @@ public Object construct(Node node) { KeyValueContainerData kvData = new KeyValueContainerData(containerType, (long) nodes.get("containerId"), lv); kvData.setContainerDBType((String)nodes.get("containerDBType")); - kvData.setDbPath((String) nodes.get("dbPath")); - kvData.setContainerFilePath((String) nodes.get("containerFilePath")); + kvData.setMetadataPath((String) nodes.get( + "metadataPath")); + kvData.setChunksPath((String) nodes.get("chunksPath")); Map meta = (Map) nodes.get("metadata"); meta.forEach((key, val) -> { try { diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestKeyValueContainerData.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestKeyValueContainerData.java index e057f6f7cd..055110cd39 100644 --- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestKeyValueContainerData.java +++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestKeyValueContainerData.java @@ -92,8 +92,8 @@ public void testKeyValueData() { kvData.setState(state); kvData.setContainerDBType(containerDBType); - kvData.setContainerFilePath(path); - kvData.setDbPath(path); + kvData.setChunksPath(path); + kvData.setMetadataPath(path); kvData.incrReadBytes(10); kvData.incrWriteBytes(10); kvData.incrReadCount(); @@ -101,8 +101,8 @@ public void testKeyValueData() { assertEquals(state, kvData.getState()); assertEquals(containerDBType, kvData.getContainerDBType()); - assertEquals(path, kvData.getContainerFilePath()); - assertEquals(path, kvData.getDbPath()); + assertEquals(path, kvData.getChunksPath()); + assertEquals(path, kvData.getMetadataPath()); assertEquals(10, kvData.getReadBytes()); assertEquals(10, kvData.getWriteBytes()); diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestKeyValueYaml.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestKeyValueYaml.java index 06f6f9d799..8550c4727e 100644 --- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestKeyValueYaml.java +++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestKeyValueYaml.java @@ -47,8 +47,8 @@ public void testCreateContainerFile() throws IOException { KeyValueContainerData keyValueContainerData = new KeyValueContainerData( ContainerProtos.ContainerType.KeyValueContainer, Long.MAX_VALUE); keyValueContainerData.setContainerDBType("RocksDB"); - keyValueContainerData.setDbPath(path); - keyValueContainerData.setContainerFilePath(path); + keyValueContainerData.setMetadataPath(path); + keyValueContainerData.setChunksPath(path); File containerFile = new File(filePath, containerPath); @@ -65,8 +65,8 @@ public void testCreateContainerFile() throws IOException { assertEquals(ContainerProtos.ContainerType.KeyValueContainer, kvData .getContainerType()); assertEquals("RocksDB", kvData.getContainerDBType()); - assertEquals(path, kvData.getContainerFilePath()); - assertEquals(path, kvData.getDbPath()); + assertEquals(path, kvData.getMetadataPath()); + assertEquals(path, kvData.getChunksPath()); assertEquals(ContainerProtos.ContainerLifeCycleState.OPEN, kvData .getState()); assertEquals(1, kvData.getLayOutVersion()); @@ -90,8 +90,8 @@ public void testCreateContainerFile() throws IOException { assertEquals(ContainerProtos.ContainerType.KeyValueContainer, kvData .getContainerType()); assertEquals("RocksDB", kvData.getContainerDBType()); - assertEquals(path, kvData.getContainerFilePath()); - assertEquals(path, kvData.getDbPath()); + assertEquals(path, kvData.getMetadataPath()); + assertEquals(path, kvData.getChunksPath()); assertEquals(ContainerProtos.ContainerLifeCycleState.CLOSED, kvData .getState()); assertEquals(1, kvData.getLayOutVersion()); @@ -143,9 +143,9 @@ public void testCheckBackWardCompatabilityOfContainerFile() throws .getContainerType()); assertEquals(9223372036854775807L, kvData.getContainerId()); assertEquals("/hdds/current/aed-fg4-hji-jkl/containerdir0/1", kvData - .getDbPath()); + .getChunksPath()); assertEquals("/hdds/current/aed-fg4-hji-jkl/containerdir0/1", kvData - .getContainerFilePath()); + .getMetadataPath()); assertEquals(1, kvData.getLayOutVersion()); assertEquals(2, kvData.getMetadata().size()); diff --git a/hadoop-hdds/container-service/src/test/resources/additionalfields.container b/hadoop-hdds/container-service/src/test/resources/additionalfields.container index d0df0fec39..b19ec44dfb 100644 --- a/hadoop-hdds/container-service/src/test/resources/additionalfields.container +++ b/hadoop-hdds/container-service/src/test/resources/additionalfields.container @@ -1,9 +1,10 @@ ! containerDBType: RocksDB -containerFilePath: /hdds/current/aed-fg4-hji-jkl/containerdir0/1 +chunksPath: /hdds/current/aed-fg4-hji-jkl/containerdir0/1 containerId: 9223372036854775807 containerType: KeyValueContainer -dbPath: /hdds/current/aed-fg4-hji-jkl/containerdir0/1 +metadataPath: /hdds/current/aed-fg4-hji-jkl/containerdir0/1 layOutVersion: 1 metadata: {OWNER: ozone, VOLUME: hdfs} -state: CLOSED \ No newline at end of file +state: CLOSED +aclEnabled: true \ No newline at end of file diff --git a/hadoop-hdds/container-service/src/test/resources/incorrect.container b/hadoop-hdds/container-service/src/test/resources/incorrect.container index d56702377c..0d2bfd1897 100644 --- a/hadoop-hdds/container-service/src/test/resources/incorrect.container +++ b/hadoop-hdds/container-service/src/test/resources/incorrect.container @@ -1,10 +1,9 @@ ! containerDBType: RocksDB -containerFilePath: /hdds/current/aed-fg4-hji-jkl/containerdir0/1 +chunksPath: /hdds/current/aed-fg4-hji-jkl/containerdir0/1 containerId: 9223372036854775807 containerType: KeyValueContainer -dbPath: /hdds/current/aed-fg4-hji-jkl/containerdir0/1 +metadataPath: /hdds/current/aed-fg4-hji-jkl/containerdir0/1 layOutVersion: 1 metadata: {OWNER: ozone, VOLUME: hdfs} -state: INVALID -aclEnabled: true \ No newline at end of file +state: INVALID \ No newline at end of file