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 picocli.CommandLine;
|
import picocli.CommandLine;
|
||||||
import picocli.CommandLine.ExecutionException;
|
import picocli.CommandLine.ExecutionException;
|
||||||
import picocli.CommandLine.Option;
|
import picocli.CommandLine.Option;
|
||||||
import picocli.CommandLine.ParameterException;
|
|
||||||
import picocli.CommandLine.RunLast;
|
import picocli.CommandLine.RunLast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a generic parent class for all the ozone related cli tools.
|
* 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"},
|
@Option(names = {"--verbose"},
|
||||||
description = "More verbose output. Show the stack trace of the errors.")
|
description = "More verbose output. Show the stack trace of the errors.")
|
||||||
@ -72,7 +71,7 @@ private void printError(Throwable error) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
throw new ParameterException(cmd, "Please choose a subcommand");
|
throw new MissingSubcommandException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OzoneConfiguration createOzoneConfiguration() {
|
public OzoneConfiguration createOzoneConfiguration() {
|
||||||
@ -86,12 +85,13 @@ public OzoneConfiguration createOzoneConfiguration() {
|
|||||||
return ozoneConf;
|
return ozoneConf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVerbose() {
|
|
||||||
return verbose;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public picocli.CommandLine getCmd() {
|
public picocli.CommandLine getCmd() {
|
||||||
return cmd;
|
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 ***
|
*** Keywords ***
|
||||||
Test ozone shell
|
Test ozone shell
|
||||||
[arguments] ${protocol} ${server} ${volume}
|
[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 not contain ${result} Failed
|
||||||
Should contain ${result} Creating Volume: ${volume}
|
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
|
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
|
Should contain ${result} createdOn
|
||||||
Execute on datanode ozone oz -updateVolume ${protocol}${server}/${volume} -user bill -quota 10TB
|
Execute on datanode ozone oz volume update ${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'
|
${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
|
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
|
Should Be Equal ${result} 10
|
||||||
Execute on datanode ozone oz -createBucket ${protocol}${server}/${volume}/bb1
|
Execute on datanode ozone oz bucket create ${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'
|
${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
|
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
|
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
|
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}
|
Should Be Equal ${result} ${volume}
|
||||||
Run Keyword Test key handling ${protocol} ${server} ${volume}
|
Run Keyword Test key handling ${protocol} ${server} ${volume}
|
||||||
Execute on datanode ozone oz -deleteBucket ${protocol}${server}/${volume}/bb1
|
Execute on datanode ozone oz bucket delete ${protocol}${server}/${volume}/bb1
|
||||||
Execute on datanode ozone oz -deleteVolume ${protocol}${server}/${volume} -user bilbo
|
Execute on datanode ozone oz volume delete ${protocol}${server}/${volume} --user bilbo
|
||||||
|
|
||||||
Test key handling
|
Test key handling
|
||||||
[arguments] ${protocol} ${server} ${volume}
|
[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 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
|
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
|
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
|
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 ***
|
*** Test Cases ***
|
||||||
Create volume and bucket
|
Create volume and bucket
|
||||||
Execute on datanode ozone oz -createVolume http://ozoneManager/fstest -user bilbo -quota 100TB -root
|
Execute on datanode ozone oz volume create http://ozoneManager/fstest --user bilbo --quota 100TB --root
|
||||||
Execute on datanode ozone oz -createBucket http://ozoneManager/fstest/bucket1
|
Execute on datanode ozone oz bucket create http://ozoneManager/fstest/bucket1
|
||||||
|
|
||||||
Check volume from ozonefs
|
Check volume from ozonefs
|
||||||
${result} = Execute on datanode ozone fs -ls o3://bucket1.fstest/
|
${result} = Execute on datanode ozone fs -ls o3://bucket1.fstest/
|
||||||
|
|
||||||
Create directory from ozonefs
|
Create directory from ozonefs
|
||||||
Execute on datanode ozone fs -mkdir -p o3://bucket1.fstest/testdir/deep
|
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
|
Should contain ${result} testdir/deep
|
||||||
|
@ -218,8 +218,8 @@ private void testCreateVolume(String volumeName, String errorMsg)
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
err.reset();
|
err.reset();
|
||||||
String userName = "bilbo";
|
String userName = "bilbo";
|
||||||
String[] args = new String[] {"-createVolume", url + "/" + volumeName,
|
String[] args = new String[] {"volume", "create", url + "/" + volumeName,
|
||||||
"-user", userName, "-root"};
|
"--user", userName, "--root"};
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(errorMsg)) {
|
if (Strings.isNullOrEmpty(errorMsg)) {
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
@ -271,7 +271,7 @@ public void testDeleteVolume() throws Exception {
|
|||||||
OzoneVolume volume = client.getVolumeDetails(volumeName);
|
OzoneVolume volume = client.getVolumeDetails(volumeName);
|
||||||
assertNotNull(volume);
|
assertNotNull(volume);
|
||||||
|
|
||||||
String[] args = new String[] {"-deleteVolume", url + "/" + volumeName};
|
String[] args = new String[] {"volume", "delete", url + "/" + volumeName};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
String output = out.toString();
|
String output = out.toString();
|
||||||
assertTrue(output.contains("Volume " + volumeName + " is deleted"));
|
assertTrue(output.contains("Volume " + volumeName + " is deleted"));
|
||||||
@ -296,7 +296,7 @@ public void testInfoVolume() throws Exception {
|
|||||||
.build();
|
.build();
|
||||||
client.createVolume(volumeName, volumeArgs);
|
client.createVolume(volumeName, volumeArgs);
|
||||||
|
|
||||||
String[] args = new String[] {"-infoVolume", url + "/" + volumeName};
|
String[] args = new String[] {"volume", "info", url + "/" + volumeName};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
|
|
||||||
String output = out.toString();
|
String output = out.toString();
|
||||||
@ -305,7 +305,7 @@ public void testInfoVolume() throws Exception {
|
|||||||
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||||
|
|
||||||
// get info for non-exist volume
|
// 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");
|
executeWithError(shell, args, "VOLUME_NOT_FOUND");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,28 +323,28 @@ public void testUpdateVolume() throws Exception {
|
|||||||
assertEquals(userName, vol.getOwner());
|
assertEquals(userName, vol.getOwner());
|
||||||
assertEquals(OzoneQuota.parseQuota("100TB").sizeInBytes(), vol.getQuota());
|
assertEquals(OzoneQuota.parseQuota("100TB").sizeInBytes(), vol.getQuota());
|
||||||
|
|
||||||
String[] args = new String[] {"-updateVolume", url + "/" + volumeName,
|
String[] args = new String[] {"volume", "update", url + "/" + volumeName,
|
||||||
"-quota", "500MB"};
|
"--quota", "500MB"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
vol = client.getVolumeDetails(volumeName);
|
vol = client.getVolumeDetails(volumeName);
|
||||||
assertEquals(userName, vol.getOwner());
|
assertEquals(userName, vol.getOwner());
|
||||||
assertEquals(OzoneQuota.parseQuota("500MB").sizeInBytes(), vol.getQuota());
|
assertEquals(OzoneQuota.parseQuota("500MB").sizeInBytes(), vol.getQuota());
|
||||||
|
|
||||||
String newUser = "new-user";
|
String newUser = "new-user";
|
||||||
args = new String[] {"-updateVolume", url + "/" + volumeName,
|
args = new String[] {"volume", "update", url + "/" + volumeName,
|
||||||
"-user", newUser};
|
"--user", newUser};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
vol = client.getVolumeDetails(volumeName);
|
vol = client.getVolumeDetails(volumeName);
|
||||||
assertEquals(newUser, vol.getOwner());
|
assertEquals(newUser, vol.getOwner());
|
||||||
|
|
||||||
// test error conditions
|
// test error conditions
|
||||||
args = new String[] {"-updateVolume", url + "/invalid-volume",
|
args = new String[] {"volume", "update", url + "/invalid-volume",
|
||||||
"-user", newUser};
|
"--user", newUser};
|
||||||
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
||||||
|
|
||||||
err.reset();
|
err.reset();
|
||||||
args = new String[] {"-updateVolume", url + "/invalid-volume",
|
args = new String[] {"volume", "update", url + "/invalid-volume",
|
||||||
"-quota", "500MB"};
|
"--quota", "500MB"};
|
||||||
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,14 +411,14 @@ public void testListVolume() throws Exception {
|
|||||||
assertNotNull(vol);
|
assertNotNull(vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] args = new String[] {"-listVolume", url + "/abcde", "-user",
|
String[] args = new String[] {"volume", "list", url + "/abcde", "--user",
|
||||||
user1, "-length", "100"};
|
user1, "--length", "100"};
|
||||||
executeWithError(shell, args, "Invalid URI");
|
executeWithError(shell, args, "Invalid URI");
|
||||||
|
|
||||||
err.reset();
|
err.reset();
|
||||||
// test -length option
|
// test -length option
|
||||||
args = new String[] {"-listVolume", url + "/", "-user",
|
args = new String[] {"volume", "list", url + "/", "--user",
|
||||||
user1, "-length", "100"};
|
user1, "--length", "100"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
volumes = (List<VolumeInfo>) JsonUtils
|
volumes = (List<VolumeInfo>) JsonUtils
|
||||||
@ -431,8 +431,8 @@ public void testListVolume() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listVolume", url + "/", "-user",
|
args = new String[] {"volume", "list", url + "/", "--user",
|
||||||
user1, "-length", "2"};
|
user1, "--length", "2"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
volumes = (List<VolumeInfo>) JsonUtils
|
volumes = (List<VolumeInfo>) JsonUtils
|
||||||
@ -440,10 +440,11 @@ public void testListVolume() throws Exception {
|
|||||||
|
|
||||||
assertEquals(2, volumes.size());
|
assertEquals(2, volumes.size());
|
||||||
|
|
||||||
// test -prefix option
|
// test --prefix option
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listVolume", url + "/", "-user", user1, "-length",
|
args =
|
||||||
"100", "-prefix", "test-vol-" + protocol + "1" };
|
new String[] {"volume", "list", url + "/", "--user", user1, "--length",
|
||||||
|
"100", "--prefix", "test-vol-" + protocol + "1"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
volumes = (List<VolumeInfo>) JsonUtils
|
volumes = (List<VolumeInfo>) JsonUtils
|
||||||
@ -459,8 +460,9 @@ public void testListVolume() throws Exception {
|
|||||||
|
|
||||||
// test -start option
|
// test -start option
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listVolume", url + "/", "-user", user2, "-length",
|
args =
|
||||||
"100", "-start", "test-vol-" + protocol + "15" };
|
new String[] {"volume", "list", url + "/", "--user", user2, "--length",
|
||||||
|
"100", "--start", "test-vol-" + protocol + "15"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
volumes = (List<VolumeInfo>) JsonUtils
|
volumes = (List<VolumeInfo>) JsonUtils
|
||||||
@ -475,13 +477,13 @@ public void testListVolume() throws Exception {
|
|||||||
|
|
||||||
// test error conditions
|
// test error conditions
|
||||||
err.reset();
|
err.reset();
|
||||||
args = new String[] {"-listVolume", url + "/", "-user",
|
args = new String[] {"volume", "list", url + "/", "--user",
|
||||||
user2, "-length", "-1"};
|
user2, "--length", "-1"};
|
||||||
executeWithError(shell, args, "the length should be a positive number");
|
executeWithError(shell, args, "the length should be a positive number");
|
||||||
|
|
||||||
err.reset();
|
err.reset();
|
||||||
args = new String[] {"-listVolume", url + "/", "-user",
|
args = new String[] {"volume", "list", url + "/", "--user",
|
||||||
user2, "-length", "invalid-length"};
|
user2, "--length", "invalid-length"};
|
||||||
executeWithError(shell, args, "For input string: \"invalid-length\"");
|
executeWithError(shell, args, "For input string: \"invalid-length\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +492,7 @@ public void testCreateBucket() throws Exception {
|
|||||||
LOG.info("Running testCreateBucket");
|
LOG.info("Running testCreateBucket");
|
||||||
OzoneVolume vol = creatVolume();
|
OzoneVolume vol = creatVolume();
|
||||||
String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
|
String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
|
||||||
String[] args = new String[] {"-createBucket",
|
String[] args = new String[] {"bucket", "create",
|
||||||
url + "/" + vol.getName() + "/" + bucketName};
|
url + "/" + vol.getName() + "/" + bucketName};
|
||||||
|
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
@ -500,7 +502,7 @@ public void testCreateBucket() throws Exception {
|
|||||||
assertEquals(bucketName, bucketInfo.getName());
|
assertEquals(bucketName, bucketInfo.getName());
|
||||||
|
|
||||||
// test create a bucket in a non-exist volume
|
// test create a bucket in a non-exist volume
|
||||||
args = new String[] {"-createBucket",
|
args = new String[] {"bucket", "create",
|
||||||
url + "/invalid-volume/" + bucketName};
|
url + "/invalid-volume/" + bucketName};
|
||||||
|
|
||||||
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
||||||
@ -515,7 +517,7 @@ public void testDeleteBucket() throws Exception {
|
|||||||
OzoneBucket bucketInfo = vol.getBucket(bucketName);
|
OzoneBucket bucketInfo = vol.getBucket(bucketName);
|
||||||
assertNotNull(bucketInfo);
|
assertNotNull(bucketInfo);
|
||||||
|
|
||||||
String[] args = new String[] {"-deleteBucket",
|
String[] args = new String[] {"bucket", "delete",
|
||||||
url + "/" + vol.getName() + "/" + bucketName};
|
url + "/" + vol.getName() + "/" + bucketName};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
|
|
||||||
@ -529,13 +531,13 @@ public void testDeleteBucket() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// test delete bucket in a non-exist volume
|
// test delete bucket in a non-exist volume
|
||||||
args = new String[] {"-deleteBucket",
|
args = new String[] {"bucket", "delete",
|
||||||
url + "/invalid-volume" + "/" + bucketName};
|
url + "/invalid-volume" + "/" + bucketName};
|
||||||
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
executeWithError(shell, args, "Info Volume failed, error:VOLUME_NOT_FOUND");
|
||||||
|
|
||||||
err.reset();
|
err.reset();
|
||||||
// test delete non-exist bucket
|
// test delete non-exist bucket
|
||||||
args = new String[] {"-deleteBucket",
|
args = new String[] {"bucket", "delete",
|
||||||
url + "/" + vol.getName() + "/invalid-bucket"};
|
url + "/" + vol.getName() + "/invalid-bucket"};
|
||||||
executeWithError(shell, args,
|
executeWithError(shell, args,
|
||||||
"Delete Bucket failed, error:BUCKET_NOT_FOUND");
|
"Delete Bucket failed, error:BUCKET_NOT_FOUND");
|
||||||
@ -548,7 +550,7 @@ public void testInfoBucket() throws Exception {
|
|||||||
String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
|
String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
|
||||||
vol.createBucket(bucketName);
|
vol.createBucket(bucketName);
|
||||||
|
|
||||||
String[] args = new String[] {"-infoBucket",
|
String[] args = new String[] {"bucket", "info",
|
||||||
url + "/" + vol.getName() + "/" + bucketName};
|
url + "/" + vol.getName() + "/" + bucketName};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
|
|
||||||
@ -558,7 +560,7 @@ public void testInfoBucket() throws Exception {
|
|||||||
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||||
|
|
||||||
// test get info from a non-exist bucket
|
// test get info from a non-exist bucket
|
||||||
args = new String[] {"-infoBucket",
|
args = new String[] {"bucket", "info",
|
||||||
url + "/" + vol.getName() + "/invalid-bucket" + bucketName};
|
url + "/" + vol.getName() + "/invalid-bucket" + bucketName};
|
||||||
executeWithError(shell, args,
|
executeWithError(shell, args,
|
||||||
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
||||||
@ -573,8 +575,8 @@ public void testUpdateBucket() throws Exception {
|
|||||||
OzoneBucket bucket = vol.getBucket(bucketName);
|
OzoneBucket bucket = vol.getBucket(bucketName);
|
||||||
int aclSize = bucket.getAcls().size();
|
int aclSize = bucket.getAcls().size();
|
||||||
|
|
||||||
String[] args = new String[] {"-updateBucket",
|
String[] args = new String[] {"bucket", "update",
|
||||||
url + "/" + vol.getName() + "/" + bucketName, "-addAcl",
|
url + "/" + vol.getName() + "/" + bucketName, "--addAcl",
|
||||||
"user:frodo:rw,group:samwise:r"};
|
"user:frodo:rw,group:samwise:r"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
String output = out.toString();
|
String output = out.toString();
|
||||||
@ -589,8 +591,8 @@ public void testUpdateBucket() throws Exception {
|
|||||||
&& acl.getType() == OzoneACLType.USER
|
&& acl.getType() == OzoneACLType.USER
|
||||||
&& acl.getRights()== OzoneACLRights.READ_WRITE);
|
&& acl.getRights()== OzoneACLRights.READ_WRITE);
|
||||||
|
|
||||||
args = new String[] {"-updateBucket",
|
args = new String[] {"bucket", "update",
|
||||||
url + "/" + vol.getName() + "/" + bucketName, "-removeAcl",
|
url + "/" + vol.getName() + "/" + bucketName, "--removeAcl",
|
||||||
"user:frodo:rw"};
|
"user:frodo:rw"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
|
|
||||||
@ -602,8 +604,8 @@ public void testUpdateBucket() throws Exception {
|
|||||||
&& acl.getRights()== OzoneACLRights.READ);
|
&& acl.getRights()== OzoneACLRights.READ);
|
||||||
|
|
||||||
// test update bucket for a non-exist bucket
|
// test update bucket for a non-exist bucket
|
||||||
args = new String[] {"-updateBucket",
|
args = new String[] {"bucket", "update",
|
||||||
url + "/" + vol.getName() + "/invalid-bucket", "-addAcl",
|
url + "/" + vol.getName() + "/invalid-bucket", "--addAcl",
|
||||||
"user:frodo:rw"};
|
"user:frodo:rw"};
|
||||||
executeWithError(shell, args,
|
executeWithError(shell, args,
|
||||||
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
||||||
@ -628,8 +630,8 @@ public void testListBucket() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// test -length option
|
// test -length option
|
||||||
String[] args = new String[] {"-listBucket",
|
String[] args = new String[] {"bucket", "list",
|
||||||
url + "/" + vol.getName(), "-length", "100"};
|
url + "/" + vol.getName(), "--length", "100"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
@ -648,8 +650,8 @@ public void testListBucket() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listBucket", url + "/" + vol.getName(),
|
args = new String[] {"bucket", "list", url + "/" + vol.getName(),
|
||||||
"-length", "3"};
|
"--length", "3"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
@ -662,10 +664,10 @@ public void testListBucket() throws Exception {
|
|||||||
assertEquals(buckets.get(1).getBucketName(), "test-bucket1");
|
assertEquals(buckets.get(1).getBucketName(), "test-bucket1");
|
||||||
assertEquals(buckets.get(2).getBucketName(), "test-bucket10");
|
assertEquals(buckets.get(2).getBucketName(), "test-bucket10");
|
||||||
|
|
||||||
// test -prefix option
|
// test --prefix option
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listBucket", url + "/" + vol.getName(),
|
args = new String[] {"bucket", "list", url + "/" + vol.getName(),
|
||||||
"-length", "100", "-prefix", "test-bucket1"};
|
"--length", "100", "--prefix", "test-bucket1"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
@ -678,8 +680,8 @@ public void testListBucket() throws Exception {
|
|||||||
|
|
||||||
// test -start option
|
// test -start option
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listBucket", url + "/" + vol.getName(),
|
args = new String[] {"bucket", "list", url + "/" + vol.getName(),
|
||||||
"-length", "100", "-start", "test-bucket7"};
|
"--length", "100", "--start", "test-bucket7"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
buckets = (List<BucketInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
@ -691,8 +693,8 @@ public void testListBucket() throws Exception {
|
|||||||
|
|
||||||
// test error conditions
|
// test error conditions
|
||||||
err.reset();
|
err.reset();
|
||||||
args = new String[] {"-listBucket", url + "/" + vol.getName(),
|
args = new String[] {"bucket", "list", url + "/" + vol.getName(),
|
||||||
"-length", "-1"};
|
"--length", "-1"};
|
||||||
executeWithError(shell, args, "the length should be a positive number");
|
executeWithError(shell, args, "the length should be a positive number");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,8 +706,8 @@ public void testPutKey() throws Exception {
|
|||||||
String bucketName = bucket.getName();
|
String bucketName = bucket.getName();
|
||||||
String keyName = "key" + RandomStringUtils.randomNumeric(5);
|
String keyName = "key" + RandomStringUtils.randomNumeric(5);
|
||||||
|
|
||||||
String[] args = new String[] {"-putKey",
|
String[] args = new String[] {"key", "put",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName, "-file",
|
url + "/" + volumeName + "/" + bucketName + "/" + keyName,
|
||||||
createTmpFile()};
|
createTmpFile()};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
|
|
||||||
@ -713,8 +715,8 @@ public void testPutKey() throws Exception {
|
|||||||
assertEquals(keyName, keyInfo.getName());
|
assertEquals(keyName, keyInfo.getName());
|
||||||
|
|
||||||
// test put key in a non-exist bucket
|
// test put key in a non-exist bucket
|
||||||
args = new String[] {"-putKey",
|
args = new String[] {"key", "put",
|
||||||
url + "/" + volumeName + "/invalid-bucket/" + keyName, "-file",
|
url + "/" + volumeName + "/invalid-bucket/" + keyName,
|
||||||
createTmpFile()};
|
createTmpFile()};
|
||||||
executeWithError(shell, args,
|
executeWithError(shell, args,
|
||||||
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
||||||
@ -736,8 +738,8 @@ public void testGetKey() throws Exception {
|
|||||||
|
|
||||||
String tmpPath = baseDir.getAbsolutePath() + "/testfile-"
|
String tmpPath = baseDir.getAbsolutePath() + "/testfile-"
|
||||||
+ UUID.randomUUID().toString();
|
+ UUID.randomUUID().toString();
|
||||||
String[] args = new String[] {"-getKey",
|
String[] args = new String[] {"key", "get",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName, "-file",
|
url + "/" + volumeName + "/" + bucketName + "/" + keyName,
|
||||||
tmpPath};
|
tmpPath};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
|
|
||||||
@ -748,8 +750,8 @@ public void testGetKey() throws Exception {
|
|||||||
assertEquals(dataStr, DFSUtil.bytes2String(dataBytes));
|
assertEquals(dataStr, DFSUtil.bytes2String(dataBytes));
|
||||||
|
|
||||||
tmpPath = baseDir.getAbsolutePath() + File.separatorChar + keyName;
|
tmpPath = baseDir.getAbsolutePath() + File.separatorChar + keyName;
|
||||||
args = new String[] {"-getKey",
|
args = new String[] {"key", "get",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName, "-file",
|
url + "/" + volumeName + "/" + bucketName + "/" + keyName,
|
||||||
baseDir.getAbsolutePath()};
|
baseDir.getAbsolutePath()};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
|
|
||||||
@ -776,7 +778,7 @@ public void testDeleteKey() throws Exception {
|
|||||||
OzoneKey keyInfo = bucket.getKey(keyName);
|
OzoneKey keyInfo = bucket.getKey(keyName);
|
||||||
assertEquals(keyName, keyInfo.getName());
|
assertEquals(keyName, keyInfo.getName());
|
||||||
|
|
||||||
String[] args = new String[] {"-deleteKey",
|
String[] args = new String[] {"key", "delete",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName};
|
url + "/" + volumeName + "/" + bucketName + "/" + keyName};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
|
|
||||||
@ -790,14 +792,14 @@ public void testDeleteKey() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// test delete key in a non-exist bucket
|
// test delete key in a non-exist bucket
|
||||||
args = new String[] {"-deleteKey",
|
args = new String[] {"key", "delete",
|
||||||
url + "/" + volumeName + "/invalid-bucket/" + keyName};
|
url + "/" + volumeName + "/invalid-bucket/" + keyName};
|
||||||
executeWithError(shell, args,
|
executeWithError(shell, args,
|
||||||
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
"Info Bucket failed, error: BUCKET_NOT_FOUND");
|
||||||
|
|
||||||
err.reset();
|
err.reset();
|
||||||
// test delete a non-exist key in bucket
|
// test delete a non-exist key in bucket
|
||||||
args = new String[] {"-deleteKey",
|
args = new String[] {"key", "delete",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/invalid-key"};
|
url + "/" + volumeName + "/" + bucketName + "/invalid-key"};
|
||||||
executeWithError(shell, args, "Delete key failed, error:KEY_NOT_FOUND");
|
executeWithError(shell, args, "Delete key failed, error:KEY_NOT_FOUND");
|
||||||
}
|
}
|
||||||
@ -815,7 +817,7 @@ public void testInfoKeyDetails() throws Exception {
|
|||||||
keyOutputStream.write(dataStr.getBytes());
|
keyOutputStream.write(dataStr.getBytes());
|
||||||
keyOutputStream.close();
|
keyOutputStream.close();
|
||||||
|
|
||||||
String[] args = new String[] {"-infoKey",
|
String[] args = new String[] {"key", "info",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName};
|
url + "/" + volumeName + "/" + bucketName + "/" + keyName};
|
||||||
|
|
||||||
// verify the response output
|
// verify the response output
|
||||||
@ -834,7 +836,7 @@ public void testInfoKeyDetails() throws Exception {
|
|||||||
err.reset();
|
err.reset();
|
||||||
|
|
||||||
// get the info of a non-exist key
|
// get the info of a non-exist key
|
||||||
args = new String[] {"-infoKey",
|
args = new String[] {"key", "info",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/invalid-key"};
|
url + "/" + volumeName + "/" + bucketName + "/invalid-key"};
|
||||||
|
|
||||||
// verify the response output
|
// verify the response output
|
||||||
@ -855,7 +857,7 @@ public void testInfoDirKey() throws Exception {
|
|||||||
bucket.createKey(dirKeyName, dataStr.length());
|
bucket.createKey(dirKeyName, dataStr.length());
|
||||||
keyOutputStream.write(dataStr.getBytes());
|
keyOutputStream.write(dataStr.getBytes());
|
||||||
keyOutputStream.close();
|
keyOutputStream.close();
|
||||||
String[] args = new String[] {"-infoKey",
|
String[] args = new String[] {"key", "info",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/" + dirKeyName};
|
url + "/" + volumeName + "/" + bucketName + "/" + dirKeyName};
|
||||||
// verify the response output
|
// verify the response output
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
@ -864,7 +866,7 @@ public void testInfoDirKey() throws Exception {
|
|||||||
assertTrue(output.contains("createdOn") &&
|
assertTrue(output.contains("createdOn") &&
|
||||||
output.contains("modifiedOn") &&
|
output.contains("modifiedOn") &&
|
||||||
output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||||
args = new String[] {"-infoKey",
|
args = new String[] {"key", "info",
|
||||||
url + "/" + volumeName + "/" + bucketName + "/" + keyNameOnly};
|
url + "/" + volumeName + "/" + bucketName + "/" + keyNameOnly};
|
||||||
executeWithError(shell, args, "Lookup key failed, error:KEY_NOT_FOUND");
|
executeWithError(shell, args, "Lookup key failed, error:KEY_NOT_FOUND");
|
||||||
out.reset();
|
out.reset();
|
||||||
@ -894,8 +896,8 @@ public void testListKey() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// test -length option
|
// test -length option
|
||||||
String[] args = new String[] {"-listKey",
|
String[] args = new String[] {"key", "list",
|
||||||
url + "/" + volumeName + "/" + bucketName, "-length", "100"};
|
url + "/" + volumeName + "/" + bucketName, "--length", "100"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
@ -916,8 +918,9 @@ public void testListKey() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listKey", url + "/" + volumeName + "/" + bucketName,
|
args =
|
||||||
"-length", "3"};
|
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||||
|
"--length", "3"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
@ -929,10 +932,11 @@ public void testListKey() throws Exception {
|
|||||||
assertEquals(keys.get(1).getKeyName(), "test-key1");
|
assertEquals(keys.get(1).getKeyName(), "test-key1");
|
||||||
assertEquals(keys.get(2).getKeyName(), "test-key10");
|
assertEquals(keys.get(2).getKeyName(), "test-key10");
|
||||||
|
|
||||||
// test -prefix option
|
// test --prefix option
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listKey", url + "/" + volumeName + "/" + bucketName,
|
args =
|
||||||
"-length", "100", "-prefix", "test-key1"};
|
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||||
|
"--length", "100", "--prefix", "test-key1"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
@ -945,8 +949,9 @@ public void testListKey() throws Exception {
|
|||||||
|
|
||||||
// test -start option
|
// test -start option
|
||||||
out.reset();
|
out.reset();
|
||||||
args = new String[] {"-listKey", url + "/" + volumeName + "/" + bucketName,
|
args =
|
||||||
"-length", "100", "-start", "test-key7"};
|
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||||
|
"--length", "100", "--start", "test-key7"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
@ -957,8 +962,9 @@ public void testListKey() throws Exception {
|
|||||||
|
|
||||||
// test error conditions
|
// test error conditions
|
||||||
err.reset();
|
err.reset();
|
||||||
args = new String[] {"-listKey", url + "/" + volumeName + "/" + bucketName,
|
args =
|
||||||
"-length", "-1"};
|
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||||
|
"--length", "-1"};
|
||||||
executeWithError(shell, args, "the length should be a positive number");
|
executeWithError(shell, args, "the length should be a positive number");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,25 +18,25 @@
|
|||||||
|
|
||||||
package org.apache.hadoop.ozone.web.ozShell;
|
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.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.concurrent.Callable;
|
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_HTTP_SCHEME;
|
||||||
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_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.Command;
|
||||||
import picocli.CommandLine.ParentCommand;
|
import picocli.CommandLine.ParentCommand;
|
||||||
|
|
||||||
@ -52,20 +52,7 @@ public abstract class Handler implements Callable<Void> {
|
|||||||
protected OzoneClient client;
|
protected OzoneClient client;
|
||||||
|
|
||||||
@ParentCommand
|
@ParentCommand
|
||||||
private Shell parent;
|
private GenericParentCommand 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
@ -169,4 +156,5 @@ private static URI stringToUri(String pathString) throws IOException {
|
|||||||
public boolean isVerbose() {
|
public boolean isVerbose() {
|
||||||
return parent.isVerbose();
|
return parent.isVerbose();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,21 +20,9 @@
|
|||||||
|
|
||||||
import org.apache.hadoop.hdds.cli.GenericCli;
|
import org.apache.hadoop.hdds.cli.GenericCli;
|
||||||
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
|
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.bucket.CreateBucketHandler;
|
import org.apache.hadoop.ozone.web.ozShell.bucket.BucketCommands;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.bucket.DeleteBucketHandler;
|
import org.apache.hadoop.ozone.web.ozShell.keys.KeyCommands;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.bucket.InfoBucketHandler;
|
import org.apache.hadoop.ozone.web.ozShell.volume.VolumeCommands;
|
||||||
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.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -49,21 +37,9 @@
|
|||||||
@Command(name = "ozone oz",
|
@Command(name = "ozone oz",
|
||||||
description = "Client for the Ozone object store",
|
description = "Client for the Ozone object store",
|
||||||
subcommands = {
|
subcommands = {
|
||||||
InfoVolumeHandler.class,
|
VolumeCommands.class,
|
||||||
ListVolumeHandler.class,
|
BucketCommands.class,
|
||||||
CreateVolumeHandler.class,
|
KeyCommands.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
|
|
||||||
},
|
},
|
||||||
versionProvider = HddsVersionProvider.class,
|
versionProvider = HddsVersionProvider.class,
|
||||||
mixinStandardHelpOptions = true)
|
mixinStandardHelpOptions = true)
|
||||||
@ -100,8 +76,5 @@ public class Shell extends GenericCli {
|
|||||||
public static void main(String[] argv) throws Exception {
|
public static void main(String[] argv) throws Exception {
|
||||||
new Shell().run(argv);
|
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 @@
|
|||||||
/**
|
/**
|
||||||
* create bucket handler.
|
* create bucket handler.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-createBucket",
|
@Command(name = "create",
|
||||||
description = "creates a bucket in a given volume")
|
description = "creates a bucket in a given volume")
|
||||||
public class CreateBucketHandler extends Handler {
|
public class CreateBucketHandler extends Handler {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
/**
|
/**
|
||||||
* Delete bucket Handler.
|
* Delete bucket Handler.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-deleteBucket",
|
@Command(name = "delete",
|
||||||
description = "deletes an empty bucket")
|
description = "deletes an empty bucket")
|
||||||
public class DeleteBucketHandler extends Handler {
|
public class DeleteBucketHandler extends Handler {
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
/**
|
/**
|
||||||
* Executes Info bucket.
|
* Executes Info bucket.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-infoBucket",
|
@Command(name = "info",
|
||||||
description = "returns information about a bucket")
|
description = "returns information about a bucket")
|
||||||
public class InfoBucketHandler extends Handler {
|
public class InfoBucketHandler extends Handler {
|
||||||
|
|
||||||
|
@ -42,24 +42,25 @@
|
|||||||
/**
|
/**
|
||||||
* Executes List Bucket.
|
* Executes List Bucket.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-listBucket",
|
@Command(name = "list",
|
||||||
|
aliases = "ls",
|
||||||
description = "lists the buckets in a volume.")
|
description = "lists the buckets in a volume.")
|
||||||
public class ListBucketHandler extends Handler {
|
public class ListBucketHandler extends Handler {
|
||||||
|
|
||||||
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Option(names = {"--length", "-length", "-l"},
|
@Option(names = {"--length", "-l"},
|
||||||
description = "Limit of the max results",
|
description = "Limit of the max results",
|
||||||
defaultValue = "100",
|
defaultValue = "100",
|
||||||
showDefaultValue = Visibility.ALWAYS)
|
showDefaultValue = Visibility.ALWAYS)
|
||||||
private int maxBuckets;
|
private int maxBuckets;
|
||||||
|
|
||||||
@Option(names = {"--start", "-start", "-s"},
|
@Option(names = {"--start", "-s"},
|
||||||
description = "The first bucket to start the listing")
|
description = "The first bucket to start the listing")
|
||||||
private String startBucket;
|
private String startBucket;
|
||||||
|
|
||||||
@Option(names = {"--prefix", "-prefix", "-p"},
|
@Option(names = {"--prefix", "-p"},
|
||||||
description = "Prefix to filter the buckets")
|
description = "Prefix to filter the buckets")
|
||||||
private String prefix;
|
private String prefix;
|
||||||
/**
|
/**
|
||||||
|
@ -40,19 +40,19 @@
|
|||||||
/**
|
/**
|
||||||
* Allows users to add and remove acls and from a bucket.
|
* Allows users to add and remove acls and from a bucket.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-updateBucket",
|
@Command(name = "update",
|
||||||
description = "allows changing bucket attributes")
|
description = "allows changing bucket attributes")
|
||||||
public class UpdateBucketHandler extends Handler {
|
public class UpdateBucketHandler extends Handler {
|
||||||
|
|
||||||
@Parameters(arity = "1..1", description = Shell.OZONE_BUCKET_URI_DESCRIPTION)
|
@Parameters(arity = "1..1", description = Shell.OZONE_BUCKET_URI_DESCRIPTION)
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Option(names = {"--addAcl", "-addAcl"},
|
@Option(names = {"--addAcl"},
|
||||||
description = "Comma separated list of acl rules to add (eg. " +
|
description = "Comma separated list of acl rules to add (eg. " +
|
||||||
"user:bilbo:rw)")
|
"user:bilbo:rw)")
|
||||||
private String addAcl;
|
private String addAcl;
|
||||||
|
|
||||||
@Option(names = {"--removeAcl", "-removeAcl"},
|
@Option(names = {"--removeAcl"},
|
||||||
description = "Comma separated list of acl rules to remove (eg. "
|
description = "Comma separated list of acl rules to remove (eg. "
|
||||||
+ "user:bilbo:rw)")
|
+ "user:bilbo:rw)")
|
||||||
private String removeAcl;
|
private String removeAcl;
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
/**
|
/**
|
||||||
* Executes Delete Key.
|
* Executes Delete Key.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-deleteKey",
|
@Command(name = "delete",
|
||||||
description = "deletes an existing key")
|
description = "deletes an existing key")
|
||||||
public class DeleteKeyHandler extends Handler {
|
public class DeleteKeyHandler extends Handler {
|
||||||
|
|
||||||
|
@ -38,22 +38,21 @@
|
|||||||
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_DEFAULT;
|
||||||
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CHUNK_SIZE_KEY;
|
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CHUNK_SIZE_KEY;
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
import picocli.CommandLine.Option;
|
|
||||||
import picocli.CommandLine.Parameters;
|
import picocli.CommandLine.Parameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an existing key.
|
* Gets an existing key.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-getKey",
|
@Command(name = "get",
|
||||||
description = "Gets a specific key from ozone server")
|
description = "Gets a specific key from ozone server")
|
||||||
public class GetKeyHandler extends Handler {
|
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;
|
private String uri;
|
||||||
|
|
||||||
@Option(names = {"-f", "--file", "-file"},
|
@Parameters(index = "1", arity = "1..1",
|
||||||
description = "File path to download the key to",
|
description = "File path to download the key to")
|
||||||
required = true)
|
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
/**
|
/**
|
||||||
* Executes Info Object.
|
* Executes Info Object.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-infoKey",
|
@Command(name = "info",
|
||||||
description = "returns information about an existing key")
|
description = "returns information about an existing key")
|
||||||
public class InfoKeyHandler extends Handler {
|
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 @@
|
|||||||
/**
|
/**
|
||||||
* Executes List Keys.
|
* Executes List Keys.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-listKey",
|
@Command(name = "list",
|
||||||
|
aliases = "ls",
|
||||||
description = "list all keys in a given bucket")
|
description = "list all keys in a given bucket")
|
||||||
public class ListKeyHandler extends Handler {
|
public class ListKeyHandler extends Handler {
|
||||||
|
|
||||||
@Parameters(arity = "1..1", description = Shell.OZONE_BUCKET_URI_DESCRIPTION)
|
@Parameters(arity = "1..1", description = Shell.OZONE_BUCKET_URI_DESCRIPTION)
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Option(names = {"--length", "-length", "-l"},
|
@Option(names = {"--length", "-l"},
|
||||||
description = "Limit of the max results",
|
description = "Limit of the max results",
|
||||||
defaultValue = "100")
|
defaultValue = "100")
|
||||||
private int maxKeys;
|
private int maxKeys;
|
||||||
|
|
||||||
@Option(names = {"--start", "-start", "-s"},
|
@Option(names = {"--start", "-s"},
|
||||||
description = "The first key to start the listing")
|
description = "The first key to start the listing")
|
||||||
private String startKey;
|
private String startKey;
|
||||||
|
|
||||||
@Option(names = {"--prefix", "-prefix", "-p"},
|
@Option(names = {"--prefix", "-p"},
|
||||||
description = "Prefix to filter the key")
|
description = "Prefix to filter the key")
|
||||||
private String prefix;
|
private String prefix;
|
||||||
|
|
||||||
|
@ -50,19 +50,18 @@
|
|||||||
/**
|
/**
|
||||||
* Puts a file into an ozone bucket.
|
* Puts a file into an ozone bucket.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-putKey",
|
@Command(name = "put",
|
||||||
description = "creates or overwrites an existing key")
|
description = "creates or overwrites an existing key")
|
||||||
public class PutKeyHandler extends Handler {
|
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;
|
private String uri;
|
||||||
|
|
||||||
@Option(names = {"-f", "--file", "-file"},
|
@Parameters(index = "1", arity = "1..1", description = "File to upload")
|
||||||
description = "File to upload",
|
|
||||||
required = true)
|
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
@Option(names = {"-r", "--replication", "-replicationFactor"},
|
@Option(names = {"-r", "--replication"},
|
||||||
description = "Replication factor of the new key. (use ONE or THREE) "
|
description = "Replication factor of the new key. (use ONE or THREE) "
|
||||||
+ "Default is specified in the cluster-wide config.")
|
+ "Default is specified in the cluster-wide config.")
|
||||||
private ReplicationFactor replicationFactor;
|
private ReplicationFactor replicationFactor;
|
||||||
|
@ -18,41 +18,41 @@
|
|||||||
|
|
||||||
package org.apache.hadoop.ozone.web.ozShell.volume;
|
package org.apache.hadoop.ozone.web.ozShell.volume;
|
||||||
|
|
||||||
import picocli.CommandLine.Command;
|
import java.net.URI;
|
||||||
import picocli.CommandLine.Option;
|
|
||||||
import picocli.CommandLine.Parameters;
|
|
||||||
|
|
||||||
|
import org.apache.hadoop.ozone.client.OzoneClientException;
|
||||||
import org.apache.hadoop.ozone.client.OzoneClientUtils;
|
import org.apache.hadoop.ozone.client.OzoneClientUtils;
|
||||||
import org.apache.hadoop.ozone.client.OzoneVolume;
|
import org.apache.hadoop.ozone.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.client.VolumeArgs;
|
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.Handler;
|
||||||
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
import org.apache.hadoop.ozone.web.ozShell.Shell;
|
||||||
import org.apache.hadoop.ozone.web.utils.JsonUtils;
|
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.
|
* Executes the create volume call for the shell.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-createVolume",
|
@Command(name = "create",
|
||||||
description = "Creates a volume for the specified user")
|
description = "Creates a volume for the specified user")
|
||||||
public class CreateVolumeHandler extends Handler {
|
public class CreateVolumeHandler extends Handler {
|
||||||
|
|
||||||
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Option(names = {"--user", "-user"},
|
@Option(names = {"--user", "-u"},
|
||||||
description = "Owner of of the volume", required =
|
description = "Owner of of the volume", required =
|
||||||
true)
|
true)
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
@Option(names = {"--quota", "-quota"},
|
@Option(names = {"--quota", "-q"},
|
||||||
description =
|
description =
|
||||||
"Quota of the newly created volume (eg. 1G)")
|
"Quota of the newly created volume (eg. 1G)")
|
||||||
private String quota;
|
private String quota;
|
||||||
|
|
||||||
@Option(names = {"--root", "-root"},
|
@Option(names = {"--root"},
|
||||||
description = "Development flag to execute the "
|
description = "Development flag to execute the "
|
||||||
+ "command as the admin (hdfs) user.")
|
+ "command as the admin (hdfs) user.")
|
||||||
private boolean root;
|
private boolean root;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
/**
|
/**
|
||||||
* Executes deleteVolume call for the shell.
|
* Executes deleteVolume call for the shell.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-deleteVolume",
|
@Command(name = "delete",
|
||||||
description = "deletes a volume if it is empty")
|
description = "deletes a volume if it is empty")
|
||||||
public class DeleteVolumeHandler extends Handler {
|
public class DeleteVolumeHandler extends Handler {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
/**
|
/**
|
||||||
* Executes volume Info calls.
|
* Executes volume Info calls.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-infoVolume",
|
@Command(name = "info",
|
||||||
description = "returns information about a specific volume")
|
description = "returns information about a specific volume")
|
||||||
public class InfoVolumeHandler extends Handler{
|
public class InfoVolumeHandler extends Handler{
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@
|
|||||||
/**
|
/**
|
||||||
* Executes List Volume call.
|
* Executes List Volume call.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-listVolume",
|
@Command(name = "list",
|
||||||
|
aliases = "ls",
|
||||||
description = "List the volumes of a given user")
|
description = "List the volumes of a given user")
|
||||||
public class ListVolumeHandler extends Handler {
|
public class ListVolumeHandler extends Handler {
|
||||||
|
|
||||||
@ -48,20 +49,20 @@ public class ListVolumeHandler extends Handler {
|
|||||||
defaultValue = "/")
|
defaultValue = "/")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Option(names = {"--length", "-length", "-l"},
|
@Option(names = {"--length", "-l"},
|
||||||
description = "Limit of the max results",
|
description = "Limit of the max results",
|
||||||
defaultValue = "100")
|
defaultValue = "100")
|
||||||
private int maxVolumes;
|
private int maxVolumes;
|
||||||
|
|
||||||
@Option(names = {"--start", "-start", "-s"},
|
@Option(names = {"--start", "-s"},
|
||||||
description = "The first volume to start the listing")
|
description = "The first volume to start the listing")
|
||||||
private String startVolume;
|
private String startVolume;
|
||||||
|
|
||||||
@Option(names = {"--prefix", "-prefix", "-p"},
|
@Option(names = {"--prefix", "-p"},
|
||||||
description = "Prefix to filter the volumes")
|
description = "Prefix to filter the volumes")
|
||||||
private String prefix;
|
private String prefix;
|
||||||
|
|
||||||
@Option(names = {"--user", "-user", "-u"},
|
@Option(names = {"--user", "-u"},
|
||||||
description = "Owner of the volumes to list.")
|
description = "Owner of the volumes to list.")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
@ -35,18 +35,18 @@
|
|||||||
/**
|
/**
|
||||||
* Executes update volume calls.
|
* Executes update volume calls.
|
||||||
*/
|
*/
|
||||||
@Command(name = "-updateVolume",
|
@Command(name = "update",
|
||||||
description = "Updates parameter of the volumes")
|
description = "Updates parameter of the volumes")
|
||||||
public class UpdateVolumeHandler extends Handler {
|
public class UpdateVolumeHandler extends Handler {
|
||||||
|
|
||||||
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
@Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Option(names = {"--user", "-user"},
|
@Option(names = {"--user"},
|
||||||
description = "Owner of the volume to set")
|
description = "Owner of the volume to set")
|
||||||
private String ownerName;
|
private String ownerName;
|
||||||
|
|
||||||
@Option(names = {"--quota", "-quota"},
|
@Option(names = {"--quota"},
|
||||||
description = "Quota of the volume to set"
|
description = "Quota of the volume to set"
|
||||||
+ "(eg. 1G)")
|
+ "(eg. 1G)")
|
||||||
private String quota;
|
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
Block a user