You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by el...@apache.org on 2018/09/05 11:19:30 UTC
hadoop git commit: HDDS-315. ozoneShell infoKey does not work for
directories created as key and throws 'KEY_NOT_FOUND' error. Contributed by
Dinesh Chitlangia.
Repository: hadoop
Updated Branches:
refs/heads/trunk 85c3fe341 -> c7403a448
HDDS-315. ozoneShell infoKey does not work for directories created as key and throws 'KEY_NOT_FOUND' error. Contributed by Dinesh Chitlangia.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c7403a44
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c7403a44
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c7403a44
Branch: refs/heads/trunk
Commit: c7403a448d42ce75fd936d6f8ebfc3bfc419ba07
Parents: 85c3fe3
Author: Márton Elek <el...@apache.org>
Authored: Wed Sep 5 12:40:44 2018 +0200
Committer: Márton Elek <el...@apache.org>
Committed: Wed Sep 5 12:41:06 2018 +0200
----------------------------------------------------------------------
.../hadoop/ozone/ozShell/TestOzoneShell.java | 35 ++++++++++++++++++++
.../ozone/web/ozShell/keys/InfoKeyHandler.java | 7 +++-
2 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/c7403a44/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
index b4740b4..386b1d2 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
@@ -816,6 +816,41 @@ public class TestOzoneShell {
}
@Test
+ public void testInfoDirKey() throws Exception {
+ LOG.info("Running testInfoKey for Dir Key");
+ String dirKeyName = "test/";
+ String keyNameOnly = "test";
+ OzoneBucket bucket = creatBucket();
+ String volumeName = bucket.getVolumeName();
+ String bucketName = bucket.getName();
+ String dataStr = "test-data";
+ OzoneOutputStream keyOutputStream =
+ bucket.createKey(dirKeyName, dataStr.length());
+ keyOutputStream.write(dataStr.getBytes());
+ keyOutputStream.close();
+ String[] args = new String[] {"-infoKey",
+ url + "/" + volumeName + "/" + bucketName + "/" + dirKeyName};
+ // verify the response output
+ int a = ToolRunner.run(shell, args);
+ String output = out.toString();
+ assertEquals(0, a);
+ assertTrue(output.contains(dirKeyName));
+ assertTrue(output.contains("createdOn") &&
+ output.contains("modifiedOn") &&
+ output.contains(OzoneConsts.OZONE_TIME_ZONE));
+ args = new String[] {"-infoKey",
+ url + "/" + volumeName + "/" + bucketName + "/" + keyNameOnly};
+ a = ToolRunner.run(shell, args);
+ output = out.toString();
+ assertEquals(1, a);
+ assertTrue(err.toString().contains(
+ "Lookup key failed, error:KEY_NOT_FOUND"));
+ // reset stream
+ out.reset();
+ err.reset();
+ }
+
+ @Test
public void testListKey() throws Exception {
LOG.info("Running testListKey");
String commandOutput;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/c7403a44/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java
index fe87756..53a3264 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java
@@ -25,6 +25,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.commons.cli.CommandLine;
+import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.client.*;
import org.apache.hadoop.ozone.client.rest.OzoneException;
import org.apache.hadoop.ozone.web.ozShell.Handler;
@@ -64,8 +65,12 @@ public class InfoKeyHandler extends Handler {
volumeName = path.getName(0).toString();
bucketName = path.getName(1).toString();
- keyName = path.getName(2).toString();
+ String searchString = volumeName + OzoneConsts.OZONE_URI_DELIMITER +
+ bucketName + OzoneConsts.OZONE_URI_DELIMITER;
+
+ keyName = ozoneURIString.substring(ozoneURIString.indexOf(searchString) +
+ searchString.length());
if (cmd.hasOption(Shell.VERBOSE)) {
System.out.printf("Volume Name : %s%n", volumeName);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org