@Test public void testUnEcActionForFile() throws Exception { String testDir = "/test_dir"; dfs.mkdirs(new Path(testDir)); dfs.setErasureCodingPolicy(new Path(testDir), ecPolicy.getName()); String srcPath = testDir + "/ec_file"; createTestFile(srcPath, 1000); dfsClient.setStoragePolicy(srcPath, "COLD"); HdfsFileStatus srcFileStatus = dfsClient.getFileInfo(srcPath); assertEquals(dfsClient.getErasureCodingPolicy(srcPath), ecPolicy); UnErasureCodingAction unEcAction = new UnErasureCodingAction(); unEcAction.setContext(smartContext); String ecTmpPath = "/ssm/ec_tmp/tmp_file"; Map<String, String> args = new HashMap<>(); args.put(HdfsAction.FILE_PATH, srcPath); args.put(ErasureCodingBase.EC_TMP, ecTmpPath); unEcAction.init(args); unEcAction.run(); assertTrue(unEcAction.getExpectedAfterRun()); HdfsFileStatus fileStatus = dfsClient.getFileInfo(srcPath); assertNull(fileStatus.getErasureCodingPolicy()); assertEquals(srcFileStatus.getLen(), fileStatus.getLen()); assertEquals(srcFileStatus.getModificationTime(), fileStatus.getModificationTime()); assertEquals(srcFileStatus.getAccessTime(), fileStatus.getAccessTime()); assertEquals(srcFileStatus.getOwner(), fileStatus.getOwner()); assertEquals(srcFileStatus.getGroup(), fileStatus.getGroup()); assertEquals(srcFileStatus.getPermission(), fileStatus.getPermission()); if (srcFileStatus.getStoragePolicy() != 0) { assertEquals(srcFileStatus.getStoragePolicy(), fileStatus.getStoragePolicy()); } }
@Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); this.ecPolicyName = REPLICATION_POLICY_NAME; if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(BUF_SIZE) && !args.get(BUF_SIZE).isEmpty()) { this.bufferSize = (int) StringUtil.parseToByte(args.get(BUF_SIZE)); } this.progress = 0.0F; }
UnErasureCodingAction extends ErasureCodingBase { @Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); this.ecPolicyName = REPLICATION_POLICY_NAME; if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(BUF_SIZE) && !args.get(BUF_SIZE).isEmpty()) { this.bufferSize = (int) StringUtil.parseToByte(args.get(BUF_SIZE)); } this.progress = 0.0F; } }
UnErasureCodingAction extends ErasureCodingBase { @Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); this.ecPolicyName = REPLICATION_POLICY_NAME; if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(BUF_SIZE) && !args.get(BUF_SIZE).isEmpty()) { this.bufferSize = (int) StringUtil.parseToByte(args.get(BUF_SIZE)); } this.progress = 0.0F; }  }
UnErasureCodingAction extends ErasureCodingBase { @Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); this.ecPolicyName = REPLICATION_POLICY_NAME; if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(BUF_SIZE) && !args.get(BUF_SIZE).isEmpty()) { this.bufferSize = (int) StringUtil.parseToByte(args.get(BUF_SIZE)); } this.progress = 0.0F; }  @Override void init(Map<String, String> args); @Override float getProgress(); }
UnErasureCodingAction extends ErasureCodingBase { @Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); this.ecPolicyName = REPLICATION_POLICY_NAME; if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(BUF_SIZE) && !args.get(BUF_SIZE).isEmpty()) { this.bufferSize = (int) StringUtil.parseToByte(args.get(BUF_SIZE)); } this.progress = 0.0F; }  @Override void init(Map<String, String> args); @Override float getProgress();  }