जब मैं अपना जावा एप्लिकेशन शुरू करता हूं जो लोचदार खोज 5.6.10 के साथ लोचदार खोज जावा एपीआई के माध्यम से बातचीत करता है और मेरे लोचदार खोज क्लस्टर में 1 से अधिक नोड होते हैं, तो मुझे निम्न अपवाद प्राप्त होता है:

**

**Caused by: java.lang.IllegalArgumentException: Address must be resolved but wasn't - InetSocketAddress#getAddress() returned null
              at org.elasticsearch.common.transport.InetSocketTransportAddress.<init>(InetSocketTransportAddress.java:48)
              at com.intel.mar.data.elasticsearch.client.TransportClientFactory.createTransportClient(TransportClientFactory.java:30)
              at com.intel.mar.service.config.ServiceConfig.serviceDataManager(ServiceConfig.java:81)
              at com.intel.mar.service.config.ServiceConfig$$EnhancerBySpringCGLIB$$77f6a134.CGLIB$serviceDataManager$2(<generated>)
              at com.intel.mar.service.config.ServiceConfig$$EnhancerBySpringCGLIB$$77f6a134$$FastClassBySpringCGLIB$$b506e141.invoke(<generated>)
              at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
              at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
              at com.intel.mar.service.config.ServiceConfig$$EnhancerBySpringCGLIB$$77f6a134.serviceDataManager(<generated>)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
              ... 40 more**

**

लोचदार खोज.ymly

network.bind_host: 0.0.0.0
network.publish_host: "{{getenv "IP"}}"
path.data: /shared/el
cluster.name:  "{{  getv (print "/solutions/" (getenv "COMPONENT_NAMESPACE") "/services/mar-server/es_cluster_name")}}"
cluster.routing.allocation.awareness.attributes: aws_zone_id
node.name: "{{getenv "ID"}}"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: [{{getv (print "/solutions/" (getenv "COMPONENT_NAMESPACE") "/services/mar-server/elastic_search_seeds")}}]
discovery.zen.minimum_master_nodes: "{{getv (print "/solutions/" (getenv "COMPONENT_NAMESPACE") "/services/mar-server/es_minimum_master_nodes")}}"
http.cors.allow-origin: "/.*/"
http.cors.enabled: true

# AWS discovery

http.enabled: true
http.port: 9200

action.auto_create_index: true

transport.tcp.port: 9300
indices.fielddata.cache.size: 25%
script.inline: true
thread_pool.bulk.queue_size: 900

मैं निम्नलिखित तरीके से इलास्टिक्स खोज जावा क्लाइंट बना रहा हूं:

    public Client createTransportClient() {
        Settings settings = Settings.builder()
                .put("cluster.name", config.db().clusterName())
                .build();

    return new PreBuiltTransportClient(settings)
                    .addTransportAddress(
                            new InetSocketTransportAddress(
                                    new InetSocketAddress(
                                            config.db().getElasticSearchHost(),
                                            config.db().getElasticSearchNodePort()
                                    )
                            )
                    );
}
1
Andres Benavides 15 सितंबर 2018, 00:53

1 उत्तर

सबसे बढ़िया उत्तर

समस्या यह थी कि config.db().getElasticSearchHost() "," से अलग मास्टर क्लस्टर नोड्स की एक सूची लौटा रहा था। समाधान निम्नलिखित था:

Settings settings = Settings.builder()
                .put("cluster.name", config.db().clusterName())
                .build();

    PreBuiltTransportClient preBuiltTransportClient = new PreBuiltTransportClient(settings);
    String[] hosts = config.db().getElasticSearchHost().split(SPLIT_SEPARATOR);

    for(int i=0; i<hosts.length;i++){
        preBuiltTransportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hosts[i])
                ,config.db().getElasticSearchNodePort()));
    }

    return preBuiltTransportClient;
1
Andres Benavides 19 सितंबर 2018, 15:42