sqoop-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Moiz Arafat <moiz.ara...@teamaol.com>
Subject Issue while running Sqoop export through a Java Program
Date Fri, 12 Jun 2015 10:48:23 GMT
Hi ,

I have a java program to run export command. While executing the export it tries to look for
the export directory in my local machine instead of Hdfs . The same program works fine for
import .

the file exists on hdfs. 

Please help.

Thanks,
Moiz

public void executeSqoopLoad() throws UnsupportedEncodingException{
		SqoopOptions options = new SqoopOptions();

		String driver = "oracle.jdbc.driver.OracleDriver";
		//options.setDriverClassName(driver);
		options.setUsername(“user");
		options.setPassword(“pass");
		options.setConnectString("jdbc:oracle:thin:@host:1522:rptdev");

		Configuration configuration = new Configuration(false);
		Resource configResource;
		try {
			configResource = FileUtils.getFileResource("/Users/Moiz/git/jef/hadoop/hdfs-site.xml");
			configuration.addResource(configResource.getInputStream());
			configResource = FileUtils.getFileResource("/Users/Moiz/git/jef/hadoop/core-site.xml");
			configuration.addResource(configResource.getInputStream());
			FileSystem dfs = FileSystem.get(configuration); 

			String[] uriSplit = dfs.getUri().toString().split(":");
			String newUri = uriSplit[0]+":"+uriSplit[1];
			dfs.setWorkingDirectory(new Path(newUri+"/tmp"));
			System.out.println(dfs.getWorkingDirectory());

			System.out.println("Exists = " + dfs.exists(dfs.getWorkingDirectory()));
			
			DateTime dt =  new DateTime();
			options.setCodeOutputDir("/tmp");
			options.setClassName("SqoopLoad_"+null+dt.getYear()+dt.getMonthOfYear()+dt.getDayOfMonth()+dt.getMillisOfDay());
			options.setVerbose(true);
			// HDFS options
			options.setExportDir(dfs.getWorkingDirectory()+"/TestDirectory");
			
			System.out.println("Exists = " + dfs.exists(new Path(options.getExportDir())));
			options.setInputFieldsTerminatedBy('\u0005');
			options.setTableName(“SCHEMA.TEST_SQP");
			options.setNumMappers(1);
			options.setDirectMode(true);
			System.setProperty(Sqoop.SQOOP_RETHROW_PROPERTY, "rethrow");

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	
		int ret = 100;
		try{
			ret = new ExportTool().run(options);
		}catch (Exception e) {
			System.out.println("Debug");
			e.printStackTrace();
		}
		System.out.println("return code "+ ret);
	}

java.lang.RuntimeException: java.io.FileNotFoundException: File /tmp/TestDirectory/part-m-00000
does not exist
Mime
View raw message