ComputeEngineProcessingModule will be moved in a separate commit which will refactor CE's modules
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.server.computation;
-
-import java.util.List;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.PropertyType;
-import org.sonar.api.config.PropertyDefinition;
-import org.sonar.server.computation.log.CeLogging;
-
-import static java.util.Arrays.asList;
-
-public class CePropertyDefinitions {
- private CePropertyDefinitions() {
- // only statics
- }
-
- public static List<PropertyDefinition> all() {
- return asList(
- PropertyDefinition.builder(CeLogging.MAX_LOGS_PROPERTY)
- .name("Compute Engine Log Retention")
- .description("Number of tasks to keep logs for a given project. Once the number of logs exceeds this limit, oldest logs are purged.")
- .type(PropertyType.INTEGER)
- .defaultValue("10")
- .category(CoreProperties.CATEGORY_GENERAL)
- .build());
- }
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.server.computation;
-
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.core.util.logs.Profiler;
-import org.sonar.server.computation.step.ComputationStep;
-import org.sonar.server.computation.step.ComputationSteps;
-
-public final class ComputationStepExecutor {
- private static final Logger LOGGER = Loggers.get(ComputationStepExecutor.class);
-
- private final ComputationSteps steps;
-
- public ComputationStepExecutor(ComputationSteps steps) {
- this.steps = steps;
- }
-
- public void execute() {
- Profiler stepProfiler = Profiler.create(LOGGER);
- for (ComputationStep step : steps.instances()) {
- stepProfiler.start();
- step.execute();
- stepProfiler.stopInfo(step.getDescription());
- }
- }
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.server.computation;
-
-import java.io.File;
-import java.io.IOException;
-import javax.annotation.CheckForNull;
-import org.apache.commons.io.FileUtils;
-import org.picocontainer.ComponentLifecycle;
-import org.picocontainer.PicoContainer;
-import org.picocontainer.injectors.ProviderAdapter;
-import org.sonar.api.platform.ServerFileSystem;
-import org.sonar.api.utils.TempFolder;
-import org.sonar.api.utils.internal.DefaultTempFolder;
-
-/**
- * Provides a TempFolder instance pointing to a directory dedicated to the processing of a specific item.
- * This directory will be deleted at the end of the processing.
- * This directory is located in the "ce" directory of the temp directory of the SonarQube instance.
- */
-public class ComputationTempFolderProvider extends ProviderAdapter implements ComponentLifecycle<TempFolder> {
- private boolean started = false;
- @CheckForNull
- private DefaultTempFolder tempFolder;
-
- public TempFolder provide(ServerFileSystem fs) {
- if (this.tempFolder == null) {
- File tempDir = new File(fs.getTempDir(), "ce");
- try {
- FileUtils.forceMkdir(tempDir);
- } catch (IOException e) {
- throw new IllegalStateException("Unable to create computation temp directory " + tempDir, e);
- }
- File computationDir = new DefaultTempFolder(tempDir).newDir();
- this.tempFolder = new DefaultTempFolder(computationDir, true);
- }
- return this.tempFolder;
- }
-
- @Override
- public void start(PicoContainer container) {
- this.started = true;
- }
-
- @Override
- public void stop(PicoContainer container) {
- if (tempFolder != null) {
- tempFolder.stop();
- }
- }
-
- @Override
- public void dispose(PicoContainer container) {
- // nothing to do
- }
-
- @Override
- public boolean componentHasLifecycle() {
- return true;
- }
-
- @Override
- public boolean isStarted() {
- return started;
- }
-
-}
import org.sonar.server.computation.queue.CeProcessingSchedulerImpl;
import org.sonar.server.computation.queue.CeWorkerRunnableImpl;
import org.sonar.server.computation.queue.report.ReportTaskProcessor;
+import org.sonar.server.computation.step.ComputationStepExecutor;
public class ComputeEngineProcessingModule extends Module {
@Override
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.server.computation;
-
-import java.util.Calendar;
-import org.sonar.api.platform.Server;
-import org.sonar.api.platform.ServerStartHandler;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-
-@ServerSide
-public class PurgeCeActivities implements ServerStartHandler {
-
- private static final Logger LOGGER = Loggers.get(PurgeCeActivities.class);
-
- private final DbClient dbClient;
- private final System2 system2;
-
- public PurgeCeActivities(DbClient dbClient, System2 system2) {
- this.dbClient = dbClient;
- this.system2 = system2;
- }
-
- @Override
- public void onServerStart(Server server) {
- DbSession dbSession = dbClient.openSession(false);
- try {
- Calendar sixMonthsAgo = Calendar.getInstance();
- sixMonthsAgo.setTimeInMillis(system2.now());
- sixMonthsAgo.add(Calendar.DATE, -180);
-
- LOGGER.info("Delete the Compute Engine tasks created before " + sixMonthsAgo.getTime());
- dbClient.ceActivityDao().deleteOlderThan(dbSession, sixMonthsAgo.getTimeInMillis());
- dbSession.commit();
-
- } finally {
- dbClient.closeSession(dbSession);
- }
- }
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.server.computation;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.sonar.api.config.Settings;
-import org.sonar.api.server.ServerSide;
-import org.sonar.process.ProcessProperties;
-
-import static java.lang.String.format;
-
-@ServerSide
-public class ReportFiles {
-
- private static final String ZIP_EXTENSION = "zip";
-
- private final Settings settings;
-
- public ReportFiles(Settings settings) {
- this.settings = settings;
- }
-
- public void save(String taskUuid, InputStream reportInput) {
- File file = fileForUuid(taskUuid);
- try {
- FileUtils.copyInputStreamToFile(reportInput, file);
- } catch (Exception e) {
- FileUtils.deleteQuietly(file);
- IOUtils.closeQuietly(reportInput);
- throw new IllegalStateException(format("Fail to copy report to file: %s", file.getAbsolutePath()), e);
- }
- }
-
- public void deleteIfExists(String taskUuid) {
- FileUtils.deleteQuietly(fileForUuid(taskUuid));
- }
-
- public void deleteAll() {
- File dir = reportDir();
- if (dir.exists()) {
- try {
- FileUtils.cleanDirectory(dir);
- } catch (Exception e) {
- throw new IllegalStateException(format("Fail to clean directory: %s", dir.getAbsolutePath()), e);
- }
- }
- }
-
- private File reportDir() {
- return new File(settings.getString(ProcessProperties.PATH_DATA), "ce/reports");
- }
-
- /**
- * The analysis report to be processed. Can't be null
- * but may no exist on file system.
- */
- public File fileForUuid(String taskUuid) {
- return new File(reportDir(), format("%s.%s", taskUuid, ZIP_EXTENSION));
- }
-
- public List<String> listUuids() {
- List<String> uuids = new ArrayList<>();
- File dir = reportDir();
- if (dir.exists()) {
- Collection<File> files = FileUtils.listFiles(dir, new String[]{ZIP_EXTENSION}, false);
- for (File file : files) {
- uuids.add(FilenameUtils.getBaseName(file.getName()));
- }
- }
- return uuids;
- }
-}
import org.sonar.core.issue.tracking.Tracker;
import org.sonar.core.platform.ContainerPopulator;
import org.sonar.server.computation.queue.CeTask;
-import org.sonar.server.computation.ComputationStepExecutor;
-import org.sonar.server.computation.ComputationTempFolderProvider;
+import org.sonar.server.computation.step.ComputationStepExecutor;
+import org.sonar.server.computation.filesystem.ComputationTempFolderProvider;
import org.sonar.server.computation.analysis.ReportAnalysisMetadataHolder;
import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl;
import org.sonar.server.computation.batch.BatchReportReaderImpl;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.computation.filesystem;
+
+import java.io.File;
+import java.io.IOException;
+import javax.annotation.CheckForNull;
+import org.apache.commons.io.FileUtils;
+import org.picocontainer.ComponentLifecycle;
+import org.picocontainer.PicoContainer;
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.platform.ServerFileSystem;
+import org.sonar.api.utils.TempFolder;
+import org.sonar.api.utils.internal.DefaultTempFolder;
+
+/**
+ * Provides a TempFolder instance pointing to a directory dedicated to the processing of a specific item.
+ * This directory will be deleted at the end of the processing.
+ * This directory is located in the "ce" directory of the temp directory of the SonarQube instance.
+ */
+public class ComputationTempFolderProvider extends ProviderAdapter implements ComponentLifecycle<TempFolder> {
+ private boolean started = false;
+ @CheckForNull
+ private DefaultTempFolder tempFolder;
+
+ public TempFolder provide(ServerFileSystem fs) {
+ if (this.tempFolder == null) {
+ File tempDir = new File(fs.getTempDir(), "ce");
+ try {
+ FileUtils.forceMkdir(tempDir);
+ } catch (IOException e) {
+ throw new IllegalStateException("Unable to create computation temp directory " + tempDir, e);
+ }
+ File computationDir = new DefaultTempFolder(tempDir).newDir();
+ this.tempFolder = new DefaultTempFolder(computationDir, true);
+ }
+ return this.tempFolder;
+ }
+
+ @Override
+ public void start(PicoContainer container) {
+ this.started = true;
+ }
+
+ @Override
+ public void stop(PicoContainer container) {
+ if (tempFolder != null) {
+ tempFolder.stop();
+ }
+ }
+
+ @Override
+ public void dispose(PicoContainer container) {
+ // nothing to do
+ }
+
+ @Override
+ public boolean componentHasLifecycle() {
+ return true;
+ }
+
+ @Override
+ public boolean isStarted() {
+ return started;
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.computation.filesystem;
+
+import javax.annotation.ParametersAreNonnullByDefault;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.computation.property;
+
+import java.util.List;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.PropertyType;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.server.computation.log.CeLogging;
+
+import static java.util.Arrays.asList;
+
+public class CePropertyDefinitions {
+ private CePropertyDefinitions() {
+ // only statics
+ }
+
+ public static List<PropertyDefinition> all() {
+ return asList(
+ PropertyDefinition.builder(CeLogging.MAX_LOGS_PROPERTY)
+ .name("Compute Engine Log Retention")
+ .description("Number of tasks to keep logs for a given project. Once the number of logs exceeds this limit, oldest logs are purged.")
+ .type(PropertyType.INTEGER)
+ .defaultValue("10")
+ .category(CoreProperties.CATEGORY_GENERAL)
+ .build());
+ }
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.computation.property;
+
+import javax.annotation.ParametersAreNonnullByDefault;
import org.sonar.db.DbSession;
import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.server.computation.ReportFiles;
+import org.sonar.server.computation.queue.report.ReportFiles;
/**
* Cleans-up the Compute Engine queue and resets the JMX counters.
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.computation.queue;
+
+import java.util.Calendar;
+import org.sonar.api.platform.Server;
+import org.sonar.api.platform.ServerStartHandler;
+import org.sonar.api.server.ServerSide;
+import org.sonar.api.utils.System2;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+
+@ServerSide
+public class PurgeCeActivities implements ServerStartHandler {
+
+ private static final Logger LOGGER = Loggers.get(PurgeCeActivities.class);
+
+ private final DbClient dbClient;
+ private final System2 system2;
+
+ public PurgeCeActivities(DbClient dbClient, System2 system2) {
+ this.dbClient = dbClient;
+ this.system2 = system2;
+ }
+
+ @Override
+ public void onServerStart(Server server) {
+ DbSession dbSession = dbClient.openSession(false);
+ try {
+ Calendar sixMonthsAgo = Calendar.getInstance();
+ sixMonthsAgo.setTimeInMillis(system2.now());
+ sixMonthsAgo.add(Calendar.DATE, -180);
+
+ LOGGER.info("Delete the Compute Engine tasks created before " + sixMonthsAgo.getTime());
+ dbClient.ceActivityDao().deleteOlderThan(dbSession, sixMonthsAgo.getTimeInMillis());
+ dbSession.commit();
+
+ } finally {
+ dbClient.closeSession(dbSession);
+ }
+ }
+}
package org.sonar.server.computation.queue.report;
import org.sonar.db.ce.CeActivityDto;
-import org.sonar.server.computation.ReportFiles;
import org.sonar.server.computation.queue.CeQueueListener;
import org.sonar.server.computation.queue.CeTask;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.computation.queue.report;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.sonar.api.config.Settings;
+import org.sonar.api.server.ServerSide;
+import org.sonar.process.ProcessProperties;
+
+import static java.lang.String.format;
+
+@ServerSide
+public class ReportFiles {
+
+ private static final String ZIP_EXTENSION = "zip";
+
+ private final Settings settings;
+
+ public ReportFiles(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void save(String taskUuid, InputStream reportInput) {
+ File file = fileForUuid(taskUuid);
+ try {
+ FileUtils.copyInputStreamToFile(reportInput, file);
+ } catch (Exception e) {
+ FileUtils.deleteQuietly(file);
+ IOUtils.closeQuietly(reportInput);
+ throw new IllegalStateException(format("Fail to copy report to file: %s", file.getAbsolutePath()), e);
+ }
+ }
+
+ public void deleteIfExists(String taskUuid) {
+ FileUtils.deleteQuietly(fileForUuid(taskUuid));
+ }
+
+ public void deleteAll() {
+ File dir = reportDir();
+ if (dir.exists()) {
+ try {
+ FileUtils.cleanDirectory(dir);
+ } catch (Exception e) {
+ throw new IllegalStateException(format("Fail to clean directory: %s", dir.getAbsolutePath()), e);
+ }
+ }
+ }
+
+ private File reportDir() {
+ return new File(settings.getString(ProcessProperties.PATH_DATA), "ce/reports");
+ }
+
+ /**
+ * The analysis report to be processed. Can't be null
+ * but may no exist on file system.
+ */
+ public File fileForUuid(String taskUuid) {
+ return new File(reportDir(), format("%s.%s", taskUuid, ZIP_EXTENSION));
+ }
+
+ public List<String> listUuids() {
+ List<String> uuids = new ArrayList<>();
+ File dir = reportDir();
+ if (dir.exists()) {
+ Collection<File> files = FileUtils.listFiles(dir, new String[]{ZIP_EXTENSION}, false);
+ for (File file : files) {
+ uuids.add(FilenameUtils.getBaseName(file.getName()));
+ }
+ }
+ return uuids;
+ }
+}
import org.sonar.db.component.ComponentDto;
import org.sonar.server.component.ComponentService;
import org.sonar.server.component.NewComponent;
-import org.sonar.server.computation.ReportFiles;
import org.sonar.server.computation.queue.CeQueue;
import org.sonar.server.computation.queue.CeTask;
import org.sonar.server.computation.queue.CeTaskSubmit;
package org.sonar.server.computation.queue.report;
import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.computation.ComputationStepExecutor;
+import org.sonar.server.computation.step.ComputationStepExecutor;
import org.sonar.server.computation.container.ComputeEngineContainer;
import org.sonar.server.computation.container.ContainerFactory;
import org.sonar.server.computation.queue.CeTask;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.computation.step;
+
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.core.util.logs.Profiler;
+
+public final class ComputationStepExecutor {
+ private static final Logger LOGGER = Loggers.get(ComputationStepExecutor.class);
+
+ private final ComputationSteps steps;
+
+ public ComputationStepExecutor(ComputationSteps steps) {
+ this.steps = steps;
+ }
+
+ public void execute() {
+ Profiler stepProfiler = Profiler.create(LOGGER);
+ for (ComputationStep step : steps.instances()) {
+ stepProfiler.start();
+ step.execute();
+ stepProfiler.stopInfo(step.getDescription());
+ }
+ }
+}
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.server.computation.queue.CeTask;
-import org.sonar.server.computation.ReportFiles;
+import org.sonar.server.computation.queue.report.ReportFiles;
import org.sonar.server.computation.batch.MutableBatchReportDirectoryHolder;
/**
import org.sonar.db.semaphore.SemaphoresImpl;
import org.sonar.db.version.DatabaseVersion;
import org.sonar.db.version.MigrationStepModule;
-import org.sonar.server.computation.CePropertyDefinitions;
+import org.sonar.server.computation.property.CePropertyDefinitions;
import org.sonar.server.db.DbClient;
import org.sonar.server.db.EmbeddedDatabaseFactory;
import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.computation.queue.CeQueueInitializer;
import org.sonar.server.computation.queue.report.CleanReportQueueListener;
import org.sonar.server.computation.ComputeEngineProcessingModule;
-import org.sonar.server.computation.ReportFiles;
+import org.sonar.server.computation.queue.report.ReportFiles;
import org.sonar.server.computation.queue.report.ReportSubmitter;
import org.sonar.server.computation.dbcleaner.IndexPurgeListener;
import org.sonar.server.computation.dbcleaner.ProjectCleaner;
*/
package org.sonar.server.platform.platformlevel;
-import org.sonar.server.computation.PurgeCeActivities;
+import org.sonar.server.computation.queue.PurgeCeActivities;
import org.sonar.server.issue.filter.RegisterIssueFilters;
import org.sonar.server.platform.ServerLifecycleNotifier;
import org.sonar.server.qualitygate.RegisterQualityGates;
package org.sonar.server.computation;
import org.junit.Test;
+import org.sonar.server.computation.property.CePropertyDefinitions;
import org.sonar.test.TestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import org.sonar.db.DbTester;
import org.sonar.db.ce.CeActivityDto;
import org.sonar.db.ce.CeQueueDto;
+import org.sonar.server.computation.queue.PurgeCeActivities;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.config.Settings;
import org.sonar.process.ProcessProperties;
+import org.sonar.server.computation.queue.report.ReportFiles;
import static org.assertj.core.api.Assertions.assertThat;
import org.sonar.db.DbTester;
import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.server.computation.ReportFiles;
-import org.sonar.server.computation.queue.CeQueueCleaner;
-import org.sonar.server.computation.queue.CeQueueImpl;
+import org.sonar.server.computation.queue.report.ReportFiles;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import org.sonar.db.DbTester;
import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.server.computation.ReportFiles;
+import org.sonar.server.computation.queue.report.ReportFiles;
import org.sonar.server.computation.monitoring.CEQueueStatus;
import org.sonar.server.computation.monitoring.CEQueueStatusImpl;
-import org.sonar.server.computation.queue.CeProcessingScheduler;
-import org.sonar.server.computation.queue.CeQueueCleaner;
-import org.sonar.server.computation.queue.CeQueueInitializer;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import org.junit.Test;
import org.sonar.db.ce.CeActivityDto;
import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.server.computation.ReportFiles;
import org.sonar.server.computation.queue.CeTask;
import static org.mockito.Mockito.mock;
import org.sonar.db.component.ComponentDto;
import org.sonar.server.component.ComponentService;
import org.sonar.server.component.NewComponent;
-import org.sonar.server.computation.ReportFiles;
import org.sonar.server.computation.queue.CeQueue;
import org.sonar.server.computation.queue.CeQueueImpl;
import org.sonar.server.computation.queue.CeTaskSubmit;