steveloughran commented on a change in pull request #1702: HDFS-14788 Use 
dynamic regex filter to ignore copy of source files in…
URL: https://github.com/apache/hadoop/pull/1702#discussion_r344138955
 
 

 ##########
 File path: 
hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/CopyFilter.java
 ##########
 @@ -47,13 +53,29 @@ public void initialize() {}
    * @return An instance of the appropriate CopyFilter
    */
   public static CopyFilter getCopyFilter(Configuration conf) {
+    String filtersClassName = 
conf.get(DistCpConstants.CONF_LABEL_FILTERS_CLASS);
+
+    if (filtersClassName != null) {
+      try {
+        Class<? extends CopyFilter> filtersClass = 
conf.getClassByName(filtersClassName).asSubclass(CopyFilter.class);
+        filtersClassName = filtersClass.getName();
+        Constructor<? extends CopyFilter> constructor = 
filtersClass.getDeclaredConstructor(Configuration.class);
+        return constructor.newInstance(conf);
+      } catch (Exception e) {
+        LOG.error("Unable to instantiate " + filtersClassName, e);
+      }
+    }
+    return getDefaultCopyFilter(conf);
+  }
+
+  private static CopyFilter getDefaultCopyFilter(Configuration conf) {
     String filtersFilename = conf.get(DistCpConstants.CONF_LABEL_FILTERS_FILE);
 
     if (filtersFilename == null) {
       return new TrueCopyFilter();
     } else {
       String filterFilename = conf.get(
-          DistCpConstants.CONF_LABEL_FILTERS_FILE);
+              DistCpConstants.CONF_LABEL_FILTERS_FILE);
 
 Review comment:
   revert

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to