Github user joshelser commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/236#discussion_r120394548
--- Diff:
phoenix-queryserver/src/main/java/org/apache/phoenix/queryserver/server/QueryServer.java
---
@@ -233,16 +240,29 @@ public int run(String[] args) throws Exception {
// Build and start the HttpServer
server = builder.build();
server.start();
+ registerToServiceProvider(hostname);
runningLatch.countDown();
server.join();
return 0;
} catch (Throwable t) {
LOG.fatal("Unrecoverable service error. Shutting down.", t);
this.t = t;
return -1;
+ } finally {
+ deRegister();
}
}
+ private void registerToServiceProvider(String hostName) throws Exception
{
+ PqsZookeeperConf pqsZookeeperConf = new
PqsZookeeperConfImpl(getConf());
--- End diff --
Oh, I see now. You're instantiating these implementations directly.
I think you should use Java's ServiceLoader to properly separate properly
separate interface from implementation across the queryserver and loadbalancer
modules. Here in queryserver, you would just refer to PqsZookeeperConf and
Registry (but the concrete implementations would be wired up by ServiceLoader
as defined by the META-INF/services/... files you create).
If you're not familiar:
https://docs.oracle.com/javase/tutorial/ext/basics/spi.html. Should be pretty
straightforward. e.g. this is also how the PhoenixDriver class is loaded for
JDBC (so there's example of what to do in phoenix-core).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---