aplex commented on a change in pull request #3158:
URL: https://github.com/apache/gobblin/pull/3158#discussion_r594767810



##########
File path: 
gobblin-core/src/main/java/org/apache/gobblin/destination/DestinationDatasetHandlerFactory.java
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.destination;
+
+import org.apache.gobblin.configuration.SourceState;
+import org.apache.gobblin.util.ClassAliasResolver;
+import org.apache.gobblin.util.reflection.GobblinConstructorUtils;
+
+
+public class DestinationDatasetHandlerFactory  {
+
+  public static DestinationDatasetHandler newInstance(String handlerTypeName, 
SourceState state) {
+    try {
+      ClassAliasResolver<DestinationDatasetHandler> aliasResolver = new 
ClassAliasResolver<>(DestinationDatasetHandler.class);
+      DestinationDatasetHandler handler = 
GobblinConstructorUtils.invokeLongestConstructor(
+          aliasResolver.resolveClass(handlerTypeName), state);
+      return handler;
+    } catch (ReflectiveOperationException rfe) {
+      throw new RuntimeException("Could not construct TargetDatasetHandler " + 
handlerTypeName, rfe);

Review comment:
       DestinationDatasetHandler? 

##########
File path: 
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveCopyEntityHelper.java
##########
@@ -354,35 +313,24 @@
           this.existingTargetTable = Optional.absent();
         }
 
-        // Constructing CommitStep object for table registration
-        Path targetPath = getTargetLocation(this.dataset.fs, this.targetFs, 
this.dataset.table.getDataLocation(),
-            Optional.<Partition> absent());
+        Path targetPath = getTargetLocation(this.targetFs, 
this.dataset.table.getDataLocation(), Optional.<Partition>absent());
+        if 
(Boolean.parseBoolean(this.dataset.getProperties().getProperty(ConfigurationKeys.USE_DATASET_LOCAL_WORK_DIR,
 "false"))) {

Review comment:
       We have a bunch of utils to work with config/properties/maps - 
ConfigUtils.getBoolean() , State.getPropAsBoolean()
   If none of them work here, you can use  MapUtils.getBooleanValue from Apache 
Commons.

##########
File path: 
gobblin-core/src/main/java/org/apache/gobblin/destination/DestinationDatasetHandlerService.java
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.destination;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.configuration.SourceState;
+import org.apache.gobblin.source.workunit.WorkUnit;
+import org.apache.gobblin.source.workunit.WorkUnitStream;
+
+
+/**
+ * Initializes and runs handlers on workunits before writers are initialized
+ * Reads {@link ConfigurationKeys#DESTINATION_DATASET_HANDLER_CLASS} as a list
+ * of classes, separated by comma to initialize the handlers
+ */
+public class DestinationDatasetHandlerService implements Closeable {
+  List<DestinationDatasetHandler> handlers;
+
+  public DestinationDatasetHandlerService(SourceState jobState) {
+    this.handlers = new ArrayList<>();
+    if 
(jobState.contains(ConfigurationKeys.DESTINATION_DATASET_HANDLER_CLASS)) {
+      String[] handlerList = 
jobState.getProp(ConfigurationKeys.DESTINATION_DATASET_HANDLER_CLASS).split(",");

Review comment:
       I suggest to trim the whitespaces from splitted values . I've seen that 
people like to separate multiple value in configs with a coma and a space 
-"value1, value2, value3".




----------------------------------------------------------------
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]


Reply via email to