@Test public void testLocalFileConcat() throws IOException { final String srcPath = "/testConcat"; final String file1 = "file1"; final String file2 = "file2"; final String target = "/target"; dfs.mkdirs(new Path(srcPath)); dfs.mkdirs(new Path(target)); FSDataOutputStream out1 = dfs.create(new Path(srcPath + "/" + file1)); for (int i = 0; i < DEFAULT_BLOCK_SIZE; i++) { out1.writeByte(1); } out1.close(); out1 = dfs.create(new Path(srcPath + "/" + file2)); for (int i = 0; i < DEFAULT_BLOCK_SIZE; i++) { out1.writeByte(2); } out1.close(); ConcatFileAction concatFileAction = new ConcatFileAction(); concatFileAction.setDfsClient(dfsClient); concatFileAction.setContext(smartContext); Map<String, String> args = new HashMap<>(); args.put(CopyFileAction.FILE_PATH, srcPath + "/" + file1 + "," + srcPath + "/" + "file2"); args.put(ConcatFileAction.DEST_PATH, target); concatFileAction.init(args); concatFileAction.run(); Assert.assertTrue(concatFileAction.getExpectedAfterRun()); Assert.assertTrue(dfsClient.exists(target)); FSDataInputStream in = dfs.open(new Path(target),50); for (int i = 0; i < DEFAULT_BLOCK_SIZE; i++) { Assert.assertTrue(in.readByte() == 1); } for (int i = 0; i < DEFAULT_BLOCK_SIZE; i++) { Assert.assertTrue(in.readByte() == 2); } }
@Override public void init(Map<String, String> args) { super.init(args); String inputSrcPath = args.get(FILE_PATH); String[] srcArray = inputSrcPath.split(","); srcPathList = new LinkedList<>(Arrays.asList(srcArray)); if (args.containsKey(DEST_PATH)) { this.targetPath = args.get(DEST_PATH); } }
ConcatFileAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); String inputSrcPath = args.get(FILE_PATH); String[] srcArray = inputSrcPath.split(","); srcPathList = new LinkedList<>(Arrays.asList(srcArray)); if (args.containsKey(DEST_PATH)) { this.targetPath = args.get(DEST_PATH); } } }
ConcatFileAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); String inputSrcPath = args.get(FILE_PATH); String[] srcArray = inputSrcPath.split(","); srcPathList = new LinkedList<>(Arrays.asList(srcArray)); if (args.containsKey(DEST_PATH)) { this.targetPath = args.get(DEST_PATH); } }  }
ConcatFileAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); String inputSrcPath = args.get(FILE_PATH); String[] srcArray = inputSrcPath.split(","); srcPathList = new LinkedList<>(Arrays.asList(srcArray)); if (args.containsKey(DEST_PATH)) { this.targetPath = args.get(DEST_PATH); } }  @Override void init(Map<String, String> args); }
ConcatFileAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); String inputSrcPath = args.get(FILE_PATH); String[] srcArray = inputSrcPath.split(","); srcPathList = new LinkedList<>(Arrays.asList(srcArray)); if (args.containsKey(DEST_PATH)) { this.targetPath = args.get(DEST_PATH); } }  @Override void init(Map<String, String> args); static final String DEST_PATH; }