Java Code Examples for org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge

The following examples show how to use org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: beeju   Source File: ThriftHiveMetaStoreCore.java    License: Apache License 2.0 5 votes vote down vote up
public void initialise() throws Exception {
  thriftPort = -1;
  final Lock startLock = new ReentrantLock();
  final Condition startCondition = startLock.newCondition();
  final AtomicBoolean startedServing = new AtomicBoolean();
  try (ServerSocket socket = new ServerSocket(0)) {
    thriftPort = socket.getLocalPort();
  }
  beejuCore.setHiveVar(HiveConf.ConfVars.METASTOREURIS, getThriftConnectionUri());
  final HiveConf hiveConf = new HiveConf(beejuCore.conf(), HiveMetaStoreClient.class);
  thriftServer.execute(new Runnable() {
    @Override
    public void run() {
      try {
        HadoopThriftAuthBridge bridge = new HadoopThriftAuthBridge23();
        HiveMetaStore.startMetaStore(thriftPort, bridge, hiveConf, startLock, startCondition, startedServing);
      } catch (Throwable e) {
        LOG.error("Unable to start a Thrift server for Hive Metastore", e);
      }
    }
  });
  int i = 0;
  while (i++ < 3) {
    startLock.lock();
    try {
      if (startCondition.await(1, TimeUnit.MINUTES)) {
        break;
      }
    } finally {
      startLock.unlock();
    }
    if (i == 3) {
      throw new RuntimeException("Maximum number of tries reached whilst waiting for Thrift server to be ready");
    }
  }
}
 
Example 2
Source Project: dremio-oss   Source File: ShimLoader.java    License: Apache License 2.0 5 votes vote down vote up
public static synchronized HadoopThriftAuthBridge getHadoopThriftAuthBridge() {
  if (hadoopThriftAuthBridge == null) {
    hadoopThriftAuthBridge = loadShims(HADOOP_THRIFT_AUTH_BRIDGE_CLASSES,
        HadoopThriftAuthBridge.class);
  }
  return hadoopThriftAuthBridge;
}
 
Example 3
Source Project: hadoop-mini-clusters   Source File: HiveLocalMetaStore.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    try {
        HiveMetaStore.startMetaStore(hiveMetastorePort, 
                new HadoopThriftAuthBridge(), 
                hiveConf);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
Example 4
Source Project: waggle-dance   Source File: MetaStoreProxyServer.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Start Metastore based on a passed {@link HadoopThriftAuthBridge}
 *
 * @param bridge
 * @param startLock
 * @param startCondition
 * @param startedServing
 * @throws Throwable
 */
private void startWaggleDance(
    HadoopThriftAuthBridge bridge,
    Lock startLock,
    Condition startCondition,
    AtomicBoolean startedServing)
  throws Throwable {
  try {
    // Server will create new threads up to max as necessary. After an idle
    // period, it will destory threads to keep the number of threads in the
    // pool to min.
    int minWorkerThreads = hiveConf.getIntVar(ConfVars.METASTORESERVERMINTHREADS);
    int maxWorkerThreads = hiveConf.getIntVar(ConfVars.METASTORESERVERMAXTHREADS);
    boolean tcpKeepAlive = hiveConf.getBoolVar(ConfVars.METASTORE_TCP_KEEP_ALIVE);
    boolean useFramedTransport = hiveConf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_FRAMED_TRANSPORT);
    boolean useSSL = hiveConf.getBoolVar(ConfVars.HIVE_METASTORE_USE_SSL);

    TServerSocket serverSocket = createServerSocket(useSSL, waggleDanceConfiguration.getPort());

    if (tcpKeepAlive) {
      serverSocket = new TServerSocketKeepAlive(serverSocket);
    }

    TTransportFactory transFactory = useFramedTransport ? new TFramedTransport.Factory() : new TTransportFactory();
    LOG.info("Starting WaggleDance Server");

    TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverSocket)
        .processorFactory(tSetIpAddressProcessorFactory)
        .transportFactory(transFactory)
        .protocolFactory(new TBinaryProtocol.Factory())
        .minWorkerThreads(minWorkerThreads)
        .maxWorkerThreads(maxWorkerThreads)
        .stopTimeoutVal(waggleDanceConfiguration.getThriftServerStopTimeoutValInSeconds())
        .requestTimeout(waggleDanceConfiguration.getThriftServerRequestTimeout())
        .requestTimeoutUnit(waggleDanceConfiguration.getThriftServerRequestTimeoutUnit());

    tServer = new TThreadPoolServer(args);
    LOG.info("Started the new WaggleDance on port [" + waggleDanceConfiguration.getPort() + "]...");
    LOG.info("Options.minWorkerThreads = " + minWorkerThreads);
    LOG.info("Options.maxWorkerThreads = " + maxWorkerThreads);
    LOG.info("TCP keepalive = " + tcpKeepAlive);

    if (startLock != null) {
      signalOtherThreadsToStart(tServer, startLock, startCondition, startedServing);
    }
    tServer.serve();
  } catch (Throwable x) {
    LOG.error(StringUtils.stringifyException(x));
    throw x;
  }
  LOG.info("Waggle Dance has stopped");
}