@Test public void testEcActionForDir() throws Exception { String srcDirPath = "/test_dir/"; dfs.mkdirs(new Path(srcDirPath)); assertEquals(null, dfsClient.getErasureCodingPolicy(srcDirPath)); ErasureCodingAction ecAction = new ErasureCodingAction(); ecAction.setContext(smartContext); Map<String, String> args = new HashMap<>(); args.put(HdfsAction.FILE_PATH, srcDirPath); args.put(ErasureCodingAction.EC_POLICY_NAME, ecPolicy.getName()); ecAction.init(args); ecAction.run(); assertTrue(ecAction.getExpectedAfterRun()); assertEquals(dfsClient.getErasureCodingPolicy(srcDirPath), ecPolicy); String srcFilePath = "/test_dir/test_file"; createTestFile(srcFilePath, 1000); assertEquals(dfsClient.getErasureCodingPolicy(srcFilePath), ecPolicy); }
@Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(EC_POLICY_NAME) && !args.get(EC_POLICY_NAME).isEmpty()) { this.ecPolicyName = args.get(EC_POLICY_NAME); } else { String defaultEcPolicy = conf.getTrimmed(DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY, DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY_DEFAULT); this.ecPolicyName = defaultEcPolicy; } if (args.containsKey(BUF_SIZE) && !args.get(BUF_SIZE).isEmpty()) { this.bufferSize = (int) StringUtil.parseToByte(args.get(BUF_SIZE)); } this.progress = 0.0F; }
ErasureCodingAction extends ErasureCodingBase { @Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(EC_POLICY_NAME) && !args.get(EC_POLICY_NAME).isEmpty()) { this.ecPolicyName = args.get(EC_POLICY_NAME); } else { String defaultEcPolicy = conf.getTrimmed(DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY, DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY_DEFAULT); this.ecPolicyName = defaultEcPolicy; } if (args.containsKey(BUF_SIZE) && !args.get(BUF_SIZE).isEmpty()) { this.bufferSize = (int) StringUtil.parseToByte(args.get(BUF_SIZE)); } this.progress = 0.0F; } }
ErasureCodingAction extends ErasureCodingBase { @Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(EC_POLICY_NAME) && !args.get(EC_POLICY_NAME).isEmpty()) { this.ecPolicyName = args.get(EC_POLICY_NAME); } else { String defaultEcPolicy = conf.getTrimmed(DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY, DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY_DEFAULT); this.ecPolicyName = defaultEcPolicy; } if (args.containsKey(BUF_SIZE) && !args.get(BUF_SIZE).isEmpty()) { this.bufferSize = (int) StringUtil.parseToByte(args.get(BUF_SIZE)); } this.progress = 0.0F; }  }
ErasureCodingAction extends ErasureCodingBase { @Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(EC_POLICY_NAME) && !args.get(EC_POLICY_NAME).isEmpty()) { this.ecPolicyName = args.get(EC_POLICY_NAME); } else { String defaultEcPolicy = conf.getTrimmed(DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY, DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY_DEFAULT); this.ecPolicyName = defaultEcPolicy; } 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); void validateEcPolicy(String ecPolicyName); @Override float getProgress(); }
ErasureCodingAction extends ErasureCodingBase { @Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(EC_POLICY_NAME) && !args.get(EC_POLICY_NAME).isEmpty()) { this.ecPolicyName = args.get(EC_POLICY_NAME); } else { String defaultEcPolicy = conf.getTrimmed(DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY, DFSConfigKeys.DFS_NAMENODE_EC_SYSTEM_DEFAULT_POLICY_DEFAULT); this.ecPolicyName = defaultEcPolicy; } 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); void validateEcPolicy(String ecPolicyName); @Override float getProgress(); static final String EC_POLICY_NAME; }