use of org.sonar.search.SearchServer in project sonarqube by SonarSource.
the class EsServerHolder method get.
public static synchronized EsServerHolder get() throws IOException {
if (HOLDER == null) {
File homeDir = Files.createTempDirectory("tmp-es-").toFile();
homeDir.delete();
homeDir.mkdir();
String clusterName = "testCluster";
String hostName = "127.0.0.1";
int port = NetworkUtils.freePort();
Properties properties = new Properties();
properties.setProperty(ProcessProperties.CLUSTER_NAME, clusterName);
properties.setProperty(ProcessProperties.SEARCH_PORT, String.valueOf(port));
properties.setProperty(ProcessProperties.SEARCH_HOST, hostName);
properties.setProperty(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath());
properties.setProperty(ProcessEntryPoint.PROPERTY_SHARED_PATH, homeDir.getAbsolutePath());
SearchServer server = new SearchServer(new Props(properties));
server.start();
HOLDER = new EsServerHolder(server, clusterName, port, hostName, homeDir);
}
HOLDER.reset();
return HOLDER;
}
Aggregations