Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (1)

while running the sqoop command from the java program with -verbose option can result into race condition during obtaining lock on the console appender.we can workaround this with the help of SSHXCUTE framework which will create java program and sqoop command context separately.

ENV: HDP 2.4

Java Version : JDK-8

Step 1: download sshxcute jar from https://sourceforge.net/projects/sshxcute/

Step 2: Create RunSqoopCommand.java

import net.neoremind.sshxcute.core.SSHExec;
import net.neoremind.sshxcute.core.ConnBean;
import net.neoremind.sshxcute.task.CustomTask;
import net.neoremind.sshxcute.task.impl.ExecCommand;


public class RunSqoopCommand {


public static void main(String args[]) throws Exception{




    ConnBean cb = new ConnBean("localhost", "root","hadoop");


    SSHExec ssh = SSHExec.getInstance(cb);          
    ssh.connect();
    CustomTask sqoopCommand = new ExecCommand("sqoop import -Dorg.apache.sqoop.splitter.allow_text_splitter=true  
                                              -Dmapred.job.name=test --connect jdbc:oracle:thin:@10.0.2.12:1521:XE 
                                              --table TEST_INCREMENTAL -m 1 --username system 
                                              --password oracle --target-dir 
                                              /tmp/test26 
                                              --verbose");
    ssh.exec(sqoopCommand);
    ssh.disconnect();   
}
}

Step 3: compile program

javac -cp sshxcute-1.0.jar RunSqoopCommand.java

Step 4: Run program

java -cp sshxcute-1.0.jar RunSqoopCommand

939 Views
Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
1 of 1
Last update:
‎12-20-2016 02:19 PM
Updated by:
 
Contributors
Top Kudoed Authors