use of org.apache.calcite.avatica.Meta in project calcite-avatica by apache.
the class AlternatingRemoteMetaTest method getMeta.
private static Meta getMeta(AvaticaConnection conn) throws Exception {
Field f = AvaticaConnection.class.getDeclaredField("meta");
f.setAccessible(true);
return (Meta) f.get(conn);
}
use of org.apache.calcite.avatica.Meta in project calcite-avatica by apache.
the class Main method start.
/**
* Creates and starts an {@link HttpServer} using the given factory to create the Handler.
*
* <p>Arguments are as follows:
* <ul>
* <li>args[0]: the {@link org.apache.calcite.avatica.Meta.Factory} class
* name
* <li>args[1+]: arguments passed along to
* {@link org.apache.calcite.avatica.Meta.Factory#create(java.util.List)}
* </ul>
*
* @param args Command-line arguments
* @param port Server port to bind
* @param handlerFactory Factory to create the handler used by the server
*/
public static HttpServer start(String[] args, int port, HandlerFactory handlerFactory) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
String factoryClassName = args[0];
@SuppressWarnings("unchecked") Class<Meta.Factory> factoryClass = (Class<Meta.Factory>) Class.forName(factoryClassName);
Meta.Factory factory = factoryClass.getConstructor().newInstance();
Meta meta = factory.create(Arrays.asList(args).subList(1, args.length));
Service service = new LocalService(meta);
HttpServer server = new HttpServer(port, HttpServer.wrapJettyHandler(handlerFactory.createHandler(service)));
server.start();
return server;
}
use of org.apache.calcite.avatica.Meta in project calcite-avatica by apache.
the class RemoteMetaTest method getMeta.
private static Meta getMeta(AvaticaConnection conn) throws Exception {
Field f = AvaticaConnection.class.getDeclaredField("meta");
f.setAccessible(true);
return (Meta) f.get(conn);
}
use of org.apache.calcite.avatica.Meta in project phoenix by apache.
the class QueryServer method run.
@Override
public int run(String[] args) throws Exception {
logProcessInfo(getConf());
try {
final boolean isKerberos = "kerberos".equalsIgnoreCase(getConf().get(QueryServices.QUERY_SERVER_HBASE_SECURITY_CONF_ATTRIB));
final boolean disableSpnego = getConf().getBoolean(QueryServices.QUERY_SERVER_SPNEGO_AUTH_DISABLED_ATTRIB, QueryServicesOptions.DEFAULT_QUERY_SERVER_SPNEGO_AUTH_DISABLED);
// handle secure cluster credentials
if (isKerberos && !disableSpnego) {
String hostname = Strings.domainNamePointerToHostName(DNS.getDefaultHost(getConf().get(QueryServices.QUERY_SERVER_DNS_INTERFACE_ATTRIB, "default"), getConf().get(QueryServices.QUERY_SERVER_DNS_NAMESERVER_ATTRIB, "default")));
if (LOG.isDebugEnabled()) {
LOG.debug("Login to " + hostname + " using " + getConf().get(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, QueryServices.QUERY_SERVER_KERBEROS_PRINCIPAL_ATTRIB, hostname);
LOG.info("Login successful.");
}
Class<? extends PhoenixMetaFactory> factoryClass = getConf().getClass(QueryServices.QUERY_SERVER_META_FACTORY_ATTRIB, PhoenixMetaFactoryImpl.class, PhoenixMetaFactory.class);
int port = getConf().getInt(QueryServices.QUERY_SERVER_HTTP_PORT_ATTRIB, QueryServicesOptions.DEFAULT_QUERY_SERVER_HTTP_PORT);
LOG.debug("Listening on port " + port);
PhoenixMetaFactory factory = factoryClass.getDeclaredConstructor(Configuration.class).newInstance(getConf());
Meta meta = factory.create(Arrays.asList(args));
Service service = new LocalService(meta);
// Start building the Avatica HttpServer
final HttpServer.Builder builder = new HttpServer.Builder().withPort(port).withHandler(service, getSerialization(getConf()));
// Enable SPNEGO and Impersonation when using Kerberos
if (isKerberos) {
UserGroupInformation ugi = UserGroupInformation.getLoginUser();
// Make sure the proxyuser configuration is up to date
ProxyUsers.refreshSuperUserGroupsConfiguration(getConf());
String keytabPath = getConf().get(QueryServices.QUERY_SERVER_KEYTAB_FILENAME_ATTRIB);
File keytab = new File(keytabPath);
String realmsString = getConf().get(QueryServices.QUERY_SERVER_KERBEROS_ALLOWED_REALMS, null);
String[] additionalAllowedRealms = null;
if (null != realmsString) {
additionalAllowedRealms = StringUtils.split(realmsString, ',');
}
// Enable SPNEGO and impersonation (through standard Hadoop configuration means)
builder.withSpnego(ugi.getUserName(), additionalAllowedRealms).withAutomaticLogin(keytab).withImpersonation(new PhoenixDoAsCallback(ugi, getConf()));
}
// Build and start the HttpServer
server = builder.build();
server.start();
runningLatch.countDown();
server.join();
return 0;
} catch (Throwable t) {
LOG.fatal("Unrecoverable service error. Shutting down.", t);
this.t = t;
return -1;
}
}
Aggregations