parent
4ed0aefe9f
commit
ef478fe73e
@ -178,7 +178,7 @@ function ozonecmd_case
|
||||
OZONE_RUN_ARTIFACT_NAME="hadoop-ozone-recon"
|
||||
;;
|
||||
fs)
|
||||
HADOOP_CLASSNAME=org.apache.hadoop.fs.FsShell
|
||||
HADOOP_CLASSNAME=org.apache.hadoop.fs.ozone.OzoneFsShell
|
||||
OZONE_RUN_ARTIFACT_NAME="hadoop-ozone-tools"
|
||||
;;
|
||||
scmcli)
|
||||
|
@ -0,0 +1,100 @@
|
||||
/**
|
||||
* 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.fs.ozone;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.conf.Configured;
|
||||
import org.apache.hadoop.fs.FsShell;
|
||||
import org.apache.hadoop.fs.shell.Command;
|
||||
import org.apache.hadoop.fs.shell.CommandFactory;
|
||||
import org.apache.hadoop.fs.shell.FsCommand;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.tools.TableListing;
|
||||
import org.apache.hadoop.tracing.TraceUtils;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.hadoop.util.Tool;
|
||||
import org.apache.hadoop.util.ToolRunner;
|
||||
import org.apache.htrace.core.TraceScope;
|
||||
import org.apache.htrace.core.Tracer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/** Provide command line access to a Ozone FileSystem. */
|
||||
@InterfaceAudience.Private
|
||||
public class OzoneFsShell extends FsShell {
|
||||
|
||||
private final String ozoneUsagePrefix = "Usage: ozone fs [generic options]";
|
||||
|
||||
/**
|
||||
* Default ctor with no configuration. Be sure to invoke
|
||||
* {@link #setConf(Configuration)} with a valid configuration prior
|
||||
* to running commands.
|
||||
*/
|
||||
public OzoneFsShell() { this(null); }
|
||||
|
||||
/**
|
||||
* Construct a OzoneFsShell with the given configuration. Commands can be
|
||||
* executed via {@link #run(String[])}
|
||||
* @param conf the hadoop configuration
|
||||
*/
|
||||
public OzoneFsShell(Configuration conf) { super(conf); }
|
||||
|
||||
protected void registerCommands(CommandFactory factory) {
|
||||
// TODO: DFSAdmin subclasses FsShell so need to protect the command
|
||||
// registration. This class should morph into a base class for
|
||||
// commands, and then this method can be abstract
|
||||
if (this.getClass().equals(OzoneFsShell.class)) {
|
||||
factory.registerCommands(FsCommand.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getUsagePrefix() {
|
||||
return ozoneUsagePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* main() has some simple utility methods
|
||||
* @param argv the command and its arguments
|
||||
* @throws Exception upon error
|
||||
*/
|
||||
public static void main(String argv[]) throws Exception {
|
||||
OzoneFsShell shell = newShellInstance();
|
||||
Configuration conf = new Configuration();
|
||||
conf.setQuietMode(false);
|
||||
shell.setConf(conf);
|
||||
int res;
|
||||
try {
|
||||
res = ToolRunner.run(shell, argv);
|
||||
} finally {
|
||||
shell.close();
|
||||
}
|
||||
System.exit(res);
|
||||
}
|
||||
|
||||
// TODO: this should be abstract in a base class
|
||||
protected static OzoneFsShell newShellInstance() {
|
||||
return new OzoneFsShell();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user