Author: cos Date: Sat Apr 16 01:43:30 2011 New Revision: 1092853 URL: http://svn.apache.org/viewvc?rev=1092853&view=rev Log: HADOOP-7014. Adding missed files
Added: hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommand.java hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandFS.java hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandTypes.java hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLITestCmd.java hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/FSCmdExecutor.java Removed: hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommands.java hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CmdFactory.java Added: hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommand.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommand.java?rev=1092853&view=auto ============================================================================== --- hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommand.java (added) +++ hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommand.java Sat Apr 16 01:43:30 2011 @@ -0,0 +1,28 @@ +/** + * 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 generalize types of test command for upstream projects + */ +public interface CLICommand { + public CommandExecutor getExecutor(String tag) throws IllegalArgumentException; + public CLICommandTypes getType(); + public String getCmd(); + public String toString(); +} Added: hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandFS.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandFS.java?rev=1092853&view=auto ============================================================================== --- hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandFS.java (added) +++ hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandFS.java Sat Apr 16 01:43:30 2011 @@ -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 { +} Added: hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandTypes.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandTypes.java?rev=1092853&view=auto ============================================================================== --- hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandTypes.java (added) +++ hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLICommandTypes.java Sat Apr 16 01:43:30 2011 @@ -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 { +} Added: hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLITestCmd.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLITestCmd.java?rev=1092853&view=auto ============================================================================== --- hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLITestCmd.java (added) +++ hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/CLITestCmd.java Sat Apr 16 01:43:30 2011 @@ -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; + } +} Added: hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/FSCmdExecutor.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/FSCmdExecutor.java?rev=1092853&view=auto ============================================================================== --- hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/FSCmdExecutor.java (added) +++ hadoop/common/trunk/src/test/core/org/apache/hadoop/cli/util/FSCmdExecutor.java Sat Apr 16 01:43:30 2011 @@ -0,0 +1,36 @@ +/* + * 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; +import org.apache.hadoop.util.ToolRunner; + +public class FSCmdExecutor extends CommandExecutor { + protected String namenode = null; + protected FsShell shell = null; + + public FSCmdExecutor(String namenode, FsShell shell) { + this.namenode = namenode; + this.shell = shell; + } + + protected void execute(final String cmd) throws Exception{ + String[] args = getCommandAsArgs(cmd, "NAMENODE", this.namenode); + ToolRunner.run(shell, args); + } +}