Skip to content

Commit

Permalink
PHOENIX-2996 Process name of PQS should indicate its role (Ted Yu)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshelser committed Oct 24, 2016
1 parent 6cf827a commit a5bcb3e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bin/queryserver.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
" -Dpsql.log.dir=%(log_dir)s" + \ " -Dpsql.log.dir=%(log_dir)s" + \
" -Dpsql.log.file=%(log_file)s" + \ " -Dpsql.log.file=%(log_file)s" + \
" " + opts + \ " " + opts + \
" org.apache.phoenix.queryserver.server.Main " + args " org.apache.phoenix.queryserver.server.QueryServer " + args


if command == 'makeWinServiceDesc': if command == 'makeWinServiceDesc':
cmd = java_cmd % {'java': java, 'root_logger': 'INFO,DRFA,console', 'log_dir': log_dir, 'log_file': phoenix_log_file} cmd = java_cmd % {'java': java, 'root_logger': 'INFO,DRFA,console', 'log_dir': log_dir, 'log_file': phoenix_log_file}
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public static void beforeClass() throws Exception {
AVATICA_SERVER = new QueryServerThread(new String[] { url }, CONF, AVATICA_SERVER = new QueryServerThread(new String[] { url }, CONF,
QueryServerBasicsIT.class.getName()); QueryServerBasicsIT.class.getName());
AVATICA_SERVER.start(); AVATICA_SERVER.start();
AVATICA_SERVER.getMain().awaitRunning(); AVATICA_SERVER.getQueryServer().awaitRunning();
final int port = AVATICA_SERVER.getMain().getPort(); final int port = AVATICA_SERVER.getQueryServer().getPort();
LOG.info("Avatica server started on port " + port); LOG.info("Avatica server started on port " + port);
CONN_STRING = ThinClientUtil.getConnectionUrl("localhost", port); CONN_STRING = ThinClientUtil.getConnectionUrl("localhost", port);
LOG.info("JDBC connection string is " + CONN_STRING); LOG.info("JDBC connection string is " + CONN_STRING);
Expand All @@ -77,11 +77,12 @@ public static void beforeClass() throws Exception {
public static void afterClass() throws Exception { public static void afterClass() throws Exception {
if (AVATICA_SERVER != null) { if (AVATICA_SERVER != null) {
AVATICA_SERVER.join(TimeUnit.MINUTES.toMillis(1)); AVATICA_SERVER.join(TimeUnit.MINUTES.toMillis(1));
Throwable t = AVATICA_SERVER.getMain().getThrowable(); Throwable t = AVATICA_SERVER.getQueryServer().getThrowable();
if (t != null) { if (t != null) {
fail("query server threw. " + t.getMessage()); fail("query server threw. " + t.getMessage());
} }
assertEquals("query server didn't exit cleanly", 0, AVATICA_SERVER.getMain().getRetCode()); assertEquals("query server didn't exit cleanly", 0, AVATICA_SERVER.getQueryServer()
.getRetCode());
} }
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
package org.apache.phoenix.end2end; package org.apache.phoenix.end2end;


import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.phoenix.queryserver.server.Main; import org.apache.phoenix.queryserver.server.QueryServer;


/** Wraps up the query server for tests. */ /** Wraps up the query server for tests. */
public class QueryServerThread extends Thread { public class QueryServerThread extends Thread {


private final Main main; private final QueryServer main;


public QueryServerThread(String[] argv, Configuration conf) { public QueryServerThread(String[] argv, Configuration conf) {
this(argv, conf, null); this(argv, conf, null);
} }


public QueryServerThread(String[] argv, Configuration conf, String name) { public QueryServerThread(String[] argv, Configuration conf, String name) {
this(new Main(argv, conf), name); this(new QueryServer(argv, conf), name);
} }


private QueryServerThread(Main m, String name) { private QueryServerThread(QueryServer m, String name) {
super(m, "query server" + (name == null ? "" : (" - " + name))); super(m, "query server" + (name == null ? "" : (" - " + name)));
this.main = m; this.main = m;
setDaemon(true); setDaemon(true);
} }


public Main getMain() { public QueryServer getQueryServer() {
return main; return main;
} }
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
/** /**
* A query server for Phoenix over Calcite's Avatica. * A query server for Phoenix over Calcite's Avatica.
*/ */
public final class Main extends Configured implements Tool, Runnable { public final class QueryServer extends Configured implements Tool, Runnable {


protected static final Log LOG = LogFactory.getLog(Main.class); protected static final Log LOG = LogFactory.getLog(QueryServer.class);


private final String[] argv; private final String[] argv;
private final CountDownLatch runningLatch = new CountDownLatch(1); private final CountDownLatch runningLatch = new CountDownLatch(1);
Expand Down Expand Up @@ -94,9 +94,11 @@ public static void logJVMInfo() {
public static void logProcessInfo(Configuration conf) { public static void logProcessInfo(Configuration conf) {
// log environment variables unless asked not to // log environment variables unless asked not to
if (conf == null || !conf.getBoolean(QueryServices.QUERY_SERVER_ENV_LOGGING_ATTRIB, false)) { if (conf == null || !conf.getBoolean(QueryServices.QUERY_SERVER_ENV_LOGGING_ATTRIB, false)) {
Set<String> skipWords = new HashSet<String>(QueryServicesOptions.DEFAULT_QUERY_SERVER_SKIP_WORDS); Set<String> skipWords = new HashSet<String>(
QueryServicesOptions.DEFAULT_QUERY_SERVER_SKIP_WORDS);
if (conf != null) { if (conf != null) {
String[] confSkipWords = conf.getStrings(QueryServices.QUERY_SERVER_ENV_LOGGING_SKIPWORDS_ATTRIB); String[] confSkipWords = conf.getStrings(
QueryServices.QUERY_SERVER_ENV_LOGGING_SKIPWORDS_ATTRIB);
if (confSkipWords != null) { if (confSkipWords != null) {
skipWords.addAll(Arrays.asList(confSkipWords)); skipWords.addAll(Arrays.asList(confSkipWords));
} }
Expand All @@ -119,12 +121,12 @@ public static void logProcessInfo(Configuration conf) {
} }


/** Constructor for use from {@link org.apache.hadoop.util.ToolRunner}. */ /** Constructor for use from {@link org.apache.hadoop.util.ToolRunner}. */
public Main() { public QueryServer() {
this(null, null); this(null, null);
} }


/** Constructor for use as {@link java.lang.Runnable}. */ /** Constructor for use as {@link java.lang.Runnable}. */
public Main(String[] argv, Configuration conf) { public QueryServer(String[] argv, Configuration conf) {
this.argv = argv; this.argv = argv;
setConf(conf); setConf(conf);
} }
Expand Down Expand Up @@ -168,24 +170,28 @@ public void awaitRunning(long timeout, TimeUnit unit) throws InterruptedExceptio
public int run(String[] args) throws Exception { public int run(String[] args) throws Exception {
logProcessInfo(getConf()); logProcessInfo(getConf());
try { try {
final boolean isKerberos = "kerberos".equalsIgnoreCase(getConf().get(QueryServices.QUERY_SERVER_HBASE_SECURITY_CONF_ATTRIB)); final boolean isKerberos = "kerberos".equalsIgnoreCase(getConf().get(
QueryServices.QUERY_SERVER_HBASE_SECURITY_CONF_ATTRIB));


// handle secure cluster credentials // handle secure cluster credentials
if (isKerberos) { if (isKerberos) {
String hostname = Strings.domainNamePointerToHostName(DNS.getDefaultHost( String hostname = Strings.domainNamePointerToHostName(DNS.getDefaultHost(
getConf().get(QueryServices.QUERY_SERVER_DNS_INTERFACE_ATTRIB, "default"), getConf().get(QueryServices.QUERY_SERVER_DNS_INTERFACE_ATTRIB, "default"),
getConf().get(QueryServices.QUERY_SERVER_DNS_NAMESERVER_ATTRIB, "default"))); getConf().get(QueryServices.QUERY_SERVER_DNS_NAMESERVER_ATTRIB, "default")));
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Login to " + hostname + " using " + getConf().get(QueryServices.QUERY_SERVER_KEYTAB_FILENAME_ATTRIB) LOG.debug("Login to " + hostname + " using " + getConf().get(
+ " and principal " + getConf().get(QueryServices.QUERY_SERVER_KERBEROS_PRINCIPAL_ATTRIB) + "."); QueryServices.QUERY_SERVER_KEYTAB_FILENAME_ATTRIB)
+ " and principal " + getConf().get(
QueryServices.QUERY_SERVER_KERBEROS_PRINCIPAL_ATTRIB) + ".");
} }
SecurityUtil.login(getConf(), QueryServices.QUERY_SERVER_KEYTAB_FILENAME_ATTRIB, SecurityUtil.login(getConf(), QueryServices.QUERY_SERVER_KEYTAB_FILENAME_ATTRIB,
QueryServices.QUERY_SERVER_KERBEROS_PRINCIPAL_ATTRIB, hostname); QueryServices.QUERY_SERVER_KERBEROS_PRINCIPAL_ATTRIB, hostname);
LOG.info("Login successful."); LOG.info("Login successful.");
} }


Class<? extends PhoenixMetaFactory> factoryClass = getConf().getClass( Class<? extends PhoenixMetaFactory> factoryClass = getConf().getClass(
QueryServices.QUERY_SERVER_META_FACTORY_ATTRIB, PhoenixMetaFactoryImpl.class, PhoenixMetaFactory.class); QueryServices.QUERY_SERVER_META_FACTORY_ATTRIB, PhoenixMetaFactoryImpl.class,
PhoenixMetaFactory.class);
int port = getConf().getInt(QueryServices.QUERY_SERVER_HTTP_PORT_ATTRIB, int port = getConf().getInt(QueryServices.QUERY_SERVER_HTTP_PORT_ATTRIB,
QueryServicesOptions.DEFAULT_QUERY_SERVER_HTTP_PORT); QueryServicesOptions.DEFAULT_QUERY_SERVER_HTTP_PORT);
LOG.debug("Listening on port " + port); LOG.debug("Listening on port " + port);
Expand Down Expand Up @@ -277,7 +283,8 @@ public PhoenixDoAsCallback(UserGroupInformation serverUgi, Configuration conf) {
} }


@Override @Override
public <T> T doAsRemoteUser(String remoteUserName, String remoteAddress, final Callable<T> action) throws Exception { public <T> T doAsRemoteUser(String remoteUserName, String remoteAddress,
final Callable<T> action) throws Exception {
// We are guaranteed by Avatica that the `remoteUserName` is properly authenticated by the // We are guaranteed by Avatica that the `remoteUserName` is properly authenticated by the
// time this method is called. We don't have to verify the wire credentials, we can assume the // time this method is called. We don't have to verify the wire credentials, we can assume the
// user provided valid credentials for who it claimed it was. // user provided valid credentials for who it claimed it was.
Expand Down Expand Up @@ -327,7 +334,7 @@ public UserGroupInformation load(String remoteUserName) throws Exception {
} }


public static void main(String[] argv) throws Exception { public static void main(String[] argv) throws Exception {
int ret = ToolRunner.run(HBaseConfiguration.create(), new Main(), argv); int ret = ToolRunner.run(HBaseConfiguration.create(), new QueryServer(), argv);
System.exit(ret); System.exit(ret);
} }
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authorize.ProxyUsers; import org.apache.hadoop.security.authorize.ProxyUsers;
import org.apache.phoenix.queryserver.server.Main.PhoenixDoAsCallback; import org.apache.phoenix.queryserver.server.QueryServer.PhoenixDoAsCallback;
import org.junit.Test; import org.junit.Test;


/** /**
Expand Down

0 comments on commit a5bcb3e

Please sign in to comment.