Hej all,
I have created a Elastic Search cluster with 2 nodes in EC2 using the
homepage documentation with out using any gateway. And Thats working fine.
I can see that cluster helath and bigdesk all the stuff.
Here is my settings
cluster.name: broadwayrealtime
cloud.aws.region: eu-west-1
cloud:
cloud.aws.region: eu-west-1
aws:
access_key: XXXXXXX
secret_key: XXXXXXX
discovery:
type: ec2
node.master: true
node.name: "Brendan Test"
But when I am trying to access through the JAVA api I am getting exception.
I am using the below settings to connect to this cluster using JAVA api.
final ImmutableSettings.Builder settings =
ImmutableSettings.settingsBuilder();
settings.put("discovery.type", "ec2");
settings.put("cloud.aws.access_key", "access_key");
settings.put("cloud.aws.secret_key", "secret_key");
settings.put("cloud.aws.region", "eu-west-1");
settings.put("discovery.ec2.groups", "elasticsearch");
Node node =
NodeBuilder.nodeBuilder().settings(settings).clusterName("clusterName").client(true).node();
client = node.client();
But I get this exception after 1 minute
18:29:25.997 [New I/O client boss #1-0] WARN
org.elasticsearch.transport.netty - [Mutant X] Exception caught on netty
layer [[id: 0x129a41d2]]
java.net.SocketException: Network is unreachable
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.6.0_31]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:567)
~[na:1.6.0_31]
at
org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:404)
[elasticsearch-0.19.4.jar:na]
at
org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:366)
[elasticsearch-0.19.4.jar:na]
at
org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:282)
[elasticsearch-0.19.4.jar:na]
at
org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
[elasticsearch-0.19.4.jar:na]
at
org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
[elasticsearch-0.19.4.jar:na]
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[na:1.6.0_31]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[na:1.6.0_31]
at java.lang.Thread.run(Thread.java:680) [na:1.6.0_31]
org.elasticsearch.discovery.MasterNotDiscoveredException: waited for [1m]
at
org.elasticsearch.action.support.master.TransportMasterNodeOperationAction$3.onTimeout(TransportMasterNodeOperationAction.java:169)
at
org.elasticsearch.cluster.service.InternalClusterService$NotifyTimeout.run(InternalClusterService.java:356)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Just to share the info; If I use like this its working fine.
final ImmutableSettings.Builder settings =
ImmutableSettings.settingsBuilder();
settings.put("discovery.type", "ec2");
settings.put("cloud.aws.access_key", "access_key");
settings.put("cloud.aws.secret_key", "secret_key");
settings.put("cloud.aws.region", "eu-west-1");
settings.put("discovery.ec2.groups", "elasticsearch");
final TransportClient transportClient = new TransportClient(settings)
.addTransportAddress(new
InetSocketTransportAddress("hostname", 9300))
.addTransportAddress(new
InetSocketTransportAddress("hostname", 9300))
Do I have to specify the hostnames like the above? which is kind of
annoying to specify the host names? Shouldn't my java code find the cluster
since I have specified everything such as clustername, discovery, access
key, secret key. and region.
Many thanks for your help? I really appreciate your help.