0
Я пишу программу для управления файлом, то есть перемещаю файл (например, объект) из каталога1 в 2. Я написал фрагмент кода в каскадировании, я думаю, как я могу написать «Труба» для создания потока ,Как создать трубку?
Кто-нибудь может мне помочь?
Спасибо.
// access path to the file input and output and archiving
String inputPath = args[0]; //Directory in HDFS of the Input
String outputPath = args[1]; //Directory in HDFS of the Input
File inFile = new File(inputPath);
File outFile = new File(outputPath);
FileUtils.moveFile(inFile, outFile);
//Set up the configuration Properties
Properties properties = new Properties();
AppProps.setApplicationJarClass(properties, MoveToArchive.class);
FlowConnector flowConnector = new Hadoop2MR1FlowConnector(properties);
//Create Sources and Sinks Taps
Tap inputTap = new Hfs(new TextLine(), inputPath);
Tap outputTap = new Hfs(new TextLine(), outputPath);
Pipe copyPipe = new Pipe("copy");
copyPipe = new Each(copyPipe, SelectFileFunction(inFile));
FlowDef flowDef = FlowDef.flowDef()
.setName("archive")
.addSource("input", inputTap)
.addSource("output", outputTap);
flowConnector.connect(flowDef).complete();
try{
if(outFile.exists()){
System.err.println("file has been moved successfully!");
}
} catch(Exception e){
System.err.println("file not found in Archive Directory");
}