nickwallen commented on a change in pull request #1458: METRON-2177 Upgrade Profiler for HBase 2.0.2 URL: https://github.com/apache/metron/pull/1458#discussion_r311194672
########## File path: metron-analytics/metron-profiler-spark/src/main/java/org/apache/metron/profiler/spark/function/HBaseWriterFunction.java ########## @@ -137,35 +150,38 @@ public HBaseWriterFunction(Properties properties) { } /** - * Set the {@link TableProvider} using the class name of the provider. - * @param providerImpl The name of the class. - * @return + * Creates an {@link HBaseConnectionFactory} based on a class name. + * @param factoryImpl The class name of an {@link HBaseConnectionFactory} implementation. */ - public HBaseWriterFunction withTableProviderImpl(String providerImpl) { - this.tableProvider = createTableProvider(providerImpl); - return this; - } - - /** - * Creates a TableProvider based on a class name. - * @param providerImpl The class name of a TableProvider - */ - private static TableProvider createTableProvider(String providerImpl) { - LOG.trace("Creating table provider; className={}", providerImpl); + private static HBaseConnectionFactory createConnectionFactory(String factoryImpl) { + LOG.trace("Creating table provider; className={}", factoryImpl); // if class name not defined, use a reasonable default - if(StringUtils.isEmpty(providerImpl) || providerImpl.charAt(0) == '$') { - return new HTableProvider(); + if(StringUtils.isEmpty(factoryImpl) || factoryImpl.charAt(0) == '$') { + return new HBaseConnectionFactory(); } // instantiate the table provider - try { - Class<? extends TableProvider> clazz = (Class<? extends TableProvider>) Class.forName(providerImpl); - return clazz.getConstructor().newInstance(); + return HBaseConnectionFactory.byName(factoryImpl); + } - } catch (InstantiationException | IllegalAccessException | IllegalStateException | - InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) { - throw new IllegalStateException("Unable to instantiate connector", e); - } + protected HBaseWriterFunction withConnectionFactory(HBaseConnectionFactory connectionFactory) { Review comment: I altered the HBaseWriterFunction to use the Builder Pattern as you suggested. See fcdb697. Let me know if this is what you're looking for. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services