HDDS-424. Consolidate ozone oz parameters to use GNU convention.
Contributed by Elek, Marton.
This commit is contained in:
parent
1d567c25d0
commit
a406f6f60e
|
@ -27,13 +27,12 @@ import com.google.common.annotations.VisibleForTesting;
|
|||
import picocli.CommandLine;
|
||||
import picocli.CommandLine.ExecutionException;
|
||||
import picocli.CommandLine.Option;
|
||||
import picocli.CommandLine.ParameterException;
|
||||
import picocli.CommandLine.RunLast;
|
||||
|
||||
/**
|
||||
* This is a generic parent class for all the ozone related cli tools.
|
||||
*/
|
||||
public class GenericCli implements Callable<Void> {
|
||||
public class GenericCli implements Callable<Void>, GenericParentCommand {
|
||||
|
||||
@Option(names = {"--verbose"},
|
||||
description = "More verbose output. Show the stack trace of the errors.")
|
||||
|
@ -72,7 +71,7 @@ public class GenericCli implements Callable<Void> {
|
|||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
throw new ParameterException(cmd, "Please choose a subcommand");
|
||||
throw new MissingSubcommandException();
|
||||
}
|
||||
|
||||
public OzoneConfiguration createOzoneConfiguration() {
|
||||
|
@ -86,12 +85,13 @@ public class GenericCli implements Callable<Void> {
|
|||
return ozoneConf;
|
||||
}
|
||||
|
||||
public boolean isVerbose() {
|
||||
return verbose;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public picocli.CommandLine getCmd() {
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerbose() {
|
||||
return verbose;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.apache.hadoop.hdds.cli;
|
||||
|
||||
/**
|
||||
* Interface to access the higher level parameters.
|
||||
*/
|
||||
public interface GenericParentCommand {
|
||||
|
||||
boolean isVerbose();
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hdds.cli;
|
||||
|
||||
/**
|
||||
* Exception to throw if subcommand is not selected but required.
|
||||
*/
|
||||
public class MissingSubcommandException extends RuntimeException {
|
||||
|
||||
public MissingSubcommandException() {
|
||||
super("Please select a subcommand");
|
||||
}
|
||||
|
||||
}
|
|
@ -48,39 +48,39 @@ RpcClient without scheme
|
|||
*** Keywords ***
|
||||
Test ozone shell
|
||||
[arguments] ${protocol} ${server} ${volume}
|
||||
${result} = Execute on datanode ozone oz -createVolume ${protocol}${server}/${volume} -user bilbo -quota 100TB -root
|
||||
${result} = Execute on datanode ozone oz volume create ${protocol}${server}/${volume} --user bilbo --quota 100TB --root
|
||||
Should not contain ${result} Failed
|
||||
Should contain ${result} Creating Volume: ${volume}
|
||||
${result} = Execute on datanode ozone oz -listVolume ${protocol}${server}/ -user bilbo | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '.[] | select(.volumeName=="${volume}")'
|
||||
${result} = Execute on datanode ozone oz volume list ${protocol}${server}/ --user bilbo | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '.[] | select(.volumeName=="${volume}")'
|
||||
Should contain ${result} createdOn
|
||||
${result} = Execute on datanode ozone oz -listVolume -user bilbo | grep -Ev 'Removed|DEBUG|ERROR|INFO|TRACE|WARN' | jq -r '.[] | select(.volumeName=="${volume}")'
|
||||
${result} = Execute on datanode ozone oz volume list --user bilbo | grep -Ev 'Removed|DEBUG|ERROR|INFO|TRACE|WARN' | jq -r '.[] | select(.volumeName=="${volume}")'
|
||||
Should contain ${result} createdOn
|
||||
Execute on datanode ozone oz -updateVolume ${protocol}${server}/${volume} -user bill -quota 10TB
|
||||
${result} = Execute on datanode ozone oz -infoVolume ${protocol}${server}/${volume} | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.volumeName=="${volume}") | .owner | .name'
|
||||
Execute on datanode ozone oz volume update ${protocol}${server}/${volume} --user bill --quota 10TB
|
||||
${result} = Execute on datanode ozone oz volume info ${protocol}${server}/${volume} | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.volumeName=="${volume}") | .owner | .name'
|
||||
Should Be Equal ${result} bill
|
||||
${result} = Execute on datanode ozone oz -infoVolume ${protocol}${server}/${volume} | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.volumeName=="${volume}") | .quota | .size'
|
||||
${result} = Execute on datanode ozone oz volume info ${protocol}${server}/${volume} | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.volumeName=="${volume}") | .quota | .size'
|
||||
Should Be Equal ${result} 10
|
||||
Execute on datanode ozone oz -createBucket ${protocol}${server}/${volume}/bb1
|
||||
${result} = Execute on datanode ozone oz -infoBucket ${protocol}${server}/${volume}/bb1 | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.bucketName=="bb1") | .storageType'
|
||||
Execute on datanode ozone oz bucket create ${protocol}${server}/${volume}/bb1
|
||||
${result} = Execute on datanode ozone oz bucket info ${protocol}${server}/${volume}/bb1 | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.bucketName=="bb1") | .storageType'
|
||||
Should Be Equal ${result} DISK
|
||||
${result} = Execute on datanode ozone oz -updateBucket ${protocol}${server}/${volume}/bb1 -addAcl user:frodo:rw,group:samwise:r | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.bucketName=="bb1") | .acls | .[] | select(.name=="samwise") | .type'
|
||||
${result} = Execute on datanode ozone oz bucket update ${protocol}${server}/${volume}/bb1 --addAcl user:frodo:rw,group:samwise:r | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.bucketName=="bb1") | .acls | .[] | select(.name=="samwise") | .type'
|
||||
Should Be Equal ${result} GROUP
|
||||
${result} = Execute on datanode ozone oz -updateBucket ${protocol}${server}/${volume}/bb1 -removeAcl group:samwise:r | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.bucketName=="bb1") | .acls | .[] | select(.name=="frodo") | .type'
|
||||
${result} = Execute on datanode ozone oz bucket update ${protocol}${server}/${volume}/bb1 --removeAcl group:samwise:r | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.bucketName=="bb1") | .acls | .[] | select(.name=="frodo") | .type'
|
||||
Should Be Equal ${result} USER
|
||||
${result} = Execute on datanode ozone oz -listBucket ${protocol}${server}/${volume}/ | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '.[] | select(.bucketName=="bb1") | .volumeName'
|
||||
${result} = Execute on datanode ozone oz bucket list ${protocol}${server}/${volume}/ | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '.[] | select(.bucketName=="bb1") | .volumeName'
|
||||
Should Be Equal ${result} ${volume}
|
||||
Run Keyword Test key handling ${protocol} ${server} ${volume}
|
||||
Execute on datanode ozone oz -deleteBucket ${protocol}${server}/${volume}/bb1
|
||||
Execute on datanode ozone oz -deleteVolume ${protocol}${server}/${volume} -user bilbo
|
||||
Execute on datanode ozone oz bucket delete ${protocol}${server}/${volume}/bb1
|
||||
Execute on datanode ozone oz volume delete ${protocol}${server}/${volume} --user bilbo
|
||||
|
||||
Test key handling
|
||||
[arguments] ${protocol} ${server} ${volume}
|
||||
Execute on datanode ozone oz -putKey ${protocol}${server}/${volume}/bb1/key1 -file NOTICE.txt
|
||||
Execute on datanode ozone oz key put ${protocol}${server}/${volume}/bb1/key1 NOTICE.txt
|
||||
Execute on datanode rm -f NOTICE.txt.1
|
||||
Execute on datanode ozone oz -getKey ${protocol}${server}/${volume}/bb1/key1 -file NOTICE.txt.1
|
||||
Execute on datanode ozone oz key get ${protocol}${server}/${volume}/bb1/key1 NOTICE.txt.1
|
||||
Execute on datanode ls -l NOTICE.txt.1
|
||||
${result} = Execute on datanode ozone oz -infoKey ${protocol}${server}/${volume}/bb1/key1 | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.keyName=="key1")'
|
||||
${result} = Execute on datanode ozone oz key info ${protocol}${server}/${volume}/bb1/key1 | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '. | select(.keyName=="key1")'
|
||||
Should contain ${result} createdOn
|
||||
${result} = Execute on datanode ozone oz -listKey ${protocol}${server}/${volume}/bb1 | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '.[] | select(.keyName=="key1") | .keyName'
|
||||
${result} = Execute on datanode ozone oz key list ${protocol}${server}/${volume}/bb1 | grep -Ev 'Removed|WARN|DEBUG|ERROR|INFO|TRACE' | jq -r '.[] | select(.keyName=="key1") | .keyName'
|
||||
Should Be Equal ${result} key1
|
||||
Execute on datanode ozone oz -deleteKey ${protocol}${server}/${volume}/bb1/key1 -v
|
||||
Execute on datanode ozone oz key delete ${protocol}${server}/${volume}/bb1/key1
|
||||
|
|
|
@ -27,13 +27,13 @@ ${PROJECTDIR} ${CURDIR}/../../../../../..
|
|||
|
||||
*** Test Cases ***
|
||||
Create volume and bucket
|
||||
Execute on datanode ozone oz -createVolume http://ozoneManager/fstest -user bilbo -quota 100TB -root
|
||||
Execute on datanode ozone oz -createBucket http://ozoneManager/fstest/bucket1
|
||||
Execute on datanode ozone oz volume create http://ozoneManager/fstest --user bilbo --quota 100TB --root
|
||||
Execute on datanode ozone oz bucket create http://ozoneManager/fstest/bucket1
|
||||
|
||||
Check volume from ozonefs
|
||||
${result} = Execute on datanode ozone fs -ls o3://bucket1.fstest/
|
||||
|
||||
Create directory from ozonefs
|
||||
Execute on datanode ozone fs -mkdir -p o3://bucket1.fstest/testdir/deep
|
||||
${result} = Execute on ozoneManager ozone oz -listKey o3://ozoneManager/fstest/bucket1 | grep -v WARN | jq -r '.[].keyName'
|
||||
${result} = Execute on ozoneManager ozone oz key list o3://ozoneManager/fstest/bucket1 | grep -v WARN | jq -r '.[].keyName'
|
||||
Should contain ${result} testdir/deep
|
||||
|
|
|
@ -218,8 +218,8 @@ public class TestOzoneShell {
|
|||
throws Exception {
|
||||
err.reset();
|
||||
String userName = "bilbo";
|
||||
String[] args = new String[] {"-createVolume", url + "/" + volumeName,
|
||||
"-user", userName, "-root"};
|
||||
String[] args = new String[] {"volume", "create", url + "/" + volumeName,
|
||||
"--user", userName, "--root"};
|
||||
|
||||
if (Strings.isNullOrEmpty(errorMsg)) {
|
||||
execute(shell, args);
|
||||
|
@ -271,7 +271,7 @@ public class TestOzoneShell {
|
|||
OzoneVolume volume = client.getVolumeDetails(volumeName);
|
||||
assertNotNull(volume);
|
||||
|
||||
String[] args = new String[] {"-deleteVolume", url + "/" + volumeName};
|
||||
String[] args = new String[] {"volume", "delete", url + "/" + volumeName};
|
||||
execute(shell, args);
|
||||
String output = out.toString();
|
||||
assertTrue(output.contains("Volume " + volumeName + " is deleted"));
|
||||
|
@ -296,7 +296,7 @@ public class TestOzoneShell {
|
|||
.build();
|
||||
client.createVolume(volumeName, volumeArgs);
|
||||
|
||||
String[] args = new String[] {"-infoVolume", url + "/" + volumeName};
|
||||
String[] args = new String[] {"volume", "info", url + "/" + volumeName};
|
||||
execute(shell, args);
|
||||
|
||||
String output = out.toString();
|
||||
|
@ -305,7 +305,7 @@ public class TestOzoneShell {
|
|||
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||
|
||||
// get info for non-exist volume
|
||||
args = new String[] {"-infoVolume", url + "/invalid-volume"};
|
||||
args = new String[] {"volume", "info", url + "/invalid-volume"};
|
||||
executeWithError(shell, args, "VOLUME_NOT_FOUND");
|
||||
}
|
||||
|
||||
|
@ -323,28 +323,28 @@ public class TestOzoneShell {
|
|||
assertEquals(userName, vol.getOwner());
|
||||
assertEquals(OzoneQuota.parseQuota("100TB").sizeInBytes(), vol.getQuota());
|
||||
|
||||
String[] args = new String[] {"-updateVolume", url + "/" + volumeName,
|
||||
"-quota", "500MB"};
|
||||
String[] args = new String[] {"volume", "update", url + "/" + volumeName,
|
||||
"--quota", "500MB"};
|
||||
execute(shell, args);
|
||||
vol = client.getVolumeDetails(volumeName);
|
||||
assertEquals(userName, vol.getOwner());
|
||||
assertEquals(OzoneQuota.parseQuota("500MB").sizeInBytes(), vol.getQuota());
|
||||
|
||||
String newUser = "new-user";
|
||||
args = new String[] {"-updateVolume", url + "/" + volumeName,
|
||||
"-user", newUser};
|
||||
args = new String[] {"volume", "update", url + "/" + volumeName,
|
||||
"--user", newUser};
|
||||
execute(shell, args);
|
||||
vol = client.getVolumeDetails(volumeName);
|
||||
assertEquals(newUser, vol.getOwner());
|
||||
|
||||
// test error conditions
|
||||
args = new String[] {"-updateVolume", url + "/invalid-volume",
|
||||
"-user", newUser};
|
||||
args = new String[] {"volume", "update", url + "/invalid-volume",
|
||||
"--user", newUser};
|
||||
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
||||
|
||||
err.reset();
|
||||
args = new String[] {"-updateVolume", url + "/invalid-volume",
|
||||
"-quota", "500MB"};
|
||||
args = new String[] {"volume", "update", url + "/invalid-volume",
|
||||
"--quota", "500MB"};
|
||||
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
||||
}
|
||||
|
||||
|
@ -411,14 +411,14 @@ public class TestOzoneShell {
|
|||
assertNotNull(vol);
|
||||
}
|
||||
|
||||
String[] args = new String[] {"-listVolume", url + "/abcde", "-user",
|
||||
user1, "-length", "100"};
|
||||
String[] args = new String[] {"volume", "list", url + "/abcde", "--user",
|
||||
user1, "--length", "100"};
|
||||
executeWithError(shell, args, "Invalid URI");
|
||||
|
||||
err.reset();
|
||||
// test -length option
|
||||
args = new String[] {"-listVolume", url + "/", "-user",
|
||||
user1, "-length", "100"};
|
||||
args = new String[] {"volume", "list", url + "/", "--user",
|
||||
user1, "--length", "100"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
volumes = (List<VolumeInfo>) JsonUtils
|
||||
|
@ -431,8 +431,8 @@ public class TestOzoneShell {
|
|||
}
|
||||
|
||||
out.reset();
|
||||
args = new String[] {"-listVolume", url + "/", "-user",
|
||||
user1, "-length", "2"};
|
||||
args = new String[] {"volume", "list", url + "/", "--user",
|
||||
user1, "--length", "2"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
volumes = (List<VolumeInfo>) JsonUtils
|
||||
|
@ -440,10 +440,11 @@ public class TestOzoneShell {
|
|||
|
||||
assertEquals(2, volumes.size());
|
||||
|
||||
// test -prefix option
|
||||
// test --prefix option
|
||||
out.reset();
|
||||
args = new String[] {"-listVolume", url + "/", "-user", user1, "-length",
|
||||
"100", "-prefix", "test-vol-" + protocol + "1" };
|
||||
args =
|
||||
new String[] {"volume", "list", url + "/", "--user", user1, "--length",
|
||||
"100", "--prefix", "test-vol-" + protocol + "1"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
volumes = (List<VolumeInfo>) JsonUtils
|
||||
|
@ -459,8 +460,9 @@ public class TestOzoneShell {
|
|||
|
||||
// test -start option
|
||||
out.reset();
|
||||
args = new String[] {"-listVolume", url + "/", "-user", user2, "-length",
|
||||
"100", "-start", "test-vol-" + protocol + "15" };
|
||||
args =
|
||||
new String[] {"volume", "list", url + "/", "--user", user2, "--length",
|
||||
"100", "--start", "test-vol-" + protocol + "15"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
volumes = (List<VolumeInfo>) JsonUtils
|
||||
|
@ -475,13 +477,13 @@ public class TestOzoneShell {
|
|||
|
||||
// test error conditions
|
||||
err.reset();
|
||||
args = new String[] {"-listVolume", url + "/", "-user",
|
||||
user2, "-length", "-1"};
|
||||
args = new String[] {"volume", "list", url + "/", "--user",
|
||||
user2, "--length", "-1"};
|
||||
executeWithError(shell, args, "the length should be a positive number");
|
||||
|
||||
err.reset();
|
||||
args = new String[] {"-listVolume", url + "/", "-user",
|
||||
user2, "-length", "invalid-length"};
|
||||
args = new String[] {"volume", "list", url + "/", "--user",
|
||||
user2, "--length", "invalid-length"};
|
||||
executeWithError(shell, args, "For input string: \"invalid-length\"");
|
||||
}
|
||||
|
||||
|
@ -490,7 +492,7 @@ public class TestOzoneShell {
|
|||
LOG.info("Running testCreateBucket");
|
||||
OzoneVolume vol = creatVolume();
|
||||
String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
|
||||
String[] args = new String[] {"-createBucket",
|
||||
String[] args = new String[] {"bucket", "create",
|
||||
url + "/" + vol.getName() + "/" + bucketName};
|
||||
|
||||
execute(shell, args);
|
||||
|
@ -500,7 +502,7 @@ public class TestOzoneShell {
|
|||
assertEquals(bucketName, bucketInfo.getName());
|
||||
|
||||
// test create a bucket in a non-exist volume
|
||||
args = new String[] {"-createBucket",
|
||||
args = new String[] {"bucket", "create",
|
||||
url + "/invalid-volume/" + bucketName};
|
||||
|
||||
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
||||
|
@ -515,7 +517,7 @@ public class TestOzoneShell {
|
|||
OzoneBucket bucketInfo = vol.getBucket(bucketName);
|
||||
assertNotNull(bucketInfo);
|
||||
|
||||
String[] args = new String[] {"-deleteBucket",
|
||||
String[] args = new String[] {"bucket", "delete",
|
||||
url + "/" + vol.getName() + "/" + bucketName};
|
||||
execute(shell, args);
|
||||
|
||||
|
@ -529,13 +531,13 @@ public class TestOzoneShell {
|
|||
}
|
||||
|
||||
// test delete bucket in a non-exist volume
|
||||
args = new String[] {"-deleteBucket",
|
||||
args = new String[] {"bucket", "delete",
|
||||
url + "/invalid-volume" + "/" + bucketName};
|
||||
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
||||
|
||||
err.reset();
|
||||
// test delete non-exist bucket
|
||||
args = new String[] {"-deleteBucket",
|
||||
args = new String[] {"bucket", "delete",
|
||||
url + "/" + vol.getName() + "/invalid-bucket"};
|
||||
executeWithError(shell, args,
|
||||
"Delete Bucket failed, error:BUCKET_NOT_FOUND");
|
||||
|
@ -548,7 +550,7 @@ public class TestOzoneShell {
|
|||
String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
|
||||
vol.createBucket(bucketName);
|
||||
|
||||
String[] args = new String[] {"-infoBucket",
|
||||
String[] args = new String[] {"bucket", "info",
|
||||
url + "/" + vol.getName() + "/" + bucketName};
|
||||
execute(shell, args);
|
||||
|
||||
|
@ -558,7 +560,7 @@ public class TestOzoneShell {
|
|||
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||
|
||||
// test get info from a non-exist bucket
|
||||
args = new String[] {"-infoBucket",
|
||||
args = new String[] {"bucket", "info",
|
||||
url + "/" + vol.getName() + "/invalid-bucket" + bucketName};
|
||||
executeWithError(shell, args,
|
||||
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
||||
|
@ -573,8 +575,8 @@ public class TestOzoneShell {
|
|||
OzoneBucket bucket = vol.getBucket(bucketName);
|
||||
int aclSize = bucket.getAcls().size();
|
||||
|
||||
String[] args = new String[] {"-updateBucket",
|
||||
url + "/" + vol.getName() + "/" + bucketName, "-addAcl",
|
||||
String[] args = new String[] {"bucket", "update",
|
||||
url + "/" + vol.getName() + "/" + bucketName, "--addAcl",
|
||||
"user:frodo:rw,group:samwise:r"};
|
||||
execute(shell, args);
|
||||
String output = out.toString();
|
||||
|
@ -589,8 +591,8 @@ public class TestOzoneShell {
|
|||
&& acl.getType() == OzoneACLType.USER
|
||||
&& acl.getRights()== OzoneACLRights.READ_WRITE);
|
||||
|
||||
args = new String[] {"-updateBucket",
|
||||
url + "/" + vol.getName() + "/" + bucketName, "-removeAcl",
|
||||
args = new String[] {"bucket", "update",
|
||||
url + "/" + vol.getName() + "/" + bucketName, "--removeAcl",
|
||||
"user:frodo:rw"};
|
||||
execute(shell, args);
|
||||
|
||||
|
@ -602,8 +604,8 @@ public class TestOzoneShell {
|
|||
&& acl.getRights()== OzoneACLRights.READ);
|
||||
|
||||
// test update bucket for a non-exist bucket
|
||||
args = new String[] {"-updateBucket",
|
||||
url + "/" + vol.getName() + "/invalid-bucket", "-addAcl",
|
||||
args = new String[] {"bucket", "update",
|
||||
url + "/" + vol.getName() + "/invalid-bucket", "--addAcl",
|
||||
"user:frodo:rw"};
|
||||
executeWithError(shell, args,
|
||||
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
||||
|
@ -628,8 +630,8 @@ public class TestOzoneShell {
|
|||
}
|
||||
|
||||
// test -length option
|
||||
String[] args = new String[] {"-listBucket",
|
||||
url + "/" + vol.getName(), "-length", "100"};
|
||||
String[] args = new String[] {"bucket", "list",
|
||||
url + "/" + vol.getName(), "--length", "100"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
||||
|
@ -648,8 +650,8 @@ public class TestOzoneShell {
|
|||
}
|
||||
|
||||
out.reset();
|
||||
args = new String[] {"-listBucket", url + "/" + vol.getName(),
|
||||
"-length", "3"};
|
||||
args = new String[] {"bucket", "list", url + "/" + vol.getName(),
|
||||
"--length", "3"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
||||
|
@ -662,10 +664,10 @@ public class TestOzoneShell {
|
|||
assertEquals(buckets.get(1).getBucketName(), "test-bucket1");
|
||||
assertEquals(buckets.get(2).getBucketName(), "test-bucket10");
|
||||
|
||||
// test -prefix option
|
||||
// test --prefix option
|
||||
out.reset();
|
||||
args = new String[] {"-listBucket", url + "/" + vol.getName(),
|
||||
"-length", "100", "-prefix", "test-bucket1"};
|
||||
args = new String[] {"bucket", "list", url + "/" + vol.getName(),
|
||||
"--length", "100", "--prefix", "test-bucket1"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
||||
|
@ -678,8 +680,8 @@ public class TestOzoneShell {
|
|||
|
||||
// test -start option
|
||||
out.reset();
|
||||
args = new String[] {"-listBucket", url + "/" + vol.getName(),
|
||||
"-length", "100", "-start", "test-bucket7"};
|
||||
args = new String[] {"bucket", "list", url + "/" + vol.getName(),
|
||||
"--length", "100", "--start", "test-bucket7"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
||||
|
@ -691,8 +693,8 @@ public class TestOzoneShell {
|
|||
|
||||
// test error conditions
|
||||
err.reset();
|
||||
args = new String[] {"-listBucket", url + "/" + vol.getName(),
|
||||
"-length", "-1"};
|
||||
args = new String[] {"bucket", "list", url + "/" + vol.getName(),
|
||||
"--length", "-1"};
|
||||
executeWithError(shell, args, "the length should be a positive number");
|
||||
}
|
||||
|
||||
|
@ -704,8 +706,8 @@ public class TestOzoneShell {
|
|||
String bucketName = bucket.getName();
|
||||
String keyName = "key" + RandomStringUtils.randomNumeric(5);
|
||||
|
||||
String[] args = new String[] {"-putKey",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName, "-file",
|
||||
String[] args = new String[] {"key", "put",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName,
|
||||
createTmpFile()};
|
||||
execute(shell, args);
|
||||
|
||||
|
@ -713,8 +715,8 @@ public class TestOzoneShell {
|
|||
assertEquals(keyName, keyInfo.getName());
|
||||
|
||||
// test put key in a non-exist bucket
|
||||
args = new String[] {"-putKey",
|
||||
url + "/" + volumeName + "/invalid-bucket/" + keyName, "-file",
|
||||
args = new String[] {"key", "put",
|
||||
url + "/" + volumeName + "/invalid-bucket/" + keyName,
|
||||
createTmpFile()};
|
||||
executeWithError(shell, args,
|
||||
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
||||
|
@ -736,8 +738,8 @@ public class TestOzoneShell {
|
|||
|
||||
String tmpPath = baseDir.getAbsolutePath() + "/testfile-"
|
||||
+ UUID.randomUUID().toString();
|
||||
String[] args = new String[] {"-getKey",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName, "-file",
|
||||
String[] args = new String[] {"key", "get",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName,
|
||||
tmpPath};
|
||||
execute(shell, args);
|
||||
|
||||
|
@ -748,8 +750,8 @@ public class TestOzoneShell {
|
|||
assertEquals(dataStr, DFSUtil.bytes2String(dataBytes));
|
||||
|
||||
tmpPath = baseDir.getAbsolutePath() + File.separatorChar + keyName;
|
||||
args = new String[] {"-getKey",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName, "-file",
|
||||
args = new String[] {"key", "get",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName,
|
||||
baseDir.getAbsolutePath()};
|
||||
execute(shell, args);
|
||||
|
||||
|
@ -776,7 +778,7 @@ public class TestOzoneShell {
|
|||
OzoneKey keyInfo = bucket.getKey(keyName);
|
||||
assertEquals(keyName, keyInfo.getName());
|
||||
|
||||
String[] args = new String[] {"-deleteKey",
|
||||
String[] args = new String[] {"key", "delete",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName};
|
||||
execute(shell, args);
|
||||
|
||||
|
@ -790,14 +792,14 @@ public class TestOzoneShell {
|
|||
}
|
||||
|
||||
// test delete key in a non-exist bucket
|
||||
args = new String[] {"-deleteKey",
|
||||
args = new String[] {"key", "delete",
|
||||
url + "/" + volumeName + "/invalid-bucket/" + keyName};
|
||||
executeWithError(shell, args,
|
||||
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
||||
|
||||
err.reset();
|
||||
// test delete a non-exist key in bucket
|
||||
args = new String[] {"-deleteKey",
|
||||
args = new String[] {"key", "delete",
|
||||
url + "/" + volumeName + "/" + bucketName + "/invalid-key"};
|
||||
executeWithError(shell, args, "Delete key failed, error:KEY_NOT_FOUND");
|
||||
}
|
||||
|
@ -815,7 +817,7 @@ public class TestOzoneShell {
|
|||
keyOutputStream.write(dataStr.getBytes());
|
||||
keyOutputStream.close();
|
||||
|
||||
String[] args = new String[] {"-infoKey",
|
||||
String[] args = new String[] {"key", "info",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName};
|
||||
|
||||
// verify the response output
|
||||
|
@ -834,7 +836,7 @@ public class TestOzoneShell {
|
|||
err.reset();
|
||||
|
||||
// get the info of a non-exist key
|
||||
args = new String[] {"-infoKey",
|
||||
args = new String[] {"key", "info",
|
||||
url + "/" + volumeName + "/" + bucketName + "/invalid-key"};
|
||||
|
||||
// verify the response output
|
||||
|
@ -855,7 +857,7 @@ public class TestOzoneShell {
|
|||
bucket.createKey(dirKeyName, dataStr.length());
|
||||
keyOutputStream.write(dataStr.getBytes());
|
||||
keyOutputStream.close();
|
||||
String[] args = new String[] {"-infoKey",
|
||||
String[] args = new String[] {"key", "info",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + dirKeyName};
|
||||
// verify the response output
|
||||
execute(shell, args);
|
||||
|
@ -864,7 +866,7 @@ public class TestOzoneShell {
|
|||
assertTrue(output.contains("createdOn") &&
|
||||
output.contains("modifiedOn") &&
|
||||
output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||
args = new String[] {"-infoKey",
|
||||
args = new String[] {"key", "info",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyNameOnly};
|
||||
executeWithError(shell, args, "Lookup key failed, error:KEY_NOT_FOUND");
|
||||
out.reset();
|
||||
|
@ -894,8 +896,8 @@ public class TestOzoneShell {
|
|||
}
|
||||
|
||||
// test -length option
|
||||
String[] args = new String[] {"-listKey",
|
||||
url + "/" + volumeName + "/" + bucketName, "-length", "100"};
|
||||
String[] args = new String[] {"key", "list",
|
||||
url + "/" + volumeName + "/" + bucketName, "--length", "100"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||
|
@ -916,8 +918,9 @@ public class TestOzoneShell {
|
|||
}
|
||||
|
||||
out.reset();
|
||||
args = new String[] {"-listKey", url + "/" + volumeName + "/" + bucketName,
|
||||
"-length", "3"};
|
||||
args =
|
||||
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||
"--length", "3"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||
|
@ -929,10 +932,11 @@ public class TestOzoneShell {
|
|||
assertEquals(keys.get(1).getKeyName(), "test-key1");
|
||||
assertEquals(keys.get(2).getKeyName(), "test-key10");
|
||||
|
||||
// test -prefix option
|
||||
// test --prefix option
|
||||
out.reset();
|
||||
args = new String[] {"-listKey", url + "/" + volumeName + "/" + bucketName,
|
||||
"-length", "100", "-prefix", "test-key1"};
|
||||
args =
|
||||
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||
"--length", "100", "--prefix", "test-key1"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||
|
@ -945,8 +949,9 @@ public class TestOzoneShell {
|
|||
|
||||
// test -start option
|
||||
out.reset();
|
||||
args = new String[] {"-listKey", url + "/" + volumeName + "/" + bucketName,
|
||||
"-length", "100", "-start", "test-key7"};
|
||||
args =
|
||||
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||
"--length", "100", "--start", "test-key7"};
|
||||
execute(shell, args);
|
||||
commandOutput = out.toString();
|
||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||
|
@ -957,8 +962,9 @@ public class TestOzoneShell {
|
|||
|
||||
// test error conditions
|
||||
err.reset();
|
||||
args = new String[] {"-listKey", url + "/" + volumeName + "/" + bucketName,
|
||||
"-length", "-1"};
|
||||
args =
|
||||
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||
"--length", "-1"};
|
||||
executeWithError(shell, args, "the length should be a positive number");
|
||||
}
|
||||
|
||||
|
|
|
@ -18,25 +18,25 @@
|
|||
|
||||
package org.apache.hadoop.ozone.web.ozShell;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
|
||||
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
||||
import org.apache.hadoop.ozone.client.OzoneClient;
|
||||
import org.apache.hadoop.ozone.client.OzoneClientFactory;
|
||||
import org.apache.hadoop.ozone.client.OzoneClientException;
|
||||
import org.apache.hadoop.ozone.client.rest.OzoneException;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdds.cli.GenericParentCommand;
|
||||
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
|
||||
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
||||
import org.apache.hadoop.ozone.client.OzoneClient;
|
||||
import org.apache.hadoop.ozone.client.OzoneClientException;
|
||||
import org.apache.hadoop.ozone.client.OzoneClientFactory;
|
||||
import org.apache.hadoop.ozone.client.rest.OzoneException;
|
||||
|
||||
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_HTTP_SCHEME;
|
||||
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_SCHEME;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.ParentCommand;
|
||||
|
||||
|
@ -52,20 +52,7 @@ public abstract class Handler implements Callable<Void> {
|
|||
protected OzoneClient client;
|
||||
|
||||
@ParentCommand
|
||||
private Shell parent;
|
||||
|
||||
/**
|
||||
* Executes the Client command.
|
||||
*
|
||||
* @param cmd - CommandLine
|
||||
* @throws IOException
|
||||
* @throws OzoneException
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
protected void execute(CommandLine cmd)
|
||||
throws IOException, OzoneException, URISyntaxException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
private GenericParentCommand parent;
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
|
@ -169,4 +156,5 @@ public abstract class Handler implements Callable<Void> {
|
|||
public boolean isVerbose() {
|
||||
return parent.isVerbose();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,21 +20,9 @@ package org.apache.hadoop.ozone.web.ozShell;
|
|||
|
||||
import org.apache.hadoop.hdds.cli.GenericCli;
|
||||
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
|
||||
import org.apache.hadoop.ozone.web.ozShell.bucket.CreateBucketHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.bucket.DeleteBucketHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.bucket.InfoBucketHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.bucket.ListBucketHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.bucket.UpdateBucketHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.keys.DeleteKeyHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.keys.GetKeyHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.keys.InfoKeyHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.keys.ListKeyHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.keys.PutKeyHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.volume.CreateVolumeHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.volume.DeleteVolumeHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.volume.InfoVolumeHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.volume.ListVolumeHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.volume.UpdateVolumeHandler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.bucket.BucketCommands;
|
||||
import org.apache.hadoop.ozone.web.ozShell.keys.KeyCommands;
|
||||
import org.apache.hadoop.ozone.web.ozShell.volume.VolumeCommands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -49,21 +37,9 @@ import picocli.CommandLine.Command;
|
|||
@Command(name = "ozone oz",
|
||||
description = "Client for the Ozone object store",
|
||||
subcommands = {
|
||||
InfoVolumeHandler.class,
|
||||
ListVolumeHandler.class,
|
||||
CreateVolumeHandler.class,
|
||||
UpdateVolumeHandler.class,
|
||||
DeleteVolumeHandler.class,
|
||||
InfoBucketHandler.class,
|
||||
ListBucketHandler.class,
|
||||
CreateBucketHandler.class,
|
||||
UpdateBucketHandler.class,
|
||||
DeleteBucketHandler.class,
|
||||
InfoKeyHandler.class,
|
||||
ListKeyHandler.class,
|
||||
PutKeyHandler.class,
|
||||
GetKeyHandler.class,
|
||||
DeleteKeyHandler.class
|
||||
VolumeCommands.class,
|
||||
BucketCommands.class,
|
||||
KeyCommands.class
|
||||
},
|
||||
versionProvider = HddsVersionProvider.class,
|
||||
mixinStandardHelpOptions = true)
|
||||
|
@ -100,8 +76,5 @@ public class Shell extends GenericCli {
|
|||
public static void main(String[] argv) throws Exception {
|
||||
new Shell().run(argv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.ozone.web.ozShell.bucket;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.hadoop.hdds.cli.GenericParentCommand;
|
||||
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
|
||||
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
|
||||
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.ParentCommand;
|
||||
|
||||
/**
|
||||
* Subcommands for the bucket related operations.
|
||||
*/
|
||||
@Command(name = "bucket",
|
||||
description = "Bucket specific operations",
|
||||
subcommands = {
|
||||
InfoBucketHandler.class,
|
||||
ListBucketHandler.class,
|
||||
CreateBucketHandler.class,
|
||||
UpdateBucketHandler.class,
|
||||
DeleteBucketHandler.class
|
||||
},
|
||||
mixinStandardHelpOptions = true,
|
||||
versionProvider = HddsVersionProvider.class)
|
||||
public class BucketCommands implements GenericParentCommand, Callable<Void> {
|
||||
|
||||
@ParentCommand
|
||||
private Shell shell;
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
throw new MissingSubcommandException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerbose() {
|
||||
return shell.isVerbose();
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* create bucket handler.
|
||||
*/
|
||||
@Command(name = "-createBucket",
|
||||
@Command(name = "create",
|
||||
description = "creates a bucket in a given volume")
|
||||
public class CreateBucketHandler extends Handler {
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Delete bucket Handler.
|
||||
*/
|
||||
@Command(name = "-deleteBucket",
|
||||
@Command(name = "delete",
|
||||
description = "deletes an empty bucket")
|
||||
public class DeleteBucketHandler extends Handler {
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Executes Info bucket.
|
||||
*/
|
||||
@Command(name = "-infoBucket",
|
||||
@Command(name = "info",
|
||||
description = "returns information about a bucket")
|
||||
public class InfoBucketHandler extends Handler {
|
||||
|
||||
|
|
|
@ -42,24 +42,25 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Executes List Bucket.
|
||||
*/
|
||||
@Command(name = "-listBucket",
|
||||
@Command(name = "list",
|
||||
aliases = "ls",
|
||||
description = "lists the buckets in a volume.")
|
||||
public class ListBucketHandler extends Handler {
|
||||
|
||||
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
||||
private String uri;
|
||||
|
||||
@Option(names = {"--length", "-length", "-l"},
|
||||
@Option(names = {"--length", "-l"},
|
||||
description = "Limit of the max results",
|
||||
defaultValue = "100",
|
||||
showDefaultValue = Visibility.ALWAYS)
|
||||
private int maxBuckets;
|
||||
|
||||
@Option(names = {"--start", "-start", "-s"},
|
||||
@Option(names = {"--start", "-s"},
|
||||
description = "The first bucket to start the listing")
|
||||
private String startBucket;
|
||||
|
||||
@Option(names = {"--prefix", "-prefix", "-p"},
|
||||
@Option(names = {"--prefix", "-p"},
|
||||
description = "Prefix to filter the buckets")
|
||||
private String prefix;
|
||||
/**
|
||||
|
|
|
@ -40,19 +40,19 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Allows users to add and remove acls and from a bucket.
|
||||
*/
|
||||
@Command(name = "-updateBucket",
|
||||
@Command(name = "update",
|
||||
description = "allows changing bucket attributes")
|
||||
public class UpdateBucketHandler extends Handler {
|
||||
|
||||
@Parameters(arity = "1..1", description = Shell.OZONE_BUCKET_URI_DESCRIPTION)
|
||||
private String uri;
|
||||
|
||||
@Option(names = {"--addAcl", "-addAcl"},
|
||||
@Option(names = {"--addAcl"},
|
||||
description = "Comma separated list of acl rules to add (eg. " +
|
||||
"user:bilbo:rw)")
|
||||
private String addAcl;
|
||||
|
||||
@Option(names = {"--removeAcl", "-removeAcl"},
|
||||
@Option(names = {"--removeAcl"},
|
||||
description = "Comma separated list of acl rules to remove (eg. "
|
||||
+ "user:bilbo:rw)")
|
||||
private String removeAcl;
|
||||
|
|
|
@ -34,7 +34,7 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Executes Delete Key.
|
||||
*/
|
||||
@Command(name = "-deleteKey",
|
||||
@Command(name = "delete",
|
||||
description = "deletes an existing key")
|
||||
public class DeleteKeyHandler extends Handler {
|
||||
|
||||
|
|
|
@ -38,22 +38,21 @@ import org.apache.commons.codec.digest.DigestUtils;
|
|||
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CHUNK_SIZE_DEFAULT;
|
||||
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CHUNK_SIZE_KEY;
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
import picocli.CommandLine.Parameters;
|
||||
|
||||
/**
|
||||
* Gets an existing key.
|
||||
*/
|
||||
@Command(name = "-getKey",
|
||||
@Command(name = "get",
|
||||
description = "Gets a specific key from ozone server")
|
||||
public class GetKeyHandler extends Handler {
|
||||
|
||||
@Parameters(arity = "1..1", description = Shell.OZONE_KEY_URI_DESCRIPTION)
|
||||
@Parameters(index = "0", arity = "1..1", description =
|
||||
Shell.OZONE_KEY_URI_DESCRIPTION)
|
||||
private String uri;
|
||||
|
||||
@Option(names = {"-f", "--file", "-file"},
|
||||
description = "File path to download the key to",
|
||||
required = true)
|
||||
@Parameters(index = "1", arity = "1..1",
|
||||
description = "File path to download the key to")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Executes Info Object.
|
||||
*/
|
||||
@Command(name = "-infoKey",
|
||||
@Command(name = "info",
|
||||
description = "returns information about an existing key")
|
||||
public class InfoKeyHandler extends Handler {
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.ozone.web.ozShell.keys;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.hadoop.hdds.cli.GenericParentCommand;
|
||||
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
|
||||
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
|
||||
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.ParentCommand;
|
||||
|
||||
/**
|
||||
* Subcommand to group key related operations.
|
||||
*/
|
||||
@Command(name = "key",
|
||||
description = "Key specific operations",
|
||||
subcommands = {
|
||||
InfoKeyHandler.class,
|
||||
ListKeyHandler.class,
|
||||
GetKeyHandler.class,
|
||||
PutKeyHandler.class,
|
||||
DeleteKeyHandler.class
|
||||
},
|
||||
mixinStandardHelpOptions = true,
|
||||
versionProvider = HddsVersionProvider.class)
|
||||
public class KeyCommands implements GenericParentCommand, Callable<Void> {
|
||||
|
||||
@ParentCommand
|
||||
private Shell shell;
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
throw new MissingSubcommandException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerbose() {
|
||||
return shell.isVerbose();
|
||||
}
|
||||
}
|
|
@ -42,23 +42,24 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Executes List Keys.
|
||||
*/
|
||||
@Command(name = "-listKey",
|
||||
@Command(name = "list",
|
||||
aliases = "ls",
|
||||
description = "list all keys in a given bucket")
|
||||
public class ListKeyHandler extends Handler {
|
||||
|
||||
@Parameters(arity = "1..1", description = Shell.OZONE_BUCKET_URI_DESCRIPTION)
|
||||
private String uri;
|
||||
|
||||
@Option(names = {"--length", "-length", "-l"},
|
||||
@Option(names = {"--length", "-l"},
|
||||
description = "Limit of the max results",
|
||||
defaultValue = "100")
|
||||
private int maxKeys;
|
||||
|
||||
@Option(names = {"--start", "-start", "-s"},
|
||||
@Option(names = {"--start", "-s"},
|
||||
description = "The first key to start the listing")
|
||||
private String startKey;
|
||||
|
||||
@Option(names = {"--prefix", "-prefix", "-p"},
|
||||
@Option(names = {"--prefix", "-p"},
|
||||
description = "Prefix to filter the key")
|
||||
private String prefix;
|
||||
|
||||
|
|
|
@ -50,19 +50,18 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Puts a file into an ozone bucket.
|
||||
*/
|
||||
@Command(name = "-putKey",
|
||||
@Command(name = "put",
|
||||
description = "creates or overwrites an existing key")
|
||||
public class PutKeyHandler extends Handler {
|
||||
|
||||
@Parameters(arity = "1..1", description = Shell.OZONE_KEY_URI_DESCRIPTION)
|
||||
@Parameters(index = "0", arity = "1..1", description =
|
||||
Shell.OZONE_KEY_URI_DESCRIPTION)
|
||||
private String uri;
|
||||
|
||||
@Option(names = {"-f", "--file", "-file"},
|
||||
description = "File to upload",
|
||||
required = true)
|
||||
@Parameters(index = "1", arity = "1..1", description = "File to upload")
|
||||
private String fileName;
|
||||
|
||||
@Option(names = {"-r", "--replication", "-replicationFactor"},
|
||||
@Option(names = {"-r", "--replication"},
|
||||
description = "Replication factor of the new key. (use ONE or THREE) "
|
||||
+ "Default is specified in the cluster-wide config.")
|
||||
private ReplicationFactor replicationFactor;
|
||||
|
|
|
@ -18,41 +18,41 @@
|
|||
|
||||
package org.apache.hadoop.ozone.web.ozShell.volume;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
import picocli.CommandLine.Parameters;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.hadoop.ozone.client.OzoneClientException;
|
||||
import org.apache.hadoop.ozone.client.OzoneClientUtils;
|
||||
import org.apache.hadoop.ozone.client.OzoneVolume;
|
||||
import org.apache.hadoop.ozone.client.VolumeArgs;
|
||||
import org.apache.hadoop.ozone.client.OzoneClientException;
|
||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
||||
import org.apache.hadoop.ozone.web.utils.JsonUtils;
|
||||
|
||||
import java.net.URI;
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
import picocli.CommandLine.Parameters;
|
||||
|
||||
/**
|
||||
* Executes the create volume call for the shell.
|
||||
*/
|
||||
@Command(name = "-createVolume",
|
||||
@Command(name = "create",
|
||||
description = "Creates a volume for the specified user")
|
||||
public class CreateVolumeHandler extends Handler {
|
||||
|
||||
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
||||
private String uri;
|
||||
|
||||
@Option(names = {"--user", "-user"},
|
||||
@Option(names = {"--user", "-u"},
|
||||
description = "Owner of of the volume", required =
|
||||
true)
|
||||
private String userName;
|
||||
|
||||
@Option(names = {"--quota", "-quota"},
|
||||
@Option(names = {"--quota", "-q"},
|
||||
description =
|
||||
"Quota of the newly created volume (eg. 1G)")
|
||||
private String quota;
|
||||
|
||||
@Option(names = {"--root", "-root"},
|
||||
@Option(names = {"--root"},
|
||||
description = "Development flag to execute the "
|
||||
+ "command as the admin (hdfs) user.")
|
||||
private boolean root;
|
||||
|
|
|
@ -30,7 +30,7 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Executes deleteVolume call for the shell.
|
||||
*/
|
||||
@Command(name = "-deleteVolume",
|
||||
@Command(name = "delete",
|
||||
description = "deletes a volume if it is empty")
|
||||
public class DeleteVolumeHandler extends Handler {
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import picocli.CommandLine.Parameters;
|
|||
/**
|
||||
* Executes volume Info calls.
|
||||
*/
|
||||
@Command(name = "-infoVolume",
|
||||
@Command(name = "info",
|
||||
description = "returns information about a specific volume")
|
||||
public class InfoVolumeHandler extends Handler{
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ import java.util.List;
|
|||
/**
|
||||
* Executes List Volume call.
|
||||
*/
|
||||
@Command(name = "-listVolume",
|
||||
@Command(name = "list",
|
||||
aliases = "ls",
|
||||
description = "List the volumes of a given user")
|
||||
public class ListVolumeHandler extends Handler {
|
||||
|
||||
|
@ -48,20 +49,20 @@ public class ListVolumeHandler extends Handler {
|
|||
defaultValue = "/")
|
||||
private String uri;
|
||||
|
||||
@Option(names = {"--length", "-length", "-l"},
|
||||
@Option(names = {"--length", "-l"},
|
||||
description = "Limit of the max results",
|
||||
defaultValue = "100")
|
||||
private int maxVolumes;
|
||||
|
||||
@Option(names = {"--start", "-start", "-s"},
|
||||
@Option(names = {"--start", "-s"},
|
||||
description = "The first volume to start the listing")
|
||||
private String startVolume;
|
||||
|
||||
@Option(names = {"--prefix", "-prefix", "-p"},
|
||||
@Option(names = {"--prefix", "-p"},
|
||||
description = "Prefix to filter the volumes")
|
||||
private String prefix;
|
||||
|
||||
@Option(names = {"--user", "-user", "-u"},
|
||||
@Option(names = {"--user", "-u"},
|
||||
description = "Owner of the volumes to list.")
|
||||
private String userName;
|
||||
|
||||
|
|
|
@ -35,18 +35,18 @@ import java.net.URI;
|
|||
/**
|
||||
* Executes update volume calls.
|
||||
*/
|
||||
@Command(name = "-updateVolume",
|
||||
@Command(name = "update",
|
||||
description = "Updates parameter of the volumes")
|
||||
public class UpdateVolumeHandler extends Handler {
|
||||
|
||||
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
||||
private String uri;
|
||||
|
||||
@Option(names = {"--user", "-user"},
|
||||
@Option(names = {"--user"},
|
||||
description = "Owner of the volume to set")
|
||||
private String ownerName;
|
||||
|
||||
@Option(names = {"--quota", "-quota"},
|
||||
@Option(names = {"--quota"},
|
||||
description = "Quota of the volume to set"
|
||||
+ "(eg. 1G)")
|
||||
private String quota;
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.ozone.web.ozShell.volume;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.hadoop.hdds.cli.GenericParentCommand;
|
||||
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
|
||||
import org.apache.hadoop.hdds.cli.MissingSubcommandException;
|
||||
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.ParentCommand;
|
||||
|
||||
/**
|
||||
* Subcommand to group volume related operations.
|
||||
*/
|
||||
@Command(name = "volume",
|
||||
aliases = "vol",
|
||||
description = "Volume specific operations",
|
||||
subcommands = {
|
||||
InfoVolumeHandler.class,
|
||||
ListVolumeHandler.class,
|
||||
CreateVolumeHandler.class,
|
||||
UpdateVolumeHandler.class,
|
||||
DeleteVolumeHandler.class
|
||||
},
|
||||
mixinStandardHelpOptions = true,
|
||||
versionProvider = HddsVersionProvider.class)
|
||||
public class VolumeCommands implements GenericParentCommand, Callable<Void> {
|
||||
|
||||
@ParentCommand
|
||||
private Shell shell;
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
throw new MissingSubcommandException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerbose() {
|
||||
return shell.isVerbose();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue