当前位置: 首页>>代码示例>>Java>>正文


Java InetSocketTransportAddress.getHost方法代码示例

本文整理汇总了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();
}
 
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:17,代码来源:XmlPluginTest.java

示例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();
}
 
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:17,代码来源:XmlPluginTest.java

示例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"));
}
 
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:25,代码来源:XmlPluginTest.java


注:本文中的org.elasticsearch.common.transport.InetSocketTransportAddress.getHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。