diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-02-25 22:22:20 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-02 11:02:08 +0100 |
commit | af3d0b3c6b555616b3f6207620dd92360a653996 (patch) | |
tree | 3f48b9d5324e89e40590a7b67c5cf514ef54839e /sonar-batch | |
parent | 4ea0dd1c85069c253e4dbdc1b7c6e203b5beb082 (diff) | |
download | sonarqube-af3d0b3c6b555616b3f6207620dd92360a653996.tar.gz sonarqube-af3d0b3c6b555616b3f6207620dd92360a653996.zip |
Refactor table ANALYSIS_REPORTS because of MySQL packet size limitation
* do not store report zip in table ANALYSIS_REPORTS but in FS dir {home}/data/analysis
* do not store snapshot id in table but in protobuf report
Diffstat (limited to 'sonar-batch')
3 files changed, 14 insertions, 17 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java index 3604685d66f..0a7d97d9ad6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java @@ -48,12 +48,15 @@ public class ComponentsPublisher implements ReportPublisher { @Override public void publish(BatchOutputWriter writer) { BatchResource rootProject = resourceCache.get(reactor.getRoot().getKeyWithBranch()); - BatchReport.Metadata metadata = BatchReport.Metadata.newBuilder() + BatchReport.Metadata.Builder builder = BatchReport.Metadata.newBuilder() .setAnalysisDate(((Project) rootProject.resource()).getAnalysisDate().getTime()) .setProjectKey(((Project) rootProject.resource()).key()) - .setRootComponentRef(rootProject.batchId()) - .build(); - writer.writeMetadata(metadata); + .setRootComponentRef(rootProject.batchId()); + Integer sid = rootProject.snapshotId(); + if (sid != null) { + builder.setSnapshotId(sid); + } + writer.writeMetadata(builder.build()); recursiveWriteComponent(rootProject, writer); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/PublishReportJob.java b/sonar-batch/src/main/java/org/sonar/batch/report/PublishReportJob.java index 17a8c7e4c32..76713e6a747 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/PublishReportJob.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/PublishReportJob.java @@ -33,7 +33,6 @@ import org.sonar.api.utils.TempFolder; import org.sonar.api.utils.ZipUtils; import org.sonar.batch.bootstrap.DefaultAnalysisMode; import org.sonar.batch.bootstrap.ServerClient; -import org.sonar.batch.index.ResourceCache; import org.sonar.batch.protocol.output.BatchOutputWriter; import java.io.File; @@ -50,26 +49,24 @@ public class PublishReportJob implements BatchComponent { private final Settings settings; private final Project project; private final DefaultAnalysisMode analysisMode; - private final ResourceCache resourceCache; private final TempFolder temp; private ReportPublisher[] publishers; public PublishReportJob(Settings settings, ServerClient serverClient, Server server, - Project project, DefaultAnalysisMode analysisMode, TempFolder temp, ResourceCache resourceCache, ReportPublisher[] publishers) { + Project project, DefaultAnalysisMode analysisMode, TempFolder temp, ReportPublisher[] publishers) { this.serverClient = serverClient; this.server = server; this.project = project; this.settings = settings; this.analysisMode = analysisMode; this.temp = temp; - this.resourceCache = resourceCache; this.publishers = publishers; } public PublishReportJob(Settings settings, ServerClient serverClient, Server server, - Project project, DefaultAnalysisMode analysisMode, TempFolder temp, ResourceCache resourceCache) { - this(settings, serverClient, server, project, analysisMode, temp, resourceCache, new ReportPublisher[0]); + Project project, DefaultAnalysisMode analysisMode, TempFolder temp) { + this(settings, serverClient, server, project, analysisMode, temp, new ReportPublisher[0]); } public void execute() { @@ -112,8 +109,7 @@ public class PublishReportJob implements BatchComponent { long startTime = System.currentTimeMillis(); URL url; try { - int snapshotId = resourceCache.get(project.getEffectiveKey()).snapshotId(); - url = new URL(serverClient.getURL() + "/api/computation/submit_report?projectKey=" + project.getEffectiveKey() + "&snapshot=" + snapshotId); + url = new URL(serverClient.getURL() + "/api/computation/submit_report?projectKey=" + project.getEffectiveKey()); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid URL", e); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/PublishReportJobTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/PublishReportJobTest.java index 924f05d25f2..2da52bd2f3d 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/report/PublishReportJobTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/report/PublishReportJobTest.java @@ -32,9 +32,7 @@ import org.sonar.batch.bootstrap.ServerClient; import org.sonar.batch.index.ResourceCache; import org.sonar.jpa.test.AbstractDbUnitTestCase; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; public class PublishReportJobTest extends AbstractDbUnitTestCase { @@ -52,7 +50,7 @@ public class PublishReportJobTest extends AbstractDbUnitTestCase { Settings settings = new Settings(); settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver/"); Project project = new Project("struts"); - PublishReportJob job = new PublishReportJob(settings, mock(ServerClient.class), mock(Server.class), project, mode, mock(TempFolder.class), mock(ResourceCache.class)); + PublishReportJob job = new PublishReportJob(settings, mock(ServerClient.class), mock(Server.class), project, mode, mock(TempFolder.class)); Logger logger = mock(Logger.class); job.logSuccess(logger); @@ -66,7 +64,7 @@ public class PublishReportJobTest extends AbstractDbUnitTestCase { Settings settings = new Settings(); when(mode.isPreview()).thenReturn(true); Project project = new Project("struts"); - PublishReportJob job = new PublishReportJob(settings, mock(ServerClient.class), mock(Server.class), project, mode, mock(TempFolder.class), mock(ResourceCache.class)); + PublishReportJob job = new PublishReportJob(settings, mock(ServerClient.class), mock(Server.class), project, mode, mock(TempFolder.class)); Logger logger = mock(Logger.class); job.logSuccess(logger); |