replaced IndexSynchronizer which also triggered a full reindex (which we do not want in CE)
import org.sonar.api.utils.Durations;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.UriReader;
+import org.sonar.ce.es.EsIndexerEnabler;
import org.sonar.ce.property.CePropertyDefinitions;
import org.sonar.core.component.DefaultResourceTypes;
import org.sonar.core.config.CorePropertyDefinitions;
};
private static final Object[] STARTUP_COMPONENTS = new Object[] {
// IndexSynchronizer.class, ES maintenance, responsibility of Web Server
+ EsIndexerEnabler.class,
// RegisterMetrics.class, DB maintenance, responsibility of Web Server
// RegisterQualityGates.class, DB maintenance, responsibility of Web Server
// RegisterRules.class, DB maintenance, responsibility of Web Server
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.ce.es;
+
+import org.picocontainer.Startable;
+import org.sonar.server.activity.index.ActivityIndexer;
+import org.sonar.server.issue.index.IssueAuthorizationIndexer;
+import org.sonar.server.issue.index.IssueIndexer;
+import org.sonar.server.test.index.TestIndexer;
+import org.sonar.server.user.index.UserIndexer;
+import org.sonar.server.view.index.ViewIndexer;
+
+/**
+ * Replaces the {@link org.sonar.server.search.IndexSynchronizer} to enable indexers but without triggering a full
+ * indexation (it's the WebServer's responsibility).
+ */
+public class EsIndexerEnabler implements Startable {
+
+ private final TestIndexer testIndexer;
+ private final IssueAuthorizationIndexer issueAuthorizationIndexer;
+ private final IssueIndexer issueIndexer;
+ private final UserIndexer userIndexer;
+ private final ViewIndexer viewIndexer;
+ private final ActivityIndexer activityIndexer;
+
+ public EsIndexerEnabler(TestIndexer testIndexer, IssueAuthorizationIndexer issueAuthorizationIndexer,
+ IssueIndexer issueIndexer, UserIndexer userIndexer, ViewIndexer viewIndexer, ActivityIndexer activityIndexer) {
+ this.testIndexer = testIndexer;
+ this.issueAuthorizationIndexer = issueAuthorizationIndexer;
+ this.issueIndexer = issueIndexer;
+ this.userIndexer = userIndexer;
+ this.viewIndexer = viewIndexer;
+ this.activityIndexer = activityIndexer;
+ }
+
+ @Override
+ public void start() {
+ activityIndexer.setEnabled(true);
+ issueAuthorizationIndexer.setEnabled(true);
+ issueIndexer.setEnabled(true);
+ testIndexer.setEnabled(true);
+ userIndexer.setEnabled(true);
+ viewIndexer.setEnabled(true);
+ }
+
+ @Override
+ public void stop() {
+ // nothing to do at stop
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.ce.es;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+ 7 // content of CeQueueModule
+ 4 // content of ReportProcessingModule
+ 4 // content of CeTaskProcessorModule
- + 3 // level startup
+ + 4 // level startup
);
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.ce.es;
+
+import org.junit.Test;
+import org.sonar.server.activity.index.ActivityIndexer;
+import org.sonar.server.issue.index.IssueAuthorizationIndexer;
+import org.sonar.server.issue.index.IssueIndexer;
+import org.sonar.server.test.index.TestIndexer;
+import org.sonar.server.user.index.UserIndexer;
+import org.sonar.server.view.index.ViewIndexer;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class EsIndexerEnablerTest {
+ private TestIndexer testIndexer = mock(TestIndexer.class);
+ private IssueAuthorizationIndexer issueAuthorizationIndexer = mock(IssueAuthorizationIndexer.class);
+ private IssueIndexer issueIndexer = mock(IssueIndexer.class);
+ private UserIndexer userIndexer = mock(UserIndexer.class);
+ private ViewIndexer viewIndexer = mock(ViewIndexer.class);
+ private ActivityIndexer activityIndexer = mock(ActivityIndexer.class);
+ private EsIndexerEnabler underTest = new EsIndexerEnabler(testIndexer, issueAuthorizationIndexer, issueIndexer, userIndexer, viewIndexer, activityIndexer);
+
+ @Test
+ public void start_enables_all_indexers() {
+ underTest.start();
+
+ verify(testIndexer).setEnabled(true);
+ verify(issueAuthorizationIndexer).setEnabled(true);
+ verify(issueIndexer).setEnabled(true);
+ verify(userIndexer).setEnabled(true);
+ verify(viewIndexer).setEnabled(true);
+ verify(activityIndexer).setEnabled(true);
+ }
+}