mmiklavc 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_r309001264
##########
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:
Is there a compelling reason to expose this class to inconsistent state
using setters vs using an overloaded constructor or builder pattern? (see Josh
Bloch's builder pattern - more here -
http://www.informit.com/articles/article.aspx?p=1216151&seqNum=2)
----------------------------------------------------------------
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