Created
May 9, 2011 18:46
-
-
Save anonymous/963103 to your computer and use it in GitHub Desktop.
elasticSearch_transport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void initializeClient() throws Exception { | |
// add transport addresses | |
client = new TransportClient(ImmutableSettings.settingsBuilder() | |
.put("cluster.name", "elasticsearch") // currently hardcoded | |
.put("client.transport.sniff", true)); | |
for (String server : servers) { | |
URL indexUrl = new URL(server); | |
String host = indexUrl.getHost(); | |
Integer port = new Integer(indexUrl.getPort()); | |
index = indexUrl.getPath().substring(1).split("/")[0]; | |
type = indexUrl.getPath().substring(1).split("/")[1]; | |
LOG.info("host:" + host); | |
LOG.info("port:" + port); | |
LOG.info("index:" + index); | |
LOG.info("type:" + type); | |
client.addTransportAddress(new InetSocketTransportAddress(host, port)); | |
} | |
int retry = 0; | |
while (client.connectedNodes().isEmpty()) { | |
retry++; | |
LOG.info("waiting for nodes to connect attempt " + retry); | |
Thread.sleep(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment