本文整理汇总了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"));
}