Review Board 1.7.22


SQOOP-614: Provide client side ability to clone connection or job object

Review Request #7372 - Created Oct. 1, 2012 and submitted

Jarek Cecho
SQOOP-614
Reviewers
Sqoop
sqoop-sqoop2
I've implemented new client side only command clone that will fetch connection or job object, supply it to user for changes (if needed) and creating new object on server side (thus cloning it).
No new unit tests introduced, just "by hand" testing.
client/src/main/java/org/apache/sqoop/client/shell/CloneCommand.java
New File

    
   
1
/**

    
   
2
 * Licensed to the Apache Software Foundation (ASF) under one

    
   
3
 * or more contributor license agreements.  See the NOTICE file

    
   
4
 * distributed with this work for additional information

    
   
5
 * regarding copyright ownership.  The ASF licenses this file

    
   
6
 * to you under the Apache License, Version 2.0 (the

    
   
7
 * "License"); you may not use this file except in compliance

    
   
8
 * with the License.  You may obtain a copy of the License at

    
   
9
 *

    
   
10
 *     http://www.apache.org/licenses/LICENSE-2.0

    
   
11
 *

    
   
12
 * Unless required by applicable law or agreed to in writing, software

    
   
13
 * distributed under the License is distributed on an "AS IS" BASIS,

    
   
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

    
   
15
 * See the License for the specific language governing permissions and

    
   
16
 * limitations under the License.

    
   
17
 */

    
   
18
package org.apache.sqoop.client.shell;

    
   
19

   

    
   
20
import org.apache.sqoop.client.core.ClientError;

    
   
21
import org.apache.sqoop.common.SqoopException;

    
   
22
import org.codehaus.groovy.tools.shell.Shell;

    
   
23

   

    
   
24
import java.util.List;

    
   
25

   

    
   
26
/**

    
   
27
 * Client side cloning of connection and job objects.

    
   
28
 */

    
   
29
public class CloneCommand extends SqoopCommand {

    
   
30

   

    
   
31
  private CloneConnectionFunction connectionFunction;

    
   
32
  private CloneJobFunction jobFunction;

    
   
33

   

    
   
34
  public CloneCommand(Shell shell) {

    
   
35
    super(shell, "clone", "\\cl",

    
   
36
      new String[] {"connection", "job"},

    
   
37
      "Clone", "Info");

    
   
38
  }

    
   
39

   

    
   
40
  public Object execute(List args) {

    
   
41
    if (args.size() == 0) {

    
   
42
      io.out.println("Usage: clone " + getUsage());

    
   
43
      io.out.println();

    
   
44
      return null;

    
   
45
    }

    
   
46

   

    
   
47
    String func = (String)args.get(0);

    
   
48
    if (func.equals("connection")) {

    
   
49
      if (connectionFunction == null) {

    
   
50
        connectionFunction = new CloneConnectionFunction(io);

    
   
51
      }

    
   
52
      return connectionFunction.execute(args);

    
   
53
    } else if (func.equals("job")) {

    
   
54
      if (jobFunction == null) {

    
   
55
        jobFunction = new CloneJobFunction(io);

    
   
56
      }

    
   
57
      return jobFunction.execute(args);

    
   
58
    } else {

    
   
59
      String msg = "Usage: clone " + getUsage();

    
   
60
      throw new SqoopException(ClientError.CLIENT_0002, msg);

    
   
61
    }

    
   
62
  }

    
   
63
}
client/src/main/java/org/apache/sqoop/client/shell/CloneConnectionFunction.java
New File
 
client/src/main/java/org/apache/sqoop/client/shell/CloneJobFunction.java
New File
 
client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
Revision 91682d1 New Change
 
client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
Revision 58749e9 New Change
 
  1. client/src/main/java/org/apache/sqoop/client/shell/CloneCommand.java: Loading...
  2. client/src/main/java/org/apache/sqoop/client/shell/CloneConnectionFunction.java: Loading...
  3. client/src/main/java/org/apache/sqoop/client/shell/CloneJobFunction.java: Loading...
  4. client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java: Loading...
  5. client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java: Loading...