[ https://issues.apache.org/jira/browse/HIVE-10227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14504313#comment-14504313 ]
Sushanth Sowmyan commented on HIVE-10227: ----------------------------------------- Hm, that's definitely food for thought and it does change my mind about how I think it ought to work. a) I do agree now that it should not reset to null, but for a slightly different reason - if there's no hope for success, there's no point in attempting to re-instantiate it every time - it's unlikely that the HiveConf would have changed. So, nulling it out, only to set it again and fail again is pointless. b) I do still think it should absolutely error every time a user attempts to call ReplicationTask.create from then on, since we should not have any case of silent successes here via NoopFactory being instantiated, since this could cause a tool like Falcon to assume that it has successfully processed that eventid, and move its pointer forward, thereby missing the event altogether in the future. However, this might mean that the optimal route here is going to go further in the direction you warn against, but that will only happen in cases where the tool calling ReplicationTask is misbehaving badly. Thoughts? To wit, this is the change I now think appropriate: {code} diff --git a/hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/repl/ReplicationTask.java b/hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/repl/ReplicationTask.ja index e73cc0c..811eeb8 100644 --- a/hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/repl/ReplicationTask.java +++ b/hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/repl/ReplicationTask.java @@ -24,6 +24,7 @@ import org.apache.hive.hcatalog.api.HCatNotificationEvent; import org.apache.hive.hcatalog.common.HCatConstants; import org.apache.hive.hcatalog.messaging.MessageFactory; +import sun.plugin.dom.exception.InvalidStateException; /** @@ -81,6 +82,20 @@ public ReplicationTask create(HCatClient client, HCatNotificationEvent event) { } } + /** + * Dummy factory to indicate that ReplicationTask is in an invalid state, + * possibly due to an incorrect Factory having been configured. To reset + * use, please call resetFactory on a valid ReplicationTask.Factory impl. + */ + public static class InvalidStateFactory implements Factory { + @Override + public ReplicationTask create(HCatClient client, HCatNotificationEvent event) { + throw new InvalidStateException("Error instantiating ReplicationTask.Factory " + + HiveConf.ConfVars.HIVE_REPL_TASK_FACTORY.varname+"="+factoryClassName + + ". Call resetFactory() if you need to reset to a valid one."); + } + } + private static Factory getFactoryInstance(HCatClient client) { if (factoryInstance == null){ createFactoryInstance(client); @@ -112,7 +127,7 @@ private synchronized static void createFactoryInstance(HCatClient client) { Class<? extends Factory> factoryClass = (Class<? extends Factory>) Class.forName(factoryClassName); factoryInstance = factoryClass.newInstance(); } catch (Exception e) { - factoryClassName = null; // reset the classname for future evaluations. + factoryInstance = new InvalidStateFactory(); throw new RuntimeException("Error instantiating ReplicationTask.Factory " + HiveConf.ConfVars.HIVE_REPL_TASK_FACTORY.varname+"="+factoryClassName); } {code} > Concrete implementation of Export/Import based ReplicationTaskFactory > --------------------------------------------------------------------- > > Key: HIVE-10227 > URL: https://issues.apache.org/jira/browse/HIVE-10227 > Project: Hive > Issue Type: Sub-task > Components: Import/Export > Affects Versions: 1.2.0 > Reporter: Sushanth Sowmyan > Assignee: Sushanth Sowmyan > Attachments: HIVE-10227.2.patch, HIVE-10227.3.patch, > HIVE-10227.4.patch, HIVE-10227.patch > > -- This message was sent by Atlassian JIRA (v6.3.4#6332)