I am facing an issue while converting the node client to transport client , can any one please guide me on the conversion , It is saying none of the configured nodes available.
Do any one has any snippet to create a transport client , i am doing with the embedded elastic search server start up in junit test case to connect via transport client , please post any thoughts or ideas to create an embedded es server and connect through transport client .
Hi David , starting up the custom embedded es cluster and shutting down once after all the unit test are done. And he was using the node client during that time and we decided to go with the transport client and there is the actual issue.
Here is the custom class where we have written to start up embedded one :
public EmbeddedElasticsearchServer(String clusterName) {
this.clusterName = clusterName;
this.dataDirectory = DEFAULT_DATA_DIRECTORY + this.clusterName;
LOGGER.info("######### Starting embedded elastic search cluster, name = {} in directory = {}", clusterName, this.dataDirectory);
/* Clean directory before starting server */
File dataDirectory = new File(this.dataDirectory);
if (dataDirectory.exists()) {
EmbeddedElasticsearchServer.deleteDataDirectory(this.dataDirectory);
}
this.elasticsearchSettings = ImmutableSettings.settingsBuilder()
.put("http.enabled", "false")
.put("path.data", this.dataDirectory)
.put("index.number_of_replicas", 0)
.build();
node = createLocalNode();
client = this.node.client();
esClients = new ArrayList<>();
esClients.add(client);
}
public Node createLocalNode() {
return nodeBuilder()
.local(true)
.settings(this.elasticsearchSettings)
.clusterName(this.clusterName)
.node();
}
public static void deleteDataDirectory(String directory) {
LOGGER.info("Deleting directory = {}", directory);
try {
FileUtils.forceDelete(new File(directory));
} catch (IOException e) {
LOGGER.error("Unable to delete directory = {} due to exception = {}", directory, ExceptionUtils.getStackTrace(e));
}
}
@Override
public Client getClient() {
return client;
}
@Override
public ArrayList<Client> getEsClients() {
return esClients;
}
@Override
public void shutDown() {
String nodeName = node.settings().get("name");
LOGGER.info("######### Stopping embedded elastic search client and node = " + nodeName);
this.getEsClients().forEach(client -> client.close());
node.close();
LOGGER.info("######### Stopped embedded elastic search node = " + nodeName + ", is closed = " + node.isClosed());
EmbeddedElasticsearchServer.deleteDataDirectory(this.dataDirectory);
}
and that was the place where i was trying to inject esclient as transport client instead of node client and i ended up with the none of the configured nodes exception.
Thank you for the suggestion but my issue is different where i am using es version of 1.3 and there is no prebuilt transport client for es version of 1.3 and i didnt get your statement that there is no embedded support or embedded es setup available , if that is the case we are doing by ourself by setting up node and cluster and reaching out via node client , the same embedded cluster i want to use but i have to get with the transport client instead of node client which i have written the above code. Please let me know if i am missing something here ..i really appreciate the help from the community. I mean i am requesting that the proper conversion technique of moving away from node client to transport client with the es version of 1.3.
thank you ...but do you see any issue in connecting the created node through transport client instead of node client ? i mean i am able to do the same setup and successful operations with the node client and not able to do with the transport client..i have followed the documentation and provided all the settings needed but still it says none of the configured nodes exception. is there any way which can create a local node with the node builder and access through transport client ?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.