HADOOP-7014. Adding missed files
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1092853 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
58ca2272bc
commit
98a2b7051f
|
@ -6,9 +6,9 @@
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
* <p/>
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
* <p/>
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -17,21 +17,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.cli.util;
|
package org.apache.hadoop.cli.util;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.FsShell;
|
/**
|
||||||
|
* This interface is to generalize types of test command for upstream projects
|
||||||
public abstract class CmdFactory {
|
*/
|
||||||
public static CommandExecutor getCommandExecutor(CLITestData.TestCmd cmd,
|
public interface CLICommand {
|
||||||
String tag)
|
public CommandExecutor getExecutor(String tag) throws IllegalArgumentException;
|
||||||
throws IllegalArgumentException {
|
public CLICommandTypes getType();
|
||||||
CommandExecutor executor = null;
|
public String getCmd();
|
||||||
switch (cmd.getType()) {
|
public String toString();
|
||||||
case FS:
|
|
||||||
executor = new CLICommands.FSCmdExecutor(tag, new FsShell());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown type of Test command:" +
|
|
||||||
cmd.getType());
|
|
||||||
}
|
|
||||||
return executor;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**
|
||||||
|
* 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.cli.util;
|
||||||
|
|
||||||
|
public class CLICommandFS implements CLICommandTypes {
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* 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.cli.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface is to provide command type for test commands enums
|
||||||
|
*/
|
||||||
|
public interface CLICommandTypes {
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
* 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.cli.util;
|
||||||
|
|
||||||
|
import org.apache.hadoop.fs.FsShell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to define Test Command along with its type
|
||||||
|
*/
|
||||||
|
public class CLITestCmd implements CLICommand {
|
||||||
|
private final CLICommandTypes type;
|
||||||
|
private final String cmd;
|
||||||
|
|
||||||
|
public CLITestCmd(String str, CLICommandTypes type) {
|
||||||
|
cmd = str;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutor getExecutor(String tag) throws IllegalArgumentException {
|
||||||
|
if (getType() instanceof CLICommandFS)
|
||||||
|
return new FSCmdExecutor(tag, new FsShell());
|
||||||
|
throw new
|
||||||
|
IllegalArgumentException("Unknown type of test command: " + getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CLICommandTypes getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
public String getCmd() {
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
public String toString() {
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,9 +20,7 @@ package org.apache.hadoop.cli.util;
|
||||||
import org.apache.hadoop.fs.FsShell;
|
import org.apache.hadoop.fs.FsShell;
|
||||||
import org.apache.hadoop.util.ToolRunner;
|
import org.apache.hadoop.util.ToolRunner;
|
||||||
|
|
||||||
public class CLICommands {
|
public class FSCmdExecutor extends CommandExecutor {
|
||||||
|
|
||||||
public static class FSCmdExecutor extends CommandExecutor {
|
|
||||||
protected String namenode = null;
|
protected String namenode = null;
|
||||||
protected FsShell shell = null;
|
protected FsShell shell = null;
|
||||||
|
|
||||||
|
@ -35,5 +33,4 @@ public class CLICommands {
|
||||||
String[] args = getCommandAsArgs(cmd, "NAMENODE", this.namenode);
|
String[] args = getCommandAsArgs(cmd, "NAMENODE", this.namenode);
|
||||||
ToolRunner.run(shell, args);
|
ToolRunner.run(shell, args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue