Search in sources :

Example 1 with SearchServer

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;
}
Also used : SearchServer(org.sonar.search.SearchServer) Properties(java.util.Properties) ProcessProperties(org.sonar.process.ProcessProperties) Props(org.sonar.process.Props) File(java.io.File) ProcessEntryPoint(org.sonar.process.ProcessEntryPoint)

Aggregations

File (java.io.File)1 Properties (java.util.Properties)1 ProcessEntryPoint (org.sonar.process.ProcessEntryPoint)1 ProcessProperties (org.sonar.process.ProcessProperties)1 Props (org.sonar.process.Props)1 SearchServer (org.sonar.search.SearchServer)1