mirror of
https://github.com/apache/sqoop.git
synced 2025-05-05 04:00:54 +08:00
SQOOP-1424: Sqoop2: Simplify SqoopCommand in shell package
This commit is contained in:
parent
0ad7401bb5
commit
f01ab4d8d7
@ -37,6 +37,10 @@ limitations under the License.
|
|||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-all</artifactId>
|
<artifactId>mockito-all</artifactId>
|
||||||
|
5
pom.xml
5
pom.xml
@ -320,6 +320,11 @@ limitations under the License.
|
|||||||
<artifactId>json-simple</artifactId>
|
<artifactId>json-simple</artifactId>
|
||||||
<version>${json-simple.version}</version>
|
<version>${json-simple.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.sqoop.submission</groupId>
|
<groupId>org.apache.sqoop.submission</groupId>
|
||||||
<artifactId>sqoop-submission-mapreduce</artifactId>
|
<artifactId>sqoop-submission-mapreduce</artifactId>
|
||||||
|
@ -17,47 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client side cloning of connection and job objects.
|
* Client side cloning of connection and job objects.
|
||||||
*/
|
*/
|
||||||
public class CloneCommand extends SqoopCommand {
|
public class CloneCommand extends SqoopCommand {
|
||||||
|
|
||||||
private CloneConnectionFunction connectionFunction;
|
|
||||||
private CloneJobFunction jobFunction;
|
|
||||||
|
|
||||||
public CloneCommand(Shell shell) {
|
public CloneCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_CLONE, Constants.CMD_CLONE_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
|
Constants.CMD_CLONE,
|
||||||
Constants.PRE_CLONE, Constants.SUF_INFO);
|
Constants.CMD_CLONE_SC,
|
||||||
}
|
ImmutableMap.of(
|
||||||
|
Constants.FN_CONNECTION, CloneConnectionFunction.class,
|
||||||
public Object executeCommand(List args) {
|
Constants.FN_JOB, CloneJobFunction.class
|
||||||
if (args.size() == 0) {
|
)
|
||||||
printlnResource(Constants.RES_CLONE_USAGE, getUsage());
|
);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String)args.get(0);
|
|
||||||
if (func.equals(Constants.FN_CONNECTION)) {
|
|
||||||
if (connectionFunction == null) {
|
|
||||||
connectionFunction = new CloneConnectionFunction();
|
|
||||||
}
|
|
||||||
return connectionFunction.execute(args);
|
|
||||||
} else if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (jobFunction == null) {
|
|
||||||
jobFunction = new CloneJobFunction();
|
|
||||||
}
|
|
||||||
return jobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,47 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CreateCommand extends SqoopCommand {
|
public class CreateCommand extends SqoopCommand {
|
||||||
|
|
||||||
private CreateConnectionFunction connectionFunction;
|
|
||||||
private CreateJobFunction jobFunction;
|
|
||||||
|
|
||||||
public CreateCommand(Shell shell) {
|
public CreateCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_CREATE, Constants.CMD_CREATE_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
|
Constants.CMD_CREATE,
|
||||||
Constants.PRE_CREATE, Constants.SUF_INFO);
|
Constants.CMD_CREATE_SC,
|
||||||
}
|
ImmutableMap.of(
|
||||||
|
Constants.FN_CONNECTION, CreateConnectionFunction.class,
|
||||||
public Object executeCommand(List args) {
|
Constants.FN_JOB, CreateJobFunction.class
|
||||||
if (args.size() == 0) {
|
)
|
||||||
printlnResource(Constants.RES_CREATE_USAGE, getUsage());
|
);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String)args.get(0);
|
|
||||||
if (func.equals(Constants.FN_CONNECTION)) {
|
|
||||||
if (connectionFunction == null) {
|
|
||||||
connectionFunction = new CreateConnectionFunction();
|
|
||||||
}
|
|
||||||
return connectionFunction.execute(args);
|
|
||||||
} else if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (jobFunction == null) {
|
|
||||||
jobFunction = new CreateJobFunction();
|
|
||||||
}
|
|
||||||
return jobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,48 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DeleteCommand extends SqoopCommand {
|
public class DeleteCommand extends SqoopCommand {
|
||||||
|
|
||||||
private DeleteConnectionFunction connectionFunction;
|
|
||||||
private DeleteJobFunction jobFunction;
|
|
||||||
|
|
||||||
public DeleteCommand(Shell shell) {
|
public DeleteCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_DELETE, Constants.CMD_DELETE_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
|
Constants.CMD_DELETE,
|
||||||
Constants.PRE_DELETE, Constants.SUF_INFO);
|
Constants.CMD_DELETE_SC,
|
||||||
}
|
ImmutableMap.of(
|
||||||
|
Constants.FN_CONNECTION, DeleteConnectionFunction.class,
|
||||||
@Override
|
Constants.FN_JOB, DeleteJobFunction.class
|
||||||
@SuppressWarnings("unchecked")
|
)
|
||||||
public Object executeCommand(List args) {
|
);
|
||||||
if (args.size() == 0) {
|
|
||||||
printlnResource(Constants.RES_DELETE_USAGE, getUsage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String)args.get(0);
|
|
||||||
if (func.equals(Constants.FN_CONNECTION)) {
|
|
||||||
if (connectionFunction == null) {
|
|
||||||
connectionFunction = new DeleteConnectionFunction();
|
|
||||||
}
|
|
||||||
return connectionFunction.execute(args);
|
|
||||||
} else if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (jobFunction == null) {
|
|
||||||
jobFunction = new DeleteJobFunction();
|
|
||||||
}
|
|
||||||
return jobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,48 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DisableCommand extends SqoopCommand {
|
public class DisableCommand extends SqoopCommand {
|
||||||
|
|
||||||
private DisableConnectionFunction connectionFunction;
|
|
||||||
private DisableJobFunction jobFunction;
|
|
||||||
|
|
||||||
public DisableCommand(Shell shell) {
|
public DisableCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_DISABLE, Constants.CMD_DISABLE_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
|
Constants.CMD_DISABLE,
|
||||||
Constants.PRE_DISABLE, Constants.SUF_INFO);
|
Constants.CMD_DISABLE_SC,
|
||||||
}
|
ImmutableMap.of(
|
||||||
|
Constants.FN_CONNECTION, DisableConnectionFunction.class,
|
||||||
@Override
|
Constants.FN_JOB, DisableJobFunction.class
|
||||||
@SuppressWarnings("unchecked")
|
)
|
||||||
public Object executeCommand(List args) {
|
);
|
||||||
if (args.size() == 0) {
|
|
||||||
printlnResource(Constants.RES_DISABLE_USAGE, getUsage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String)args.get(0);
|
|
||||||
if (func.equals(Constants.FN_CONNECTION)) {
|
|
||||||
if (connectionFunction == null) {
|
|
||||||
connectionFunction = new DisableConnectionFunction();
|
|
||||||
}
|
|
||||||
return connectionFunction.execute(args);
|
|
||||||
} else if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (jobFunction == null) {
|
|
||||||
jobFunction = new DisableJobFunction();
|
|
||||||
}
|
|
||||||
return jobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,48 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EnableCommand extends SqoopCommand {
|
public class EnableCommand extends SqoopCommand {
|
||||||
|
|
||||||
private EnableConnectionFunction connectionFunction;
|
|
||||||
private EnableJobFunction jobFunction;
|
|
||||||
|
|
||||||
public EnableCommand(Shell shell) {
|
public EnableCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_ENABLE, Constants.CMD_ENABLE_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
|
Constants.CMD_ENABLE,
|
||||||
Constants.PRE_ENABLE, Constants.SUF_INFO);
|
Constants.CMD_ENABLE_SC,
|
||||||
}
|
ImmutableMap.of(
|
||||||
|
Constants.FN_CONNECTION, EnableConnectionFunction.class,
|
||||||
@Override
|
Constants.FN_JOB, EnableJobFunction.class
|
||||||
@SuppressWarnings("unchecked")
|
)
|
||||||
public Object executeCommand(List args) {
|
);
|
||||||
if (args.size() == 0) {
|
|
||||||
printlnResource(Constants.RES_ENABLE_USAGE, getUsage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String)args.get(0);
|
|
||||||
if (func.equals(Constants.FN_CONNECTION)) {
|
|
||||||
if (connectionFunction == null) {
|
|
||||||
connectionFunction = new EnableConnectionFunction();
|
|
||||||
}
|
|
||||||
return connectionFunction.execute(args);
|
|
||||||
} else if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (jobFunction == null) {
|
|
||||||
jobFunction = new EnableJobFunction();
|
|
||||||
}
|
|
||||||
return jobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,48 +17,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
import java.util.List;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
|
||||||
|
|
||||||
public class SetCommand extends SqoopCommand {
|
public class SetCommand extends SqoopCommand {
|
||||||
|
|
||||||
private SetServerFunction serverFunction;
|
|
||||||
private SetOptionFunction optionFunction;
|
|
||||||
|
|
||||||
protected SetCommand(Shell shell) {
|
protected SetCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_SET, Constants.CMD_SET_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_SERVER, Constants.FN_OPTION},
|
Constants.CMD_SET,
|
||||||
Constants.PRE_SET, Constants.SUF_INFO);
|
Constants.CMD_SET_SC,
|
||||||
}
|
ImmutableMap.of(
|
||||||
|
Constants.FN_SERVER, SetServerFunction.class,
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
Constants.FN_OPTION, SetOptionFunction.class
|
||||||
@Override
|
)
|
||||||
public Object executeCommand(List args) {
|
);
|
||||||
|
|
||||||
if (args.size() == 0) {
|
|
||||||
printlnResource(Constants.RES_SET_USAGE, getUsage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String func = (String)args.get(0);
|
|
||||||
if (func.equals(Constants.FN_SERVER)) {
|
|
||||||
if (serverFunction == null) {
|
|
||||||
serverFunction = new SetServerFunction();
|
|
||||||
}
|
|
||||||
return serverFunction.execute(args);
|
|
||||||
|
|
||||||
} else if (func.equals(Constants.FN_OPTION)) {
|
|
||||||
if (optionFunction == null) {
|
|
||||||
optionFunction = new SetOptionFunction();
|
|
||||||
}
|
|
||||||
return optionFunction.execute(args);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class SetOptionFunction extends SqoopFunction {
|
public class SetOptionFunction extends SqoopFunction {
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected SetOptionFunction() {
|
public SetOptionFunction() {
|
||||||
this.addOption(OptionBuilder.hasArg()
|
this.addOption(OptionBuilder.hasArg()
|
||||||
.withDescription(resourceString(Constants.RES_SET_PROMPT_OPT_NAME))
|
.withDescription(resourceString(Constants.RES_SET_PROMPT_OPT_NAME))
|
||||||
.withLongOpt(Constants.OPT_NAME)
|
.withLongOpt(Constants.OPT_NAME)
|
||||||
|
@ -26,8 +26,9 @@
|
|||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class SetServerFunction extends SqoopFunction {
|
public class SetServerFunction extends SqoopFunction {
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected SetServerFunction() {
|
public SetServerFunction() {
|
||||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_HOST)
|
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_HOST)
|
||||||
.withDescription(resourceString(Constants.RES_SET_HOST_DESCRIPTION))
|
.withDescription(resourceString(Constants.RES_SET_HOST_DESCRIPTION))
|
||||||
.withLongOpt(Constants.OPT_HOST)
|
.withLongOpt(Constants.OPT_HOST)
|
||||||
|
@ -17,90 +17,26 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
import java.util.List;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
public class ShowCommand extends SqoopCommand {
|
||||||
|
|
||||||
public class ShowCommand extends SqoopCommand
|
|
||||||
{
|
|
||||||
private ShowServerFunction serverFunction;
|
|
||||||
private ShowVersionFunction versionFunction;
|
|
||||||
private ShowConnectorFunction connectorFunction;
|
|
||||||
private ShowJobFunction jobFunction;
|
|
||||||
private ShowSubmissionFunction submissionFunction;
|
|
||||||
private ShowFrameworkFunction frameworkFunction;
|
|
||||||
private ShowConnectionFunction connectionFunction;
|
|
||||||
private ShowOptionFunction optionFunction;
|
|
||||||
|
|
||||||
|
|
||||||
protected ShowCommand(Shell shell) {
|
protected ShowCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_SHOW, Constants.CMD_SHOW_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_SERVER, Constants.FN_VERSION,
|
Constants.CMD_SHOW,
|
||||||
Constants.FN_CONNECTOR, Constants.FN_FRAMEWORK,
|
Constants.CMD_SHOW_SC,
|
||||||
Constants.FN_CONNECTION, Constants.FN_JOB, Constants.FN_SUBMISSION, Constants.FN_OPTION },
|
new ImmutableMap.Builder<String, Class<? extends SqoopFunction>>()
|
||||||
Constants.PRE_SHOW, Constants.SUF_INFO);
|
.put(Constants.FN_SERVER, ShowServerFunction.class)
|
||||||
}
|
.put(Constants.FN_VERSION, ShowVersionFunction.class)
|
||||||
|
.put(Constants.FN_CONNECTOR, ShowConnectorFunction.class)
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
.put(Constants.FN_FRAMEWORK, ShowFrameworkFunction.class)
|
||||||
@Override
|
.put(Constants.FN_CONNECTION, ShowConnectionFunction.class)
|
||||||
public Object executeCommand(List args) {
|
.put(Constants.FN_JOB, ShowJobFunction.class)
|
||||||
if (args.size() == 0) {
|
.put(Constants.FN_SUBMISSION, ShowSubmissionFunction.class)
|
||||||
printlnResource(Constants.RES_SHOW_USAGE, getUsage());
|
.put(Constants.FN_OPTION, ShowOptionFunction.class)
|
||||||
return null;
|
.build()
|
||||||
}
|
);
|
||||||
|
|
||||||
String func = (String)args.get(0);
|
|
||||||
if (func.equals(Constants.FN_SERVER)) {
|
|
||||||
if (serverFunction == null) {
|
|
||||||
serverFunction = new ShowServerFunction();
|
|
||||||
}
|
|
||||||
return serverFunction.execute(args);
|
|
||||||
|
|
||||||
} else if (func.equals(Constants.FN_VERSION)) {
|
|
||||||
if (versionFunction == null) {
|
|
||||||
versionFunction = new ShowVersionFunction();
|
|
||||||
}
|
|
||||||
return versionFunction.execute(args);
|
|
||||||
|
|
||||||
} else if (func.equals(Constants.FN_CONNECTOR)) {
|
|
||||||
if (connectorFunction == null) {
|
|
||||||
connectorFunction = new ShowConnectorFunction();
|
|
||||||
}
|
|
||||||
return connectorFunction.execute(args);
|
|
||||||
|
|
||||||
} else if (func.equals(Constants.FN_FRAMEWORK)) {
|
|
||||||
if (frameworkFunction == null) {
|
|
||||||
frameworkFunction = new ShowFrameworkFunction();
|
|
||||||
}
|
|
||||||
return frameworkFunction.execute(args);
|
|
||||||
|
|
||||||
} else if (func.equals(Constants.FN_CONNECTION)) {
|
|
||||||
if (connectionFunction == null) {
|
|
||||||
connectionFunction = new ShowConnectionFunction();
|
|
||||||
}
|
|
||||||
return connectionFunction.execute(args);
|
|
||||||
|
|
||||||
} else if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (jobFunction == null) {
|
|
||||||
jobFunction = new ShowJobFunction();
|
|
||||||
}
|
|
||||||
return jobFunction.execute(args);
|
|
||||||
} else if (func.equals(Constants.FN_SUBMISSION)) {
|
|
||||||
if (submissionFunction == null) {
|
|
||||||
submissionFunction = new ShowSubmissionFunction();
|
|
||||||
}
|
|
||||||
return submissionFunction.execute(args);
|
|
||||||
} else if (func.equals(Constants.FN_OPTION)) {
|
|
||||||
if (optionFunction == null) {
|
|
||||||
optionFunction = new ShowOptionFunction();
|
|
||||||
}
|
|
||||||
return optionFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ShowConnectionFunction extends SqoopFunction {
|
public class ShowConnectionFunction extends SqoopFunction {
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected ShowConnectionFunction() {
|
public ShowConnectionFunction() {
|
||||||
this.addOption(OptionBuilder
|
this.addOption(OptionBuilder
|
||||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_CONNS))
|
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_CONNS))
|
||||||
.withLongOpt(Constants.OPT_ALL)
|
.withLongOpt(Constants.OPT_ALL)
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ShowConnectorFunction extends SqoopFunction {
|
public class ShowConnectorFunction extends SqoopFunction {
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected ShowConnectorFunction() {
|
public ShowConnectorFunction() {
|
||||||
this.addOption(OptionBuilder
|
this.addOption(OptionBuilder
|
||||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_CONNECTORS))
|
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_CONNECTORS))
|
||||||
.withLongOpt(Constants.OPT_ALL)
|
.withLongOpt(Constants.OPT_ALL)
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ShowFrameworkFunction extends SqoopFunction {
|
public class ShowFrameworkFunction extends SqoopFunction {
|
||||||
protected ShowFrameworkFunction() {
|
public ShowFrameworkFunction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ShowJobFunction extends SqoopFunction {
|
public class ShowJobFunction extends SqoopFunction {
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected ShowJobFunction() {
|
public ShowJobFunction() {
|
||||||
this.addOption(OptionBuilder
|
this.addOption(OptionBuilder
|
||||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_JOBS))
|
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_JOBS))
|
||||||
.withLongOpt(Constants.OPT_ALL)
|
.withLongOpt(Constants.OPT_ALL)
|
||||||
|
@ -33,7 +33,7 @@ public class ShowOptionFunction extends SqoopFunction {
|
|||||||
* Construct new object.
|
* Construct new object.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected ShowOptionFunction() {
|
public ShowOptionFunction() {
|
||||||
this.addOption(OptionBuilder
|
this.addOption(OptionBuilder
|
||||||
.hasArg().withArgName(Constants.OPT_NAME)
|
.hasArg().withArgName(Constants.OPT_NAME)
|
||||||
.withDescription(resource.getString(Constants.RES_SET_PROMPT_OPT_NAME))
|
.withDescription(resource.getString(Constants.RES_SET_PROMPT_OPT_NAME))
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ShowServerFunction extends SqoopFunction {
|
public class ShowServerFunction extends SqoopFunction {
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected ShowServerFunction() {
|
public ShowServerFunction() {
|
||||||
this.addOption(OptionBuilder
|
this.addOption(OptionBuilder
|
||||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SERVERS))
|
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SERVERS))
|
||||||
.withLongOpt(Constants.OPT_ALL)
|
.withLongOpt(Constants.OPT_ALL)
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ShowSubmissionFunction extends SqoopFunction {
|
public class ShowSubmissionFunction extends SqoopFunction {
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected ShowSubmissionFunction() {
|
public ShowSubmissionFunction() {
|
||||||
this.addOption(OptionBuilder
|
this.addOption(OptionBuilder
|
||||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS))
|
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS))
|
||||||
.withLongOpt(Constants.OPT_DETAIL)
|
.withLongOpt(Constants.OPT_DETAIL)
|
||||||
|
@ -35,7 +35,7 @@ public class ShowVersionFunction extends SqoopFunction {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
protected ShowVersionFunction() {
|
public ShowVersionFunction() {
|
||||||
this.addOption(OptionBuilder
|
this.addOption(OptionBuilder
|
||||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_VERSIONS))
|
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_VERSIONS))
|
||||||
.withLongOpt(Constants.OPT_ALL)
|
.withLongOpt(Constants.OPT_ALL)
|
||||||
|
@ -23,99 +23,75 @@
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.apache.sqoop.common.SqoopException;
|
import org.apache.sqoop.common.SqoopException;
|
||||||
import org.apache.sqoop.shell.core.ShellError;
|
import org.apache.sqoop.shell.core.ShellError;
|
||||||
|
import org.apache.sqoop.utils.ClassUtils;
|
||||||
import org.codehaus.groovy.tools.shell.ComplexCommandSupport;
|
import org.codehaus.groovy.tools.shell.ComplexCommandSupport;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
public abstract class SqoopCommand extends ComplexCommandSupport
|
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
||||||
{
|
|
||||||
private String descriptionPrefix;
|
|
||||||
private String descriptionPostfix;
|
|
||||||
|
|
||||||
private String description;
|
/**
|
||||||
private String usage;
|
* Sqoop shell command.
|
||||||
private String help;
|
*
|
||||||
|
* Every command should define following resource properties:
|
||||||
|
*
|
||||||
|
* $command.description
|
||||||
|
* One sentence describing purpose of the command, displayed on "help" command.
|
||||||
|
*/
|
||||||
|
public abstract class SqoopCommand extends ComplexCommandSupport {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
/**
|
||||||
protected SqoopCommand(Shell shell, String name, String shortcut,
|
* Command name
|
||||||
String[] funcs, String descriptionPrefix, String descriptionPostfix) {
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function map given by concrete implementation.
|
||||||
|
*
|
||||||
|
* Key: Name of the function as is present in the shell
|
||||||
|
* Value: Class name implementing the function
|
||||||
|
*/
|
||||||
|
private final Map<String, Class<? extends SqoopFunction>> functionNames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiated functions for reuse. Built lazily.
|
||||||
|
*/
|
||||||
|
private final Map<String, SqoopFunction> functionInstances;
|
||||||
|
|
||||||
|
protected SqoopCommand(Shell shell,
|
||||||
|
String name,
|
||||||
|
String shortcut,
|
||||||
|
Map<String, Class<? extends SqoopFunction>> funcs) {
|
||||||
super(shell, name, shortcut);
|
super(shell, name, shortcut);
|
||||||
|
|
||||||
this.functions = new LinkedList<String>();
|
this.name = name;
|
||||||
for (String func : funcs) {
|
this.functionNames = funcs;
|
||||||
this.functions.add(func);
|
this.functionInstances = new HashMap<String, SqoopFunction>();
|
||||||
}
|
|
||||||
|
|
||||||
this.descriptionPrefix = descriptionPrefix;
|
this.functions = new LinkedList<String>();
|
||||||
this.descriptionPostfix = descriptionPostfix;
|
this.functions.addAll(funcs.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
if (description == null) {
|
return resourceString(name + ".description");
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
if (descriptionPrefix != null) {
|
|
||||||
sb.append(descriptionPrefix);
|
|
||||||
sb.append(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<String> iterator = functions.iterator();
|
|
||||||
int size = functions.size();
|
|
||||||
sb.append(iterator.next());
|
|
||||||
if (size > 1) {
|
|
||||||
for (int i = 1; i < (size - 1); i++) {
|
|
||||||
sb.append(", ");
|
|
||||||
sb.append(iterator.next());
|
|
||||||
}
|
|
||||||
sb.append(" or ");
|
|
||||||
sb.append(iterator.next());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptionPostfix != null) {
|
|
||||||
sb.append(" ");
|
|
||||||
sb.append(descriptionPostfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
description = sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
if (usage == null) {
|
return new StringBuilder()
|
||||||
StringBuilder sb = new StringBuilder();
|
.append("[")
|
||||||
|
.append(StringUtils.join(functionNames.keySet(), "|"))
|
||||||
sb.append("[");
|
.append("]")
|
||||||
|
.toString();
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<String> iterator = functions.iterator();
|
|
||||||
int size = functions.size();
|
|
||||||
sb.append(iterator.next());
|
|
||||||
for (int i = 1; i < size; i++) {
|
|
||||||
sb.append("|");
|
|
||||||
sb.append(iterator.next());
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append("]");
|
|
||||||
|
|
||||||
usage = sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return usage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
if (help == null) {
|
return getDescription() + ".";
|
||||||
help = getDescription() + ".";
|
|
||||||
}
|
|
||||||
|
|
||||||
return help;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,7 +108,38 @@ public Object execute(List args) {
|
|||||||
* @param args list
|
* @param args list
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
public abstract Object executeCommand(List args);
|
public Object executeCommand(List args) {
|
||||||
|
if (args.size() == 0) {
|
||||||
|
printlnResource(Constants.RES_SHARED_USAGE, name, getUsage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String func = (String)args.get(0);
|
||||||
|
|
||||||
|
// Unknown function
|
||||||
|
if(!functionNames.containsKey(func)) {
|
||||||
|
printlnResource(Constants.RES_SHARED_UNKNOWN_FUNCTION, func);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we already do have the instance, execute it
|
||||||
|
if(functionInstances.containsKey(func)) {
|
||||||
|
return functionInstances.get(func).execute(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise create new instance
|
||||||
|
Class klass = functionNames.get(func);
|
||||||
|
SqoopFunction instance = (SqoopFunction) ClassUtils.instantiate(klass);
|
||||||
|
if(instance == null) {
|
||||||
|
// This is pretty much a developer error as it shouldn't happen without changing and testing code
|
||||||
|
throw new SqoopException(ShellError.SHELL_0000, "Can't instantiate class " + klass);
|
||||||
|
}
|
||||||
|
|
||||||
|
functionInstances.put(func, instance);
|
||||||
|
|
||||||
|
// And return the function execution
|
||||||
|
return instance.execute(args);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
protected void resolveVariables(List arg) {
|
protected void resolveVariables(List arg) {
|
||||||
|
@ -17,41 +17,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
import java.util.List;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.printlnResource;
|
|
||||||
|
|
||||||
public class StartCommand extends SqoopCommand {
|
public class StartCommand extends SqoopCommand {
|
||||||
public static final Logger LOG = Logger.getLogger(StartCommand.class);
|
|
||||||
|
|
||||||
private StartJobFunction startJobFunction;
|
|
||||||
|
|
||||||
protected StartCommand(Shell shell) {
|
protected StartCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_START, Constants.CMD_START_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_JOB}, Constants.PRE_START, null);
|
Constants.CMD_START,
|
||||||
}
|
Constants.CMD_START_SC,
|
||||||
|
new ImmutableMap.Builder<String, Class<? extends SqoopFunction>>()
|
||||||
@Override
|
.put(Constants.FN_JOB, StartJobFunction.class)
|
||||||
public Object executeCommand(List args) {
|
.build()
|
||||||
if (args.size() == 0) {
|
);
|
||||||
printlnResource(Constants.RES_START_USAGE, getUsage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String) args.get(0);
|
|
||||||
if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (startJobFunction == null) {
|
|
||||||
startJobFunction = new StartJobFunction();
|
|
||||||
}
|
|
||||||
return startJobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,39 +17,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
import java.util.List;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.printlnResource;
|
|
||||||
|
|
||||||
public class StatusCommand extends SqoopCommand {
|
public class StatusCommand extends SqoopCommand {
|
||||||
|
|
||||||
private StatusJobFunction statusJobFunction;
|
|
||||||
|
|
||||||
protected StatusCommand(Shell shell) {
|
protected StatusCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_STATUS, Constants.CMD_STATUS_SC,
|
super(shell,
|
||||||
new String[] { Constants.FN_JOB }, Constants.PRE_STATUS, null);
|
Constants.CMD_STATUS,
|
||||||
}
|
Constants.CMD_STATUS_SC,
|
||||||
|
new ImmutableMap.Builder<String, Class<? extends SqoopFunction>>()
|
||||||
@Override
|
.put(Constants.FN_JOB, StatusJobFunction.class)
|
||||||
public Object executeCommand(List args) {
|
.build()
|
||||||
if (args.size() == 0) {
|
);
|
||||||
printlnResource(Constants.RES_STATUS_USAGE, getUsage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String) args.get(0);
|
|
||||||
if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (statusJobFunction == null) {
|
|
||||||
statusJobFunction = new StatusJobFunction();
|
|
||||||
}
|
|
||||||
return statusJobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,37 +17,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
import java.util.List;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.printlnResource;
|
|
||||||
|
|
||||||
public class StopCommand extends SqoopCommand {
|
public class StopCommand extends SqoopCommand {
|
||||||
|
|
||||||
private StopJobFunction stopJobFunction;
|
|
||||||
|
|
||||||
protected StopCommand(Shell shell) {
|
protected StopCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_STOP, Constants.CMD_STOP_SC,
|
super(shell,
|
||||||
new String[] { Constants.FN_JOB }, Constants.PRE_STOP, null);
|
Constants.CMD_STOP,
|
||||||
}
|
Constants.CMD_STOP_SC,
|
||||||
@Override
|
new ImmutableMap.Builder<String, Class<? extends SqoopFunction>>()
|
||||||
public Object executeCommand(List args) {
|
.put(Constants.FN_JOB, StopJobFunction.class)
|
||||||
if (args.size() == 0) {
|
.build()
|
||||||
printlnResource(Constants.RES_STOP_USAGE, getUsage());
|
);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String) args.get(0);
|
|
||||||
if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (stopJobFunction == null) {
|
|
||||||
stopJobFunction = new StopJobFunction();
|
|
||||||
}
|
|
||||||
return stopJobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,47 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.sqoop.shell;
|
package org.apache.sqoop.shell;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
import org.codehaus.groovy.tools.shell.Shell;
|
import org.codehaus.groovy.tools.shell.Shell;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.apache.sqoop.shell.ShellEnvironment.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class UpdateCommand extends SqoopCommand {
|
public class UpdateCommand extends SqoopCommand {
|
||||||
|
|
||||||
private UpdateConnectionFunction connectionFunction;
|
|
||||||
private UpdateJobFunction jobFunction;
|
|
||||||
|
|
||||||
public UpdateCommand(Shell shell) {
|
public UpdateCommand(Shell shell) {
|
||||||
super(shell, Constants.CMD_UPDATE, Constants.CMD_UPDATE_SC,
|
super(shell,
|
||||||
new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
|
Constants.CMD_UPDATE,
|
||||||
Constants.PRE_UPDATE, Constants.SUF_INFO);
|
Constants.CMD_UPDATE_SC,
|
||||||
}
|
ImmutableMap.of(
|
||||||
|
Constants.FN_CONNECTION, UpdateConnectionFunction.class,
|
||||||
public Object executeCommand(List args) {
|
Constants.FN_JOB, UpdateJobFunction.class
|
||||||
if (args.size() == 0) {
|
)
|
||||||
printlnResource(Constants.RES_UPDATE_USAGE, getUsage());
|
);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String func = (String)args.get(0);
|
|
||||||
if (func.equals(Constants.FN_CONNECTION)) {
|
|
||||||
if (connectionFunction == null) {
|
|
||||||
connectionFunction = new UpdateConnectionFunction();
|
|
||||||
}
|
|
||||||
return connectionFunction.execute(args);
|
|
||||||
} else if (func.equals(Constants.FN_JOB)) {
|
|
||||||
if (jobFunction == null) {
|
|
||||||
jobFunction = new UpdateJobFunction();
|
|
||||||
}
|
|
||||||
return jobFunction.execute(args);
|
|
||||||
} else {
|
|
||||||
printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,29 +122,16 @@ public class Constants {
|
|||||||
public static final String FN_VERSION = "version";
|
public static final String FN_VERSION = "version";
|
||||||
public static final String FN_FRAMEWORK = "framework";
|
public static final String FN_FRAMEWORK = "framework";
|
||||||
|
|
||||||
public static final String PRE_CLONE = "Clone";
|
|
||||||
public static final String PRE_CREATE = "Create";
|
|
||||||
public static final String PRE_DELETE = "Delete";
|
|
||||||
public static final String PRE_SET = "Set";
|
|
||||||
public static final String PRE_SHOW = "Show";
|
|
||||||
public static final String PRE_UPDATE = "Update";
|
|
||||||
public static final String PRE_START = "Start";
|
|
||||||
public static final String PRE_STATUS = "Status";
|
|
||||||
public static final String PRE_STOP = "Stop";
|
|
||||||
public static final String PRE_ENABLE = "Enable";
|
|
||||||
public static final String PRE_DISABLE = "Disable";
|
|
||||||
public static final String SUF_INFO = "Info";
|
|
||||||
|
|
||||||
|
|
||||||
public static final String PROP_HOMEDIR = "user.home";
|
public static final String PROP_HOMEDIR = "user.home";
|
||||||
public static final String PROP_CURDIR = "user.dir";
|
public static final String PROP_CURDIR = "user.dir";
|
||||||
public static final String SQOOP_PROMPT = "sqoop";
|
public static final String SQOOP_PROMPT = "sqoop";
|
||||||
|
|
||||||
|
// Shared resources
|
||||||
|
public static final String RES_SHARED_USAGE = "shared.usage";
|
||||||
|
public static final String RES_SHARED_UNKNOWN_FUNCTION = "shared.unknown.function";
|
||||||
|
|
||||||
// Resource Keys for various messages
|
// Resource Keys for various messages
|
||||||
|
|
||||||
public static final String RES_FUNCTION_UNKNOWN =
|
|
||||||
"args.function.unknown";
|
|
||||||
public static final String RES_ARGS_XID_MISSING =
|
public static final String RES_ARGS_XID_MISSING =
|
||||||
"args.xid_missing";
|
"args.xid_missing";
|
||||||
public static final String RES_ARGS_FXID_MISSING =
|
public static final String RES_ARGS_FXID_MISSING =
|
||||||
@ -175,8 +162,6 @@ public class Constants {
|
|||||||
public static final String RES_PROMPT_FILL_JOB_METADATA =
|
public static final String RES_PROMPT_FILL_JOB_METADATA =
|
||||||
"prompt.fill_job_metadata";
|
"prompt.fill_job_metadata";
|
||||||
|
|
||||||
public static final String RES_CLONE_USAGE =
|
|
||||||
"clone.usage";
|
|
||||||
public static final String RES_CLONE_CONN_SUCCESSFUL =
|
public static final String RES_CLONE_CONN_SUCCESSFUL =
|
||||||
"clone.conn.successful";
|
"clone.conn.successful";
|
||||||
public static final String RES_CLONE_JOB_SUCCESSFUL =
|
public static final String RES_CLONE_JOB_SUCCESSFUL =
|
||||||
@ -186,8 +171,6 @@ public class Constants {
|
|||||||
public static final String RES_CLONE_CLONING_JOB =
|
public static final String RES_CLONE_CLONING_JOB =
|
||||||
"clone.cloning_job";
|
"clone.cloning_job";
|
||||||
|
|
||||||
public static final String RES_CREATE_USAGE =
|
|
||||||
"create.usage";
|
|
||||||
public static final String RES_CREATE_CONN_SUCCESSFUL =
|
public static final String RES_CREATE_CONN_SUCCESSFUL =
|
||||||
"create.conn_successful";
|
"create.conn_successful";
|
||||||
public static final String RES_CREATE_JOB_SUCCESSFUL =
|
public static final String RES_CREATE_JOB_SUCCESSFUL =
|
||||||
@ -197,18 +180,11 @@ public class Constants {
|
|||||||
public static final String RES_CREATE_CREATING_JOB =
|
public static final String RES_CREATE_CREATING_JOB =
|
||||||
"create.creating_job";
|
"create.creating_job";
|
||||||
|
|
||||||
public static final String RES_DELETE_USAGE =
|
|
||||||
"delete.usage";
|
|
||||||
|
|
||||||
public static final String RES_DISABLE_USAGE =
|
|
||||||
"disable.usage";
|
|
||||||
public static final String RES_DISABLE_CONNECTION_SUCCESSFUL =
|
public static final String RES_DISABLE_CONNECTION_SUCCESSFUL =
|
||||||
"disable.conn_successful";
|
"disable.conn_successful";
|
||||||
public static final String RES_DISABLE_JOB_SUCCESSFUL =
|
public static final String RES_DISABLE_JOB_SUCCESSFUL =
|
||||||
"disable.job_successful";
|
"disable.job_successful";
|
||||||
|
|
||||||
public static final String RES_ENABLE_USAGE =
|
|
||||||
"enable.usage";
|
|
||||||
public static final String RES_ENABLE_CONNECTION_SUCCESSFUL =
|
public static final String RES_ENABLE_CONNECTION_SUCCESSFUL =
|
||||||
"enable.conn_successful";
|
"enable.conn_successful";
|
||||||
public static final String RES_ENABLE_JOB_SUCCESSFUL =
|
public static final String RES_ENABLE_JOB_SUCCESSFUL =
|
||||||
@ -234,8 +210,6 @@ public class Constants {
|
|||||||
public static final String RES_UNRECOGNIZED_CMD =
|
public static final String RES_UNRECOGNIZED_CMD =
|
||||||
"unrecognized.cmd";
|
"unrecognized.cmd";
|
||||||
|
|
||||||
public static final String RES_SET_USAGE =
|
|
||||||
"set.usage";
|
|
||||||
public static final String RES_SET_PROMPT_OPT_NAME =
|
public static final String RES_SET_PROMPT_OPT_NAME =
|
||||||
"set.prompt_opt_name";
|
"set.prompt_opt_name";
|
||||||
public static final String RES_SET_PROMPT_OPT_VALUE =
|
public static final String RES_SET_PROMPT_OPT_VALUE =
|
||||||
@ -261,14 +235,10 @@ public class Constants {
|
|||||||
public static final String RES_SET_SERVER_IGNORED =
|
public static final String RES_SET_SERVER_IGNORED =
|
||||||
"set.server_ignored";
|
"set.server_ignored";
|
||||||
|
|
||||||
public static final String RES_SHOW_USAGE =
|
|
||||||
"show.usage";
|
|
||||||
public static final String RES_SHOW_PROMPT_DISPLAY_ALL_CONNS =
|
public static final String RES_SHOW_PROMPT_DISPLAY_ALL_CONNS =
|
||||||
"show.prompt_display_all_conns";
|
"show.prompt_display_all_conns";
|
||||||
public static final String RES_SHOW_PROMPT_DISPLAY_CONN_XID =
|
public static final String RES_SHOW_PROMPT_DISPLAY_CONN_XID =
|
||||||
"show.prompt_display_conn_xid";
|
"show.prompt_display_conn_xid";
|
||||||
public static final String RES_SHOW_CONN_USAGE =
|
|
||||||
"show.conn_usage";
|
|
||||||
public static final String RES_SHOW_PROMPT_CONNS_TO_SHOW =
|
public static final String RES_SHOW_PROMPT_CONNS_TO_SHOW =
|
||||||
"show.prompt_conns_to_show";
|
"show.prompt_conns_to_show";
|
||||||
public static final String RES_SHOW_PROMPT_CONN_INFO =
|
public static final String RES_SHOW_PROMPT_CONN_INFO =
|
||||||
@ -280,8 +250,6 @@ public class Constants {
|
|||||||
"show.prompt_display_all_connectors";
|
"show.prompt_display_all_connectors";
|
||||||
public static final String RES_SHOW_PROMPT_DISPLAY_CONNECTOR_CID =
|
public static final String RES_SHOW_PROMPT_DISPLAY_CONNECTOR_CID =
|
||||||
"show.prompt_display_connector_cid";
|
"show.prompt_display_connector_cid";
|
||||||
public static final String RES_SHOW_CONNECTOR_USAGE =
|
|
||||||
"show.connector_usage";
|
|
||||||
public static final String RES_SHOW_PROMPT_CONNECTORS_TO_SHOW =
|
public static final String RES_SHOW_PROMPT_CONNECTORS_TO_SHOW =
|
||||||
"show.prompt_connectors_to_show";
|
"show.prompt_connectors_to_show";
|
||||||
public static final String RES_SHOW_PROMPT_CONNECTOR_INFO =
|
public static final String RES_SHOW_PROMPT_CONNECTOR_INFO =
|
||||||
@ -296,8 +264,6 @@ public class Constants {
|
|||||||
"show.prompt_display_all_jobs";
|
"show.prompt_display_all_jobs";
|
||||||
public static final String RES_SHOW_PROMPT_DISPLAY_JOB_JID =
|
public static final String RES_SHOW_PROMPT_DISPLAY_JOB_JID =
|
||||||
"show.prompt_display_job_jid";
|
"show.prompt_display_job_jid";
|
||||||
public static final String RES_SHOW_JOB_USAGE =
|
|
||||||
"show.job_usage";
|
|
||||||
public static final String RES_SHOW_PROMPT_JOBS_TO_SHOW =
|
public static final String RES_SHOW_PROMPT_JOBS_TO_SHOW =
|
||||||
"show.prompt_jobs_to_show";
|
"show.prompt_jobs_to_show";
|
||||||
public static final String RES_SHOW_PROMPT_JOB_INFO =
|
public static final String RES_SHOW_PROMPT_JOB_INFO =
|
||||||
@ -342,17 +308,9 @@ public class Constants {
|
|||||||
public static final String RES_SHOW_PROMPT_VERSION_PROTOCOL =
|
public static final String RES_SHOW_PROMPT_VERSION_PROTOCOL =
|
||||||
"show.prompt_version_protocol";
|
"show.prompt_version_protocol";
|
||||||
|
|
||||||
public static final String RES_START_USAGE =
|
|
||||||
"start.usage";
|
|
||||||
|
|
||||||
public static final String RES_STATUS_USAGE =
|
|
||||||
"status.usage";
|
|
||||||
public static final String RES_PROMPT_SYNCHRONOUS =
|
public static final String RES_PROMPT_SYNCHRONOUS =
|
||||||
"start.prompt_synchronous";
|
"start.prompt_synchronous";
|
||||||
|
|
||||||
public static final String RES_STOP_USAGE =
|
|
||||||
"stop.usage";
|
|
||||||
|
|
||||||
public static final String RES_SQOOP_SHELL_BANNER =
|
public static final String RES_SQOOP_SHELL_BANNER =
|
||||||
"sqoop.shell_banner";
|
"sqoop.shell_banner";
|
||||||
public static final String RES_SQOOP_PROMPT_SHELL_LOADRC =
|
public static final String RES_SQOOP_PROMPT_SHELL_LOADRC =
|
||||||
@ -360,8 +318,6 @@ public class Constants {
|
|||||||
public static final String RES_SQOOP_PROMPT_SHELL_LOADEDRC =
|
public static final String RES_SQOOP_PROMPT_SHELL_LOADEDRC =
|
||||||
"sqoop.prompt_shell_loadedrc";
|
"sqoop.prompt_shell_loadedrc";
|
||||||
|
|
||||||
public static final String RES_UPDATE_USAGE =
|
|
||||||
"update.usage";
|
|
||||||
public static final String RES_UPDATE_UPDATING_CONN =
|
public static final String RES_UPDATE_UPDATING_CONN =
|
||||||
"update.conn";
|
"update.conn";
|
||||||
public static final String RES_UPDATE_CONN_SUCCESSFUL =
|
public static final String RES_UPDATE_CONN_SUCCESSFUL =
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
############################
|
############################
|
||||||
# Security Form
|
# Security Form
|
||||||
#
|
#############################
|
||||||
object-name.label = Name
|
object-name.label = Name
|
||||||
object-name.help = Non unique name of the entity to help you remember \
|
object-name.help = Non unique name of the entity to help you remember \
|
||||||
it's purpose
|
it's purpose
|
||||||
@ -25,10 +25,13 @@ object-name.help = Non unique name of the entity to help you remember \
|
|||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Messages
|
# Messages
|
||||||
#
|
#############################
|
||||||
|
|
||||||
|
# Shared (for all commands/functions)
|
||||||
|
shared.usage = @|bold Usage:|@ {0} {1}
|
||||||
|
shared.unknown.function = The specified function "{0}" is not recognized.
|
||||||
|
|
||||||
# Argument related
|
# Argument related
|
||||||
#
|
|
||||||
args.function.unknown = The specified function "{0}" is not recognized.
|
|
||||||
args.xid_missing = Required argument --xid is missing.
|
args.xid_missing = Required argument --xid is missing.
|
||||||
args.fxid_missing = Required argument --fxid is missing.
|
args.fxid_missing = Required argument --fxid is missing.
|
||||||
args.txid_missing = Required argument --txid is missing.
|
args.txid_missing = Required argument --txid is missing.
|
||||||
@ -37,7 +40,6 @@ args.cid_missing = Required argument --cid is missing.
|
|||||||
args.name_missing = Required argument --name is missing.
|
args.name_missing = Required argument --name is missing.
|
||||||
args.value_missing = Required argument --value is missing.
|
args.value_missing = Required argument --value is missing.
|
||||||
|
|
||||||
|
|
||||||
## Generic description of various ids, types etc
|
## Generic description of various ids, types etc
|
||||||
prompt.conn_id = Connection ID
|
prompt.conn_id = Connection ID
|
||||||
prompt.connector_id = Connector ID
|
prompt.connector_id = Connector ID
|
||||||
@ -53,17 +55,15 @@ connection object
|
|||||||
prompt.fill_job_metadata = Please fill following values to create new \
|
prompt.fill_job_metadata = Please fill following values to create new \
|
||||||
job object
|
job object
|
||||||
|
|
||||||
#
|
|
||||||
# Update command
|
# Update command
|
||||||
|
update.description = Update objects in Sqoop repository
|
||||||
update.conn = Updating connection with id {0}
|
update.conn = Updating connection with id {0}
|
||||||
update.job = Updating job with id {0}
|
update.job = Updating job with id {0}
|
||||||
update.usage = Usage: update {0}
|
|
||||||
update.conn_successful = Connection was successfully updated with status {0}
|
update.conn_successful = Connection was successfully updated with status {0}
|
||||||
update.job_successful = Job was successfully updated with status {0}
|
update.job_successful = Job was successfully updated with status {0}
|
||||||
|
|
||||||
#
|
|
||||||
# Clone command
|
# Clone command
|
||||||
clone.usage = Usage: clone {0}
|
clone.description = Create new object based on existing one
|
||||||
clone.conn.successful = Connection was successfully created with validation \
|
clone.conn.successful = Connection was successfully created with validation \
|
||||||
status {0} and persistent id {1}
|
status {0} and persistent id {1}
|
||||||
clone.job.successful = Job was successfully created with validation \
|
clone.job.successful = Job was successfully created with validation \
|
||||||
@ -71,34 +71,28 @@ clone.job.successful = Job was successfully created with validation \
|
|||||||
clone.cloning_conn = Cloning connection with id {0}
|
clone.cloning_conn = Cloning connection with id {0}
|
||||||
clone.cloning_job = Cloning job with id {0}
|
clone.cloning_job = Cloning job with id {0}
|
||||||
|
|
||||||
#
|
|
||||||
# Create command
|
# Create command
|
||||||
create.usage = Usage: create {0}
|
create.description = Create new object in Sqoop repository
|
||||||
create.conn_successful = New connection was successfully created with \
|
create.conn_successful = New connection was successfully created with \
|
||||||
validation status {0} and persistent id {1}
|
validation status {0} and persistent id {1}
|
||||||
create.job_successful = New job was successfully created with validation \
|
create.job_successful = New job was successfully created with validation \
|
||||||
status {0} and persistent id {1}
|
status {0} and persistent id {1}
|
||||||
## Creating messages
|
|
||||||
create.creating_conn = Creating connection for connector with id {0}
|
create.creating_conn = Creating connection for connector with id {0}
|
||||||
create.creating_job = Creating job for connections with id {0} and {1}
|
create.creating_job = Creating job for connections with id {0} and {1}
|
||||||
|
|
||||||
#
|
|
||||||
# Delete command
|
# Delete command
|
||||||
delete.usage = Usage: delete {0}
|
delete.description = Delete existing object in Sqoop repository
|
||||||
|
|
||||||
#
|
|
||||||
# Enable command
|
# Enable command
|
||||||
enable.usage = Usage: enable {0}
|
enable.description = Enable object in Sqoop repository
|
||||||
enable.conn_successful = Connection {0} was successfully enabled
|
enable.conn_successful = Connection {0} was successfully enabled
|
||||||
enable.job_successful = Job {0} was successfully enabled
|
enable.job_successful = Job {0} was successfully enabled
|
||||||
|
|
||||||
#
|
|
||||||
# Disable command
|
# Disable command
|
||||||
disable.usage = Usage: disable {0}
|
disable.description = Disable object in Sqoop repository
|
||||||
disable.conn_successful = Connection {0} was successfully disabled
|
disable.conn_successful = Connection {0} was successfully disabled
|
||||||
disable.job_successful = Job {0} was successfully disabled
|
disable.job_successful = Job {0} was successfully disabled
|
||||||
|
|
||||||
#
|
|
||||||
# Help command
|
# Help command
|
||||||
help.usage = [<command>]
|
help.usage = [<command>]
|
||||||
help.description = Display this help message
|
help.description = Display this help message
|
||||||
@ -114,9 +108,8 @@ help.specific_cmd_info = For help on a specific command type: \
|
|||||||
|
|
||||||
unrecognized.cmd = Unrecognized command {0}
|
unrecognized.cmd = Unrecognized command {0}
|
||||||
|
|
||||||
#
|
|
||||||
# Set command
|
# Set command
|
||||||
set.usage = Usage: set {0}
|
set.description = Configure various client options and settings
|
||||||
set.prompt_opt_name = Client option name
|
set.prompt_opt_name = Client option name
|
||||||
set.prompt_opt_value = New option value
|
set.prompt_opt_value = New option value
|
||||||
set.verbose_changed = Verbose option was changed to {0}
|
set.verbose_changed = Verbose option was changed to {0}
|
||||||
@ -131,8 +124,8 @@ set.server_successful = Server is set successfully
|
|||||||
set.server_ignored = --host, --port or --webapp option is ignored, because --url option is given.
|
set.server_ignored = --host, --port or --webapp option is ignored, because --url option is given.
|
||||||
|
|
||||||
|
|
||||||
show.usage = Usage: show {0}
|
# Show command
|
||||||
|
show.description = Display various objects and configuration options
|
||||||
show.prompt_display_all_conns = Display all connections
|
show.prompt_display_all_conns = Display all connections
|
||||||
show.prompt_display_conn_xid = Display the connection with xid
|
show.prompt_display_conn_xid = Display the connection with xid
|
||||||
show.conn_usage = Usage: show connection
|
show.conn_usage = Usage: show connection
|
||||||
@ -182,12 +175,15 @@ sqoop.shell_banner = @|green Sqoop Shell:|@ Type '@|bold help|@' or '@|bold \\h|
|
|||||||
sqoop.prompt_shell_loadrc = Loading resource file {0}
|
sqoop.prompt_shell_loadrc = Loading resource file {0}
|
||||||
sqoop.prompt_shell_loadedrc = Resource file loaded.
|
sqoop.prompt_shell_loadedrc = Resource file loaded.
|
||||||
|
|
||||||
start.usage = Usage: start {0}
|
# Start command
|
||||||
|
start.description = Start job
|
||||||
start.prompt_synchronous = Wait for submission to finish
|
start.prompt_synchronous = Wait for submission to finish
|
||||||
|
|
||||||
stop.usage = Usage: stop {0}
|
# Stop command
|
||||||
|
stop.description = Stop job
|
||||||
|
|
||||||
status.usage = Usage: status {0}
|
# Status command
|
||||||
|
status.description = Display status of a job
|
||||||
|
|
||||||
# Various Table headers
|
# Various Table headers
|
||||||
table.header.id = Id
|
table.header.id = Id
|
||||||
|
Loading…
Reference in New Issue
Block a user