當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。