@Test public void testLocalFileMerge() throws Exception { final String srcPath = "/testMerge"; 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 < 60; i++) { out1.writeByte(1); } out1.close(); out1 = dfs.create(new Path(srcPath + "/" + file2)); for (int i = 0; i < 50; i++) { out1.writeByte(2); } out1.close(); MergeFileAction mergeFileAction = new MergeFileAction(); mergeFileAction.setDfsClient(dfsClient); mergeFileAction.setContext(smartContext); Map<String, String> args = new HashMap<>(); args.put(MergeFileAction.FILE_PATH, srcPath + "/" + file1 + "," + dfs.getUri() + srcPath + "/" + "file2"); args.put(MergeFileAction.DEST_PATH, target); mergeFileAction.init(args); mergeFileAction.run(); Assert.assertTrue(mergeFileAction.getExpectedAfterRun()); Assert.assertTrue(dfsClient.exists(target)); FSDataInputStream in = dfs.open(new Path(target),50); for (int i = 0; i < 60; i++) { Assert.assertTrue(in.readByte() == 1); } for (int i = 0; i < 50; i++) { Assert.assertTrue(in.readByte() == 2); } }
@Override public void init(Map<String, String> args) { super.init(args); String allSrcPath = args.get(FILE_PATH); String[] allSrcPathArr = allSrcPath.split(","); srcPathList = new LinkedList<String>(Arrays.asList(allSrcPathArr)); if (args.containsKey(DEST_PATH)) { this.target = args.get(DEST_PATH); } if (args.containsKey(BUF_SIZE)) { bufferSize = Integer.valueOf(args.get(BUF_SIZE)); } }
MergeFileAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); String allSrcPath = args.get(FILE_PATH); String[] allSrcPathArr = allSrcPath.split(","); srcPathList = new LinkedList<String>(Arrays.asList(allSrcPathArr)); if (args.containsKey(DEST_PATH)) { this.target = args.get(DEST_PATH); } if (args.containsKey(BUF_SIZE)) { bufferSize = Integer.valueOf(args.get(BUF_SIZE)); } } }
MergeFileAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); String allSrcPath = args.get(FILE_PATH); String[] allSrcPathArr = allSrcPath.split(","); srcPathList = new LinkedList<String>(Arrays.asList(allSrcPathArr)); if (args.containsKey(DEST_PATH)) { this.target = args.get(DEST_PATH); } if (args.containsKey(BUF_SIZE)) { bufferSize = Integer.valueOf(args.get(BUF_SIZE)); } }  }
MergeFileAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); String allSrcPath = args.get(FILE_PATH); String[] allSrcPathArr = allSrcPath.split(","); srcPathList = new LinkedList<String>(Arrays.asList(allSrcPathArr)); if (args.containsKey(DEST_PATH)) { this.target = args.get(DEST_PATH); } if (args.containsKey(BUF_SIZE)) { bufferSize = Integer.valueOf(args.get(BUF_SIZE)); } }  @Override void init(Map<String, String> args); }
MergeFileAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); String allSrcPath = args.get(FILE_PATH); String[] allSrcPathArr = allSrcPath.split(","); srcPathList = new LinkedList<String>(Arrays.asList(allSrcPathArr)); if (args.containsKey(DEST_PATH)) { this.target = args.get(DEST_PATH); } if (args.containsKey(BUF_SIZE)) { bufferSize = Integer.valueOf(args.get(BUF_SIZE)); } }  @Override void init(Map<String, String> args); static final String DEST_PATH; static final String BUF_SIZE; }