aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2019-07-25 10:59:37 +0200
committerSonarTech <sonartech@sonarsource.com>2019-07-30 20:24:27 +0200
commit2e9eeb4eb9c26bac7f8df8e568018ab843e95a54 (patch)
tree3b2fe3fb62c4c0026e8405aef827f2e3af4f1060
parent45d3a6430c5baa30721c57207e06c9823bc7d775 (diff)
downloadsonarqube-2e9eeb4eb9c26bac7f8df8e568018ab843e95a54.tar.gz
sonarqube-2e9eeb4eb9c26bac7f8df8e568018ab843e95a54.zip
SONAR-10028 move CeQueueCleaner to Web to support clustering
-rw-r--r--server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueue.java11
-rw-r--r--server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java5
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java6
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java10
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java5
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ce/queue/CeQueueCleaner.java (renamed from server/sonar-ce/src/main/java/org/sonar/ce/queue/CeQueueCleaner.java)12
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java (renamed from server/sonar-server-common/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java)0
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ce/queue/CeQueueCleanerTest.java (renamed from server/sonar-ce/src/test/java/org/sonar/ce/queue/CeQueueCleanerTest.java)5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java (renamed from server/sonar-server-common/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java)0
11 files changed, 30 insertions, 30 deletions
diff --git a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueue.java b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueue.java
index bb1b7281c02..c2bf3568dd6 100644
--- a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueue.java
+++ b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueue.java
@@ -25,6 +25,7 @@ import java.util.Optional;
import javax.annotation.Nullable;
import org.sonar.ce.task.CeTask;
import org.sonar.db.DbSession;
+import org.sonar.db.ce.CeActivityDto;
import org.sonar.db.ce.CeQueueDto;
/**
@@ -112,6 +113,16 @@ public interface CeQueue {
WorkersPauseStatus getWorkersPauseStatus();
+ /**
+ * Removes all the tasks from the queue, whatever their status. They are marked
+ * as {@link CeActivityDto.Status#CANCELED} in past activity.
+ * This method can NOT be called when workers are being executed, as in progress
+ * tasks can't be killed.
+ *
+ * @return the number of canceled tasks
+ */
+ int clear();
+
enum SubmitOption {
UNIQUE_QUEUE_PER_MAIN_COMPONENT
}
diff --git a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
index 39f832f8f30..b9862d298b4 100644
--- a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
+++ b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
@@ -340,6 +340,11 @@ public class CeQueueImpl implements CeQueue {
}
}
+ @Override
+ public int clear() {
+ return cancelAll(true);
+ }
+
CeTask convertToTask(DbSession dbSession, CeQueueDto taskDto, Map<String, String> characteristics, @Nullable ComponentDto component, @Nullable ComponentDto mainComponent) {
CeTask.Builder builder = new CeTask.Builder()
.setUuid(taskDto.getUuid())
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
index 2358876fb0e..19ffc9671e8 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
@@ -59,7 +59,6 @@ import org.sonar.ce.monitoring.DistributedCEQueueStatusImpl;
import org.sonar.ce.platform.CECoreExtensionsInstaller;
import org.sonar.ce.platform.ComputeEngineExtensionInstaller;
import org.sonar.ce.platform.DatabaseCompatibility;
-import org.sonar.ce.queue.CeQueueCleaner;
import org.sonar.ce.queue.PurgeCeActivities;
import org.sonar.ce.task.projectanalysis.ProjectAnalysisTaskModule;
import org.sonar.ce.task.projectanalysis.analysis.ProjectConfigurationFactory;
@@ -117,7 +116,6 @@ import org.sonar.server.notification.email.EmailNotificationChannel;
import org.sonar.server.organization.BillingValidationsProxyImpl;
import org.sonar.server.organization.DefaultOrganizationProviderImpl;
import org.sonar.server.organization.OrganizationFlagsImpl;
-import org.sonar.server.platform.DefaultServerUpgradeStatus;
import org.sonar.server.platform.OfficialDistribution;
import org.sonar.server.platform.ServerFileSystemImpl;
import org.sonar.server.platform.ServerImpl;
@@ -330,7 +328,6 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
// add ReadOnlyPropertiesDao at level2 again so that it shadows PropertiesDao
ReadOnlyPropertiesDao.class,
- DefaultServerUpgradeStatus.class,
// plugins
PluginClassloaderFactory.class,
@@ -485,8 +482,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
private static Object[] startupComponents() {
return new Object[] {
ServerLifecycleNotifier.class,
- PurgeCeActivities.class,
- CeQueueCleaner.class
+ PurgeCeActivities.class
};
}
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java
index c8a06e367b2..44c8561553d 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java
@@ -50,16 +50,6 @@ public interface InternalCeQueue extends CeQueue {
Optional<CeTask> peek(String workerUuid);
/**
- * Removes all the tasks from the queue, whatever their status. They are marked
- * as {@link Status#CANCELED} in past activity.
- * This method can NOT be called when workers are being executed, as in progress
- * tasks can't be killed.
- *
- * @return the number of canceled tasks
- */
- int clear();
-
- /**
* Removes a task from the queue and registers it to past activities. This method
* is called by Compute Engine workers when task is processed and can include an option {@link CeTaskResult} object.
*
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
index 4468e1ab7af..13a424cba7d 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
@@ -104,11 +104,6 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
}
@Override
- public int clear() {
- return cancelAll(true);
- }
-
- @Override
public void remove(CeTask task, CeActivityDto.Status status, @Nullable CeTaskResult taskResult, @Nullable Throwable error) {
checkArgument(error == null || status == CeActivityDto.Status.FAILED, "Error can be provided only when status is FAILED");
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
index e75d0215a3d..68361fe5b64 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
@@ -123,7 +123,7 @@ public class ComputeEngineContainerImplTest {
assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize(
CONTAINER_ITSELF
+ 25 // MigrationConfigurationModule
- + 17 // level 2
+ + 16 // level 2
);
assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize(
COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/CeQueueCleaner.java b/server/sonar-server/src/main/java/org/sonar/server/ce/queue/CeQueueCleaner.java
index 22e2c6bfc00..260f24b5a0f 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/CeQueueCleaner.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ce/queue/CeQueueCleaner.java
@@ -17,34 +17,34 @@
* 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.queue;
+package org.sonar.server.ce.queue;
import java.util.List;
import org.picocontainer.Startable;
-import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.config.Configuration;
import org.sonar.api.platform.ServerUpgradeStatus;
+import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
+import org.sonar.ce.queue.CeQueue;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.process.ProcessProperties;
/**
* Cleans-up the Compute Engine queue.
- * CE workers must not be started before execution of this class.
*/
-@ComputeEngineSide
+@ServerSide
public class CeQueueCleaner implements Startable {
private static final Logger LOGGER = Loggers.get(CeQueueCleaner.class);
private final DbClient dbClient;
private final ServerUpgradeStatus serverUpgradeStatus;
- private final InternalCeQueue queue;
+ private final CeQueue queue;
private final Configuration configuration;
- public CeQueueCleaner(DbClient dbClient, ServerUpgradeStatus serverUpgradeStatus, InternalCeQueue queue, Configuration configuration) {
+ public CeQueueCleaner(DbClient dbClient, ServerUpgradeStatus serverUpgradeStatus, CeQueue queue, Configuration configuration) {
this.dbClient = dbClient;
this.serverUpgradeStatus = serverUpgradeStatus;
this.queue = queue;
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java
index 6948c10225b..6948c10225b 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java
index 38c80290b2a..1fb52415beb 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java
@@ -23,6 +23,7 @@ import org.sonar.api.utils.log.Loggers;
import org.sonar.core.platform.EditionProvider;
import org.sonar.core.platform.PlatformEditionProvider;
import org.sonar.server.app.ProcessCommandWrapper;
+import org.sonar.server.ce.queue.CeQueueCleaner;
import org.sonar.server.es.IndexerStartupTask;
import org.sonar.server.organization.DefaultOrganizationEnforcer;
import org.sonar.server.platform.ServerLifecycleNotifier;
@@ -68,7 +69,8 @@ public class PlatformLevelStartup extends PlatformLevel {
BuiltInQProfileUpdateImpl.class,
RegisterQualityProfiles.class,
RegisterPermissionTemplates.class,
- RenameDeprecatedPropertyKeys.class);
+ RenameDeprecatedPropertyKeys.class,
+ CeQueueCleaner.class);
// RegisterServletFilters makes the WebService engine of Level4 served by the MasterServletFilter, therefor it
// must be started after all the other startup tasks
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/queue/CeQueueCleanerTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/queue/CeQueueCleanerTest.java
index 771b13c21a2..f8c78ae07dc 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/queue/CeQueueCleanerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ce/queue/CeQueueCleanerTest.java
@@ -17,7 +17,7 @@
* 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.queue;
+package org.sonar.server.ce.queue;
import java.util.Optional;
import org.apache.commons.io.IOUtils;
@@ -26,6 +26,7 @@ import org.junit.Test;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.platform.ServerUpgradeStatus;
import org.sonar.api.utils.System2;
+import org.sonar.ce.queue.CeQueue;
import org.sonar.db.DbTester;
import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.ce.CeTaskInputDao;
@@ -44,7 +45,7 @@ public class CeQueueCleanerTest {
public DbTester dbTester = DbTester.create(System2.INSTANCE);
private ServerUpgradeStatus serverUpgradeStatus = mock(ServerUpgradeStatus.class);
- private InternalCeQueue queue = mock(InternalCeQueue.class);
+ private CeQueue queue = mock(CeQueue.class);
private MapSettings settings = new MapSettings();
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java
index 050fc56cbac..050fc56cbac 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java