test_class.file: smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/action/TestErasureCodingAction.java
test_class.identifier: TestErasureCodingAction
test_class.superclass: extends TestErasureCodingMiniCluster
test_case.body: @Test
    public void testEcActionForFile() throws Exception {
      String srcPath = "/ec/test_file";
      // Small file is not stored in EC way.
      createTestFile(srcPath, 100000000);
      dfsClient.setStoragePolicy(srcPath, "COLD");
      HdfsFileStatus srcFileStatus = dfsClient.getFileInfo(srcPath);
      // The file is expected to be stored in replication.
      assertEquals(null, srcFileStatus.getErasureCodingPolicy());
  
      ErasureCodingAction ecAction = new ErasureCodingAction();
      ecAction.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);
      args.put(ErasureCodingAction.EC_POLICY_NAME, ecPolicy.getName());
      ecAction.init(args);
      ecAction.run();
      assertTrue(ecAction.getExpectedAfterRun());
      HdfsFileStatus fileStatus = dfsClient.getFileInfo(srcPath);
      // The file is expected to be stored in EC with default policy.
      assertEquals(ecPolicy, fileStatus.getErasureCodingPolicy());
      // Examine the consistency of file attributes.
      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());
      // UNDEF storage policy makes the converted file's storage type uncertain, so it is excluded.
      if (srcFileStatus.getStoragePolicy() != 0) {
        // To make sure the consistency of storage policy
        assertEquals(srcFileStatus.getStoragePolicy(), fileStatus.getStoragePolicy());
      }
    }
test_case.class_method_signature: TestErasureCodingAction.testEcActionForFile()
test_case.full_signature: @Test public void testEcActionForFile()
test_case.identifier: testEcActionForFile
test_case.invocations: createTestFile setStoragePolicy getFileInfo assertEquals getErasureCodingPolicy setContext put put put getName init run assertTrue getExpectedAfterRun getFileInfo assertEquals getErasureCodingPolicy assertEquals getLen getLen assertEquals getModificationTime getModificationTime assertEquals getAccessTime getAccessTime assertEquals getOwner getOwner assertEquals getGroup getGroup assertEquals getPermission getPermission getStoragePolicy assertEquals getStoragePolicy getStoragePolicy
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEcActionForFile()
focal_class.declarator: LOG =
        LoggerFactory.getLogger(ErasureCodingAction.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG =
        LoggerFactory.getLogger(ErasureCodingAction.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: EC_POLICY_NAME = "-policy"
focal_class.modifier: public static final
focal_class.original_string: public static final String EC_POLICY_NAME = "-policy";
focal_class.type: String
focal_class.var_name: EC_POLICY_NAME
focal_class.declarator: conf
focal_class.modifier: private
focal_class.original_string: private SmartConf conf;
focal_class.type: SmartConf
focal_class.var_name: conf
focal_class.declarator: ecPolicyName
focal_class.modifier: private
focal_class.original_string: private String ecPolicyName;
focal_class.type: String
focal_class.var_name: ecPolicyName
focal_class.file: smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/smartdata/hdfs/action/ErasureCodingAction.java
focal_class.identifier: ErasureCodingAction
focal_class.class_method_signature: ErasureCodingAction.init(Map<String, String> args)
focal_class.full_signature: @Override public void init(Map<String, String> args)
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: (Map<String, String> args)
focal_class.return: void
focal_class.signature: void init(Map<String, String> args)
focal_class.class_method_signature: ErasureCodingAction.execute()
focal_class.full_signature: @Override protected void execute()
focal_class.identifier: execute
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void execute()
focal_class.class_method_signature: ErasureCodingAction.validateEcPolicy(String ecPolicyName)
focal_class.full_signature: public void validateEcPolicy(String ecPolicyName)
focal_class.identifier: validateEcPolicy
focal_class.modifiers: public
focal_class.parameters: (String ecPolicyName)
focal_class.return: void
focal_class.signature: void validateEcPolicy(String ecPolicyName)
focal_class.class_method_signature: ErasureCodingAction.getProgress()
focal_class.full_signature: @Override public float getProgress()
focal_class.identifier: getProgress
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: float
focal_class.signature: float getProgress()
focal_class.superclass: extends ErasureCodingBase
focal_method.body: @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 is a temp file kept for converting a file to another with other ec policy.
        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;
    }
focal_method.class_method_signature: ErasureCodingAction.init(Map<String, String> args)
focal_method.full_signature: @Override public void init(Map<String, String> args)
focal_method.identifier: init
focal_method.invocations: init getConf getContext get containsKey get containsKey isEmpty get get getTrimmed containsKey isEmpty get parseToByte get
focal_method.modifiers: @Override public
focal_method.parameters: (Map<String, String> args)
focal_method.return: void
focal_method.signature: void init(Map<String, String> args)