Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Sqoop, mail # user - Connection refused while Job Submission - Sqoop Client API


Copy link to this message
-
Re: Connection refused while Job Submission - Sqoop Client API
Manish Meshram 2013-09-24, 07:12
Hi Abraham,

   Can you tell me how to give mapreduce cluster access to database.
   I guess I haven't given it.

Thanks,
   Manish
On Tue, Sep 24, 2013 at 11:54 AM, Abraham Elmahrek <[EMAIL PROTECTED]> wrote:

> Manish,
>
> Have you given your mapreduce cluster access to your database? it will be
> using the credentials in the Connection you created to distribute the
> process of importing into HDFS.
>
> -Abe
>
>
> On Mon, Sep 23, 2013 at 10:52 PM, Manish Meshram <
> [EMAIL PROTECTED]> wrote:
>
>> Hi Abraham,
>>
>> That is another problem,I cannot use the commands you said because when I
>> start client on the same machine(centOS-remote for me) on which server is
>> running, the server automatically stops.
>> But when I started the server on centOS(which is remote for me and I am
>> accessing it through putty)
>> and I have a sqoop Client API java program in my system(windows 7).
>> It does not stops the server and my connection established successfully.
>> Also MySQL server is installed on my system(windows 7) and I have given
>> remote access to ip address of CentOS system,
>> that is why my connection get established in 1st step.
>> I am attaching the source and the output I am getting, please have a look.
>>
>> *Program:*
>> *
>> *
>> public class TestSqoopClient {
>>  private static void printMessage(List<MForm> formList) {
>>   for(MForm form : formList) {
>>     List<MInput<?>> inputlist = form.getInputs();
>>     if (form.getValidationMessage() != null) {
>>       System.out.println("Form message: " + form.getValidationMessage());
>>     }
>>     for (MInput minput : inputlist) {
>>       if (minput.getValidationStatus() == Status.ACCEPTABLE) {
>>         System.out.println("Warning:" + minput.getValidationMessage());
>>       } else if (minput.getValidationStatus() == Status.UNACCEPTABLE) {
>>         System.out.println("Error:" + minput.getValidationMessage());
>>       }
>>     }
>>   }
>> }
>>
>> public static void main(String[] args) {
>>  try
>>  {
>> String url = "http://192.168.3.156:12000/sqoop/";
>>  SqoopClient client = new SqoopClient(url);
>>   /*********Connection**********/
>> //Dummy connection object
>> MConnection newCon = client.newConnection(1);
>>
>> //Get connection and framework forms. Set name for connection
>> MConnectionForms conForms = newCon.getConnectorPart();
>>  MConnectionForms frameworkForms = newCon.getFrameworkPart();
>> newCon.setName("MyConnection");
>>   /*sample for below code
>>  * MStringInput m >> conForms.getStringInput("connection.connectionString");
>>  m.setValue("");*/
>>  //Set connection forms values
>>
>> conForms.getStringInput("connection.connectionString").setValue("jdbc:mysql://
>> 10.10.10.103:3306/mydb");
>>
>> conForms.getStringInput("connection.jdbcDriver").setValue("com.mysql.jdbc.Driver");
>> conForms.getStringInput("connection.username").setValue("********");
>>  conForms.getStringInput("connection.password").setValue("********");
>> //I masked it.
>>
>> frameworkForms.getIntegerInput("security.maxConnections").setValue(0);
>>
>> Status status  = client.createConnection(newCon);
>> if(status.canProceed()) {
>>  System.out.println("Created. New Connection ID : "
>> +newCon.getPersistenceId());
>>  } else {
>>  System.out.println("Check for status and forms error ");
>> }
>>  //for checking the errors/warnings
>> printMessage(newCon.getConnectorPart().getForms());
>>  printMessage(newCon.getFrameworkPart().getForms());
>>   /*********Job**********/
>> //Creating dummy job object
>> MJob newjob = client.newJob(1, org.apache.sqoop.model.MJob.Type.IMPORT);
>>  MJobForms connectorForm = newjob.getConnectorPart();
>> MJobForms frameworkForm = newjob.getFrameworkPart();
>>  newjob.setName("ImportJob");
>> //Database configuration
>>  connectorForm.getStringInput("table.schemaName").setValue("");
>>  //Input either table name or sql
>>  connectorForm.getStringInput("table.tableName").setValue("student");
>> //connectorForm.getStringInput("table.sql").setValue("select id,name from