Hi all,
running elastic search on docker container
developing a sample application in java, using java client 6.0.0 alpha2 and transport client to communicate to ElasticSearch.
Cluster name is "elasticsearch" (this is the default name and i have not change any config in the docker machine)
Ports 9200 and 9300 are published.
code:
public class Main {
//EventProcessorSimulator
// this java program will "listen" for messages that arrive at the rabbit queue and write then to elastic
private final static String LOG_QUEUE_NAME = "QLOG";
private final static String TRACE_QUEUE_NAME = "QTRACE";
public static void main(String[] args) throws Exception {
//get a connection to rabbitmq and get a channel
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
// get messages from the log events queue
channel.queueBind(LOG_QUEUE_NAME, "EXQLOGS", "");
// get a connection to elasticsearch
System.out.println(" [*] Connecting to elasticSearch");
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY);
client.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));
String jsonvalue = "{\"nome\":\"ruimadaleno\"}"; curl -XGET localhost:9200/_nodes?pretty
// index (put) the message in elastic search
System.out.println(jsonvalue);
IndexResponse response = client.prepareIndex("logs","logtype").setSource(jsonvalue, XContentType.JSON).get();
//xContentType
// get the status of the operation and doc id created
//RestStatus ResponseStatus =response.status();
//String DocId = response.getId();
///System.out.println(" elastic search operation is " + ResponseStatus.getStatus() + " created doc " + DocId);
System.out.println("aaaaaaaaaaaaaaaaaa");
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
Consumer consumer = new DefaultConsumer(channel) {
@Override
public void handleDelivery(String consumerTag, Envelope envelope,
AMQP.BasicProperties properties, byte[] body) throws IOException {
String message = new String(body, "UTF-8");
System.out.println(" [x] Received '" + message + "'");
}
};
channel.basicConsume(LOG_QUEUE_NAME, true, consumer);
}
}
curl -XGET localhost:9200
{
"name" : "uAYop-M",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Mb8z4AWVRCiL4FXRDq_quQ",
"version" : {
"number" : "5.4.3",
"build_hash" : "eed30a8",
"build_date" : "2017-06-22T00:34:03.743Z",
"build_snapshot" : false,
"lucene_version" : "6.5.1"
},
"tagline" : "You Know, for Search"
}
error:
[*] Connecting to elasticSearch
111aaaaaaaaaaaaaaaaaa
{"nome":"ruimadaleno"}
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{fIpyYVs_RfOn8YS8oAHVjg}{localhost}{127.0.0.1:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:357)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:405)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:394)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:53)
at com.ff_logstrace_framework.Main.main(Main.java:67)
some additional info
curl -XGET localhost:9200/_nodes?pretty
{
"_nodes" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"cluster_name" : "elasticsearch",
"nodes" : {
"uAYop-MZToio_Ik1-i1oXg" : {
"name" : "uAYop-M",
"transport_address" : "127.0.0.1:9300",
"host" : "127.0.0.1",
"ip" : "127.0.0.1",
"version" : "5.4.3",
"build_hash" : "eed30a8",
"total_indexing_buffer" : 211261849,
"roles" : [
"master",
"data",
"ingest"
],
"settings" : {
"client" : {
"type" : "node"
},
"cluster" : {
"name" : "elasticsearch"
},
"http" : {
"host" : "0.0.0.0",
"type" : {
"default" : "netty4"
}
},
"node" : {
"name" : "uAYop-M"
},
"path" : {
"logs" : "/usr/share/elasticsearch/logs",
"home" : "/usr/share/elasticsearch"
},
"transport" : {
"host" : "127.0.0.1",
"type" : {
"default" : "netty4"
}
}
},
"os" : {
"refresh_interval_in_millis" : 1000,
"name" : "Linux",
"arch" : "amd64",
"version" : "4.4.0-83-generic",
"available_processors" : 4,
"allocated_processors" : 4
},
"process" : {
"refresh_interval_in_millis" : 1000,
"id" : 26,{
"name" : "uAYop-M",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Mb8z4AWVRCiL4FXRDq_quQ",
"version" : {
"number" : "5.4.3",
"build_hash" : "eed30a8",
"build_date" : "2017-06-22T00:34:03.743Z",
"build_snapshot" : false,
"lucene_version" : "6.5.1"
},
"tagline" : "You Know, for Search"
}
"mlockall" : false
},
"transport" : {
"bound_address" : [
"127.0.0.1:9300"
],
"publish_address" : "127.0.0.1:9300",
"profiles" : { }
},
"http" : {
"bound_address" : [
"[::]:9200"
],
"publish_address" : "172.17.0.2:9200",
"max_content_length_in_bytes" : 104857600
},
"plugins" : [ ],
"modules" : [
{
"name" : "aggs-matrix-stats",
"version" : "5.4.3",
}
}
}
}
},
}