本文整理匯總了Java中org.elasticsearch.common.transport.InetSocketTransportAddress.getHost方法的典型用法代碼示例。如果您正苦於以下問題:Java InetSocketTransportAddress.getHost方法的具體用法?Java InetSocketTransportAddress.getHost怎麽用?Java InetSocketTransportAddress.getHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.common.transport.InetSocketTransportAddress
的用法示例。
在下文中一共展示了InetSocketTransportAddress.getHost方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testHealthResponse
import org.elasticsearch.common.transport.InetSocketTransportAddress; //導入方法依賴的package包/類
@Test
public void testHealthResponse() throws Exception {
InetSocketTransportAddress httpAddress = findHttpAddress(client("1"));
if (httpAddress == null) {
throw new IllegalArgumentException("no HTTP address found");
}
URL base = new URL("http://" + httpAddress.getHost() + ":" + httpAddress.getPort());
URL url = new URL(base, "/_cluster/health?xml");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
if ((line = reader.readLine()) != null) {
assertTrue(line.startsWith("<root xmlns=\"http://elasticsearch.org/ns/1.0/\">"));
assertTrue(line.endsWith("</root>"));
}
reader.close();
}
示例2: testPrettyHealthResponse
import org.elasticsearch.common.transport.InetSocketTransportAddress; //導入方法依賴的package包/類
@Test
public void testPrettyHealthResponse() throws Exception {
InetSocketTransportAddress httpAddress = findHttpAddress(client("1"));
if (httpAddress == null) {
throw new IllegalArgumentException("no HTTP address found");
}
URL base = new URL("http://" + httpAddress.getHost() + ":" + httpAddress.getPort());
URL url = new URL(base, "/_cluster/health?xml&pretty");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
// check only first line
if ((line = reader.readLine()) != null) {
assertTrue(line.startsWith("<root xmlns=\"http://elasticsearch.org/ns/1.0/\">"));
}
reader.close();
}
示例3: testBigAndFatResponse
import org.elasticsearch.common.transport.InetSocketTransportAddress; //導入方法依賴的package包/類
@Test
public void testBigAndFatResponse() throws Exception {
Client client = client("1");
for (int i = 0; i < 10000; i++) {
client.index(new IndexRequest("test", "test", Integer.toString(i))
.source("{\"random\":\""+randomString(32)+ " " + randomString(32) + "\"}")).actionGet();
}
client.admin().indices().refresh(new RefreshRequest("test")).actionGet();
InetSocketTransportAddress httpAddress = findHttpAddress(client);
if (httpAddress == null) {
throw new IllegalArgumentException("no HTTP address found");
}
URL base = new URL("http://" + httpAddress.getHost() + ":" + httpAddress.getPort());
URL url = new URL(base, "/test/test/_search?xml&pretty&size=10000");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
int count = 0;
String line;
while ((line = reader.readLine()) != null) {
count += line.length();
}
assertTrue(count >= 2309156);
reader.close();
client.admin().indices().delete(new DeleteIndexRequest("test"));
}