package com.savy3.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.sql.Timestamp;

import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.mapred.JobConf;
import org.apache.sqoop.mapreduce.mainframe.MainframeConfiguration;

//import org.apache.sqoop.util.MainframeFTPClientUtils;

public class FTPtoHDFS

{
	private static FTPClient ftp = null;

	public static void main(String[] args) throws IOException,
			URISyntaxException {
		JobConf job = new JobConf(FTPtoHDFS.class);

		job.set("mapreduce.mainframe.input.dataset.name", args[0]);
		DBConfiguration.configureDB(job, "manu", "ftp address",
				"uid", "pwd");
		ftp = MainframeFTPClientUtils.getFTPConnection(job);
		ftp.setFileType(FTP.BINARY_FILE_TYPE);
		ftp.featureValue("LITERAL SITE RDW");
		ftp.doCommand("SITE", "RDW");
		System.out.println("reply for LITERAL" + ftp.getReplyString());
		String dsName = "'"
				+ job.get(MainframeConfiguration.MAINFRAME_INPUT_DATASET_NAME)
				+ "'";
		ftp.changeWorkingDirectory(dsName);
		InputStream inputStream = ftp.retrieveFileStream(dsName);

		FileSystem fileSystem = FileSystem.get(job);
		java.util.Date date = new java.util.Date();
		OutputStream outputStream = fileSystem.create(new Path(args[1]));
		System.out.println("FTP Start Time : "
				+ (new Timestamp(date.getTime())));
		IOUtils.copyBytes(inputStream, outputStream, job, true);
		date = new java.util.Date();
		System.out.println("FTP End Time : " + (new Timestamp(date.getTime())));

	}

}

@@ -724,16 +724,148 @@
 class);%0A
+%09%09job.set(%22mapreduce.jdbc.url%22,args%5B0%5D);%0A%09%09job.set(%22mapreduce.jdbc.username%22,args%5B1%5D);%0A%09%09job.set(%22mapreduce.jdbc.password%22,args%5B2%5D);
 %0A%09%09job.s
@@ -914,21 +914,24 @@
 %22, args%5B
-0
+3
 %5D);%0A
+%09%09%0A
 %09%09DBConf
@@ -969,39 +969,137 @@
 u%22, 
-%22ftp address%22,%0A%09%09%09%09%22uid%22, %22pwd%22
+job.get(DBConfiguration.URL_PROPERTY),%0A%09%09%09%09job.get(DBConfiguration.USERNAME_PROPERTY), job.get(DBConfiguration.PASSWORD_PROPERTY)
 );%0A%09
@@ -1685,17 +1685,17 @@
 th(args%5B
-1
+4
 %5D));%0A%09%09S

Update FTPtoHDFS.java