我在UBUNTU上使用了下面的Java代码,但正在“节点发现已禁用”。因此,我无法前进。
谁能帮我解决这个问题。
public static JestClient JestConfiguration(){
// Configuration
ClientConfig client = new ClientConfig.Builder("http://localhost:9200")
.multiThreaded(true).build();
System.out.println("\nclient configured via:- "+client);
// Construct a new Jest client according to configuration via factory
JestClientFactory factory = new JestClientFactory();
factory.setClientConfig(client);
System.out.println("\nJestClientFactory Via:-"+factory);
JestClient jestClient = factory.getObject();
System.out.println("\njestClient via:-"+jestClient);
//jestClient.shutdownClient();
return jestClient;
}
我不确定您使用的是哪个版本。我正在使用0.1.2,而我的工厂只有一个 setHttpClientConfig 方法。因此,我改用了
HttpClientConfig ,它扩展了 ClientConfig 。撇开这一点,构建器有两种您需要的方法:
这些设置节点节点发现以及轮询的频率。
HttpClientConfig httpClientConfig = new HttpClientConfig.Builder("http://localhost:9200")
.discoveryEnabled(true)
.discoveryFrequency(10l, TimeUnit.SECONDS)
.multiThreaded(true)
.build();
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(httpClientConfig);