Procházet zdrojové kódy

SONAR-12686 enforce index rebuilding by changing ES data directory

tags/8.6.0.39681
Sébastien Lesaint před 4 roky
rodič
revize
8cdee7d30f

+ 1
- 1
server/sonar-docs/src/pages/faq.md Zobrazit soubor

@@ -20,7 +20,7 @@ This can be automated by using the corresponding Web API: `api/projects/bulk_del
Currently, the only way to force a reindex is to:

* Stop your server
* Remove the contents of the $SQ_HOME/data/es6 directory
* Remove the contents of the $SQ_HOME/data/es7 directory
* Start your server

Before doing this, you should be aware first that processes are in place on the SonarQube side that out-of-sync indices are detected and corrected, and second that a full re-index can be quite lengthy depending on the size of your instance.

+ 2
- 2
server/sonar-docs/src/pages/setup/troubleshooting.md Zobrazit soubor

@@ -59,13 +59,13 @@ If you still have inconsistencies, you'll need to rebuild the indices (this oper
**non-DCE:**

1. Stop SonarQube
1. Delete the data/es6 directory
1. Delete the data/es7 directory
1. Restart SonarQube

**DCE:**

1. Stop the whole cluster (ES and application nodes)
1. Delete the data/es6 directory on each ES node
1. Delete the data/es7 directory on each ES node
1. Restart the whole cluster
**Note:** See [Configure & Operate a Cluster](/setup/operate-cluster/) for information on stopping and starting a cluster.

+ 6
- 3
server/sonar-main/src/main/java/org/sonar/application/es/EsInstallation.java Zobrazit soubor

@@ -20,11 +20,12 @@
package org.sonar.application.es;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.stream.Stream;
import org.sonar.application.command.EsJvmOptions;
import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.process.Props;

import static org.sonar.process.ProcessProperties.Property.PATH_DATA;
@@ -65,12 +66,14 @@ public class EsInstallation {

private static List<File> buildOutdatedSearchDirs(Props props) {
String dataPath = props.nonNullValue(PATH_DATA.getKey());
return Arrays.asList(new File(dataPath, "es"), new File(dataPath, "es5"));
return Stream.of("es", "es5", "es6")
.map(t -> new File(dataPath, t))
.collect(MoreCollectors.toList());
}

private static File buildDataDir(Props props) {
String dataPath = props.nonNullValue(PATH_DATA.getKey());
return new File(dataPath, "es6");
return new File(dataPath, "es7");
}

private static File buildLogPath(Props props) {

+ 3
- 3
server/sonar-main/src/test/java/org/sonar/application/es/EsInstallationTest.java Zobrazit soubor

@@ -102,7 +102,7 @@ public class EsInstallationTest {

EsInstallation underTest = new EsInstallation(props);

assertThat(underTest.getDataDirectory()).isEqualTo(new File(dataDir, "es6"));
assertThat(underTest.getDataDirectory()).isEqualTo(new File(dataDir, "es7"));
}

@Test
@@ -133,8 +133,8 @@ public class EsInstallationTest {
EsInstallation underTest = new EsInstallation(props);

assertThat(underTest.getOutdatedSearchDirectories())
.extracting(t -> t.getName())
.containsOnly("es", "es5");
.extracting(File::getName)
.containsExactlyInAnyOrder("es", "es5", "es6");
}

@Test

Načítá se…
Zrušit
Uložit