java - How to get Sqoop Server Running URL and Port in Horton Sandbox -
i using sqoop client. , don't know url have initialize sqoopclient object. running horton sandbox preconfigured everything. dont know having sqoop server running or not. , if running dnt know port. , if not running how can run in sandbox.
i reading tutorial given @ page: http://devslogics.blogspot.in/2013/09/sqoop-java-client.html
this 2 lines focus initialize url.
string url = "http://192.168.56.102:12000/sqoop/"; sqoopclient client = new sqoopclient(url); here finish code -
//here using table persons, columns personid , lastname import org.apache.sqoop.client.sqoopclient; import org.apache.sqoop.model.mconnection; import org.apache.sqoop.model.mconnectionforms; import org.apache.sqoop.model.mjob; import org.apache.sqoop.model.mjobforms; import org.apache.sqoop.model.msubmission; import org.apache.sqoop.validation.status; /** * @author devan * @date 19-sep-2013 * @mail msdevanms@gmail.com */ public class sqoopimport { public static void main(string[] args) { string connectionstring = "jdbc:mysql://localhost:3316/dw_db"; string username = "openmrs"; string password = "epm2zekzozrl"; string schemaname = "dw_db"; string tablename = "dw_table"; string columns = "locale,name"; //comma seperated column names string partitioncolumn = "locale"; string outputdirectory = "/output/persons"; string url = "http://192.168.56.102:12000/sqoop/"; sqoopclient client = new sqoopclient(url); //client.setserverurl(newurl); //dummy connection object mconnection newcon = client.newconnection(1); //get connection , framework forms. set name connection mconnectionforms conforms = newcon.getconnectorpart(); mconnectionforms frameworkforms = newcon.getframeworkpart(); newcon.setname("myconnection"); //set connection forms values conforms.getstringinput("connection.connectionstring").setvalue(connectionstring); conforms.getstringinput("connection.jdbcdriver").setvalue("com.mysql.jdbc.driver"); conforms.getstringinput("connection.username").setvalue(username); conforms.getstringinput("connection.password").setvalue(password); 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 status , forms error "); } //creating dummy job object mjob newjob = client.newjob(newcon.getpersistenceid(), 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(schemaname); //input either table name or sql connectorform.getstringinput("table.tablename").setvalue(tablename); //connectorform.getstringinput("table.sql").setvalue("select id,name table ${conditions}"); connectorform.getstringinput("table.columns").setvalue(columns); connectorform.getstringinput("table.partitioncolumn").setvalue(partitioncolumn); //set boundary value if required //connectorform.getstringinput("table.boundaryquery").setvalue(""); //output configurations frameworkform.getenuminput("output.storagetype").setvalue("hdfs"); frameworkform.getenuminput("output.outputformat").setvalue("text_file");//other option: sequence_file / text_file frameworkform.getstringinput("output.outputdirectory").setvalue(outputdirectory); //job resources frameworkform.getintegerinput("throttling.extractors").setvalue(1); frameworkform.getintegerinput("throttling.loaders").setvalue(1); status = client.createjob(newjob); if(status.canproceed()) { system.out.println("new job id: "+ newjob.getpersistenceid()); } else { system.out.println("check status , forms error "); } //now submit job msubmission submission = client.startsubmission(newjob.getpersistenceid()); system.out.println("status : " + submission.getstatus()); } }
for checking list of services running on linux machine,please seek next one:
netstat -tulpn
this list services.
to particular service or port,you can grep port name command.
for example:netstat -tulpn | grep 8080
to list running services
netstat -tulpn | grep listen
hope,this helpful
java mapreduce sqoop hortonworks-data-platform sqoop2
No comments:
Post a Comment