private Hbase.Client refresh(Hbase.Client client, THttpClient httpClient) { httpClient.setCustomHeader("doAs", doAsUser); if(secure) { try { httpClient.setCustomHeader("Authorization", generateTicket()); } catch (GSSException e) { LOG.error("Kerberos authentication failed", e); } } return client; }
@Override public Pair<THBaseService.Client, TTransport> getClient() throws IOException { Preconditions.checkArgument(connection.getHost().startsWith("http"), "http client host must start with http or https"); String url = connection.getHost() + ":" + connection.getPort(); try { THttpClient httpClient = new THttpClient(url, connection.getHttpClient()); for (Map.Entry<String, String> header : customHeader.entrySet()) { httpClient.setCustomHeader(header.getKey(), header.getValue()); } httpClient.open(); TProtocol prot = new TBinaryProtocol(httpClient); THBaseService.Client client = new THBaseService.Client(prot); return new Pair<>(client, httpClient); } catch (TTransportException e) { throw new IOException(e); } } }
@Override protected void talkToThriftServer(String url, int customHeaderSize) throws Exception { // Close httpClient and THttpClient automatically on any failures try ( CloseableHttpClient httpClient = createHttpClient(); THttpClient tHttpClient = new THttpClient(url, httpClient) ) { tHttpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } tHttpClient.setCustomHeader(HttpHeaders.USER_AGENT, sb.toString()); } TProtocol prot = new TBinaryProtocol(tHttpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated) { TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } }
protected void talkToThriftServer(String url, int customHeaderSize) throws Exception { THttpClient httpClient = new THttpClient(url); httpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } httpClient.setCustomHeader("User-Agent", sb.toString()); } try { TProtocol prot; prot = new TBinaryProtocol(httpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated){ TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } finally { httpClient.close(); } }
sb.append("a"); httpClient.setCustomHeader("User-Agent", sb.toString());
private Hbase.Client refresh(Hbase.Client client, THttpClient httpClient) { httpClient.setCustomHeader("doAs", doAsUser); if(secure) { try { httpClient.setCustomHeader("Authorization", generateTicket()); } catch (GSSException e) { e.printStackTrace(); } } return client; }
public void loginWithAuthToken(String authToken) throws Exception { THttpClient transport = new THttpClient(LINE_HTTP_IN_URL, httpClient); transport.setCustomHeader(X_LINE_ACCESS, authToken); transport.open(); TProtocol protocol = new TCompactProtocol(transport); setClient(new TalkService.Client(protocol)); setAuthToken(authToken); }
private void talkToThriftServer(int customHeaderSize) throws Exception { THttpClient httpClient = new THttpClient( "http://"+ HConstants.LOCALHOST + ":" + port); httpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } httpClient.setCustomHeader("User-Agent", sb.toString()); } try { TProtocol prot; prot = new TBinaryProtocol(httpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated){ TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } finally { httpClient.close(); } }
@Override void talkToThriftServer(String url, int customHeaderSize) throws Exception { // Close httpClient and THttpClient automatically on any failures try ( CloseableHttpClient httpClient = createHttpClient(); THttpClient tHttpClient = new THttpClient(url, httpClient) ) { tHttpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } tHttpClient.setCustomHeader(HttpHeaders.USER_AGENT, sb.toString()); } TProtocol prot = new TBinaryProtocol(tHttpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated) { TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } }
void talkToThriftServer(String url, int customHeaderSize) throws Exception { THttpClient httpClient = new THttpClient(url); httpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } httpClient.setCustomHeader("User-Agent", sb.toString()); } try { TProtocol prot; prot = new TBinaryProtocol(httpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated){ TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } finally { httpClient.close(); } }