Java Code Examples for org.apache.hadoop.hbase.HConstants#LOCALHOST
The following examples show how to use
org.apache.hadoop.hbase.HConstants#LOCALHOST .
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 File: TestThriftConnection.java From hbase with Apache License 2.0 | 6 votes |
private static Connection createConnection(int port, boolean useHttp) throws IOException { Configuration conf = HBaseConfiguration.create(TEST_UTIL.getConfiguration()); conf.set(ConnectionUtils.HBASE_CLIENT_CONNECTION_IMPL, ThriftConnection.class.getName()); if (useHttp) { conf.set(Constants.HBASE_THRIFT_CLIENT_BUIDLER_CLASS, ThriftConnection.HTTPThriftClientBuilder.class.getName()); } String host = HConstants.LOCALHOST; if (useHttp) { host = "http://" + host; } conf.set(Constants.HBASE_THRIFT_SERVER_NAME, host); conf.setInt(Constants.HBASE_THRIFT_SERVER_PORT, port); return ConnectionFactory.createConnection(conf); }
Example 2
Source File: TestThriftSpnegoHttpFallbackServer.java From hbase with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { kdc = SimpleKdcServerUtil. getRunningSimpleKdcServer(new File(TEST_UTIL.getDataTestDir().toString()), HBaseTestingUtility::randomFreePort); File keytabDir = Paths.get(TEST_UTIL.getRandomDir().toString()).toAbsolutePath().toFile(); assertTrue(keytabDir.mkdirs()); clientPrincipal = "client@" + kdc.getKdcConfig().getKdcRealm(); clientKeytab = new File(keytabDir, clientPrincipal + ".keytab"); kdc.createAndExportPrincipals(clientKeytab, clientPrincipal); serverPrincipal = "hbase/" + HConstants.LOCALHOST + "@" + kdc.getKdcConfig().getKdcRealm(); serverKeytab = new File(keytabDir, serverPrincipal.replace('/', '_') + ".keytab"); spnegoServerPrincipal = "HTTP/" + HConstants.LOCALHOST + "@" + kdc.getKdcConfig().getKdcRealm(); // Add SPNEGO principal to server keytab kdc.createAndExportPrincipals(serverKeytab, serverPrincipal, spnegoServerPrincipal); TEST_UTIL.getConfiguration().setBoolean(Constants.USE_HTTP_CONF_KEY, true); addSecurityConfigurations(TEST_UTIL.getConfiguration()); TestThriftHttpServer.setUpBeforeClass(); }
Example 3
Source File: TestThriftHttpServer.java From hbase with Apache License 2.0 | 5 votes |
void runThriftServer(int customHeaderSize) throws Exception { // Add retries in case we see stuff like connection reset Exception clientSideException = null; for (int i = 0; i < 10; i++) { clientSideException = null; ThriftServerRunner tsr = createBoundServer(getThriftServerSupplier()); String url = "http://" + HConstants.LOCALHOST + ":" + tsr.getThriftServer().listenPort; try { checkHttpMethods(url); talkToThriftServer(url, customHeaderSize); break; } catch (Exception ex) { clientSideException = ex; LOG.info("Client-side Exception", ex); } finally { tsr.close(); tsr.join(); if (tsr.getRunException() != null) { LOG.error("Invocation of HBase Thrift server threw exception", tsr.getRunException()); throw tsr.getRunException(); } } } if (clientSideException != null) { LOG.error("Thrift Client", clientSideException); throw clientSideException; } }
Example 4
Source File: ProcessBasedLocalHBaseCluster.java From hbase with Apache License 2.0 | 4 votes |
private final String generateConfig(ServerType serverType, int rpcPort, String daemonDir) { StringBuilder sb = new StringBuilder(); Map<String, Object> confMap = new TreeMap<>(); confMap.put(HConstants.CLUSTER_DISTRIBUTED, true); if (serverType == ServerType.MASTER) { confMap.put(HConstants.MASTER_PORT, rpcPort); int masterInfoPort = HBaseTestingUtility.randomFreePort(); reportWebUIPort("master", masterInfoPort); confMap.put(HConstants.MASTER_INFO_PORT, masterInfoPort); } else if (serverType == ServerType.RS) { confMap.put(HConstants.REGIONSERVER_PORT, rpcPort); int rsInfoPort = HBaseTestingUtility.randomFreePort(); reportWebUIPort("region server", rsInfoPort); confMap.put(HConstants.REGIONSERVER_INFO_PORT, rsInfoPort); } else { confMap.put(HConstants.ZOOKEEPER_DATA_DIR, daemonDir); } confMap.put(HConstants.ZOOKEEPER_CLIENT_PORT, zkClientPort); confMap.put(HConstants.HREGION_MAX_FILESIZE, MAX_FILE_SIZE_OVERRIDE); if (dfsCluster != null) { String fsURL = "hdfs://" + HConstants.LOCALHOST + ":" + dfsCluster.getNameNodePort(); confMap.put("fs.defaultFS", fsURL); confMap.put("hbase.rootdir", fsURL + "/hbase_test"); } sb.append("<configuration>\n"); for (Map.Entry<String, Object> entry : confMap.entrySet()) { sb.append(" <property>\n"); sb.append(" <name>" + entry.getKey() + "</name>\n"); sb.append(" <value>" + entry.getValue() + "</value>\n"); sb.append(" </property>\n"); } sb.append("</configuration>\n"); return sb.toString(); }