diff options
author | Eric Giffon <eric.giffon@sonarsource.com> | 2024-09-23 15:58:45 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-10-09 20:02:46 +0000 |
commit | a79666b02068f247ea26944d3ea0d0181365c3b7 (patch) | |
tree | 0a90e171f965d6257040150ec99cacceb9cfb4f8 /server/sonar-db-dao/src/main/java/org/sonar | |
parent | 449c62b7f35b191a320f8cfd7d378539c6864a51 (diff) | |
download | sonarqube-a79666b02068f247ea26944d3ea0d0181365c3b7.tar.gz sonarqube-a79666b02068f247ea26944d3ea0d0181365c3b7.zip |
SONAR-22879 Remove code related to live_measures table
Diffstat (limited to 'server/sonar-db-dao/src/main/java/org/sonar')
11 files changed, 0 insertions, 398 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java index c0852b111a5..2913c653a97 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java @@ -50,7 +50,6 @@ import org.sonar.db.issue.AnticipatedTransitionDao; import org.sonar.db.issue.IssueChangeDao; import org.sonar.db.issue.IssueDao; import org.sonar.db.issue.IssueFixedDao; -import org.sonar.db.measure.LiveMeasureDao; import org.sonar.db.measure.MeasureDao; import org.sonar.db.measure.ProjectMeasureDao; import org.sonar.db.metric.MetricDao; @@ -155,7 +154,6 @@ public class DaoModule extends Module { IssueFixedDao.class, IssuesDependencyDao.class, MeasureDao.class, - LiveMeasureDao.class, ProjectMeasureDao.class, MetricDao.class, NewCodePeriodDao.class, diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java index 200f3547cb4..46cb3d67623 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java @@ -50,7 +50,6 @@ import org.sonar.db.issue.AnticipatedTransitionDao; import org.sonar.db.issue.IssueChangeDao; import org.sonar.db.issue.IssueDao; import org.sonar.db.issue.IssueFixedDao; -import org.sonar.db.measure.LiveMeasureDao; import org.sonar.db.measure.MeasureDao; import org.sonar.db.measure.ProjectMeasureDao; import org.sonar.db.metric.MetricDao; @@ -177,7 +176,6 @@ public class DbClient { private final AnalysisPropertiesDao analysisPropertiesDao; private final QProfileEditUsersDao qProfileEditUsersDao; private final QProfileEditGroupsDao qProfileEditGroupsDao; - private final LiveMeasureDao liveMeasureDao; private final WebhookDao webhookDao; private final WebhookDeliveryDao webhookDeliveryDao; private final NewCodePeriodDao newCodePeriodDao; @@ -276,7 +274,6 @@ public class DbClient { analysisPropertiesDao = getDao(map, AnalysisPropertiesDao.class); qProfileEditUsersDao = getDao(map, QProfileEditUsersDao.class); qProfileEditGroupsDao = getDao(map, QProfileEditGroupsDao.class); - liveMeasureDao = getDao(map, LiveMeasureDao.class); webhookDao = getDao(map, WebhookDao.class); webhookDeliveryDao = getDao(map, WebhookDeliveryDao.class); internalComponentPropertiesDao = getDao(map, InternalComponentPropertiesDao.class); @@ -580,10 +577,6 @@ public class DbClient { return qProfileEditGroupsDao; } - public LiveMeasureDao liveMeasureDao() { - return liveMeasureDao; - } - protected <K extends Dao> K getDao(Map<Class, Dao> map, Class<K> clazz) { return (K) map.get(clazz); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index 9aafec712ab..6239cb6bde9 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -88,7 +88,6 @@ import org.sonar.db.issue.IssueMapper; import org.sonar.db.issue.NewCodeReferenceIssueDto; import org.sonar.db.issue.PrIssueDto; import org.sonar.db.measure.LargestBranchNclocDto; -import org.sonar.db.measure.LiveMeasureMapper; import org.sonar.db.measure.MeasureMapper; import org.sonar.db.measure.ProjectLocDistributionDto; import org.sonar.db.measure.ProjectMeasureDto; @@ -296,7 +295,6 @@ public class MyBatis { ComponentMapper.class, CveMapper.class, CveCweMapper.class, - LiveMeasureMapper.class, DefaultQProfileMapper.class, DuplicationMapper.class, EntityMapper.class, diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureComparator.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureComparator.java deleted file mode 100644 index 6ebe886adf9..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureComparator.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info 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.db.measure; - -import java.util.Comparator; - -public enum LiveMeasureComparator implements Comparator<LiveMeasureDto> { - INSTANCE; - - @Override - public int compare(LiveMeasureDto o1, LiveMeasureDto o2) { - int componentUuidComp = o1.getComponentUuid().compareTo(o2.getComponentUuid()); - if (componentUuidComp != 0) { - return componentUuidComp; - } - return o1.getMetricUuid().compareTo(o2.getMetricUuid()); - } -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java deleted file mode 100644 index be285e98e4a..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info 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.db.measure; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import org.sonar.api.utils.System2; -import org.sonar.core.util.Uuids; -import org.sonar.db.Dao; -import org.sonar.db.DbSession; -import org.sonar.db.dialect.Dialect; - -import static org.sonar.db.DatabaseUtils.executeLargeInputs; - -public class LiveMeasureDao implements Dao { - - private final System2 system2; - - public LiveMeasureDao(System2 system2) { - this.system2 = system2; - } - - public List<LiveMeasureDto> selectByComponentUuidsAndMetricUuids(DbSession dbSession, Collection<String> largeComponentUuids, Collection<String> metricUuids) { - if (largeComponentUuids.isEmpty() || metricUuids.isEmpty()) { - return Collections.emptyList(); - } - - return executeLargeInputs( - largeComponentUuids, - componentUuids -> mapper(dbSession).selectByComponentUuidsAndMetricUuids(componentUuids, metricUuids)); - } - - public Optional<LiveMeasureDto> selectMeasure(DbSession dbSession, String componentUuid, String metricKey) { - LiveMeasureDto liveMeasureDto = mapper(dbSession).selectByComponentUuidAndMetricKey(componentUuid, metricKey); - return Optional.ofNullable(liveMeasureDto); - } - - public void insert(DbSession dbSession, LiveMeasureDto dto) { - mapper(dbSession).insert(dto, Uuids.create(), system2.now()); - } - - public void insertOrUpdate(DbSession dbSession, LiveMeasureDto dto) { - LiveMeasureMapper mapper = mapper(dbSession); - long now = system2.now(); - if (mapper.update(dto, now) == 0) { - mapper.insert(dto, Uuids.create(), now); - } - } - - /** - * Similar to {@link #insertOrUpdate(DbSession, LiveMeasureDto)}, except that it triggers a single SQL request - * <strong>This method should not be called unless {@link Dialect#supportsUpsert()} is true</strong> - */ - public int upsert(DbSession dbSession, LiveMeasureDto dto) { - dto.setUuidForUpsert(Uuids.create()); - return mapper(dbSession).upsert(dto, system2.now()); - } - - public void deleteByComponentUuidExcludingMetricUuids(DbSession dbSession, String componentUuid, List<String> excludedMetricUuids) { - mapper(dbSession).deleteByComponentUuidExcludingMetricUuids(componentUuid, excludedMetricUuids); - } - - private static LiveMeasureMapper mapper(DbSession dbSession) { - return dbSession.getMapper(LiveMeasureMapper.class); - } -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDto.java deleted file mode 100644 index eb60db3dc2d..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDto.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info 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.db.measure; - -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class LiveMeasureDto { - - private static final int MAX_TEXT_VALUE_LENGTH = 4000; - - /** - * UUID generated only for UPSERT statements in PostgreSQL. It's never used - * in SELECT or regular INSERT/UPDATE. - */ - @Nullable - private String uuidForUpsert; - - private String componentUuid; - private String projectUuid; - private String metricUuid; - @Nullable - private Double value; - @Nullable - private String textValue; - @Nullable - private byte[] data; - - void setUuidForUpsert(@Nullable String s) { - this.uuidForUpsert = s; - } - - public String getComponentUuid() { - return componentUuid; - } - - public LiveMeasureDto setComponentUuid(String s) { - this.componentUuid = s; - return this; - } - - public String getProjectUuid() { - return projectUuid; - } - - public LiveMeasureDto setProjectUuid(String s) { - this.projectUuid = s; - return this; - } - - public String getMetricUuid() { - return metricUuid; - } - - public LiveMeasureDto setMetricUuid(String uuid) { - this.metricUuid = uuid; - return this; - } - - @CheckForNull - public Double getValue() { - return value; - } - - public LiveMeasureDto setValue(@Nullable Double value) { - this.value = value; - return this; - } - - @CheckForNull - public String getTextValue() { - return textValue; - } - - @CheckForNull - public byte[] getData() { - return data; - } - - @CheckForNull - public String getDataAsString() { - if (data != null) { - return new String(data, StandardCharsets.UTF_8); - } - return textValue; - } - - public LiveMeasureDto setData(@Nullable String data) { - if (data == null) { - this.textValue = null; - this.data = null; - } else if (data.length() > MAX_TEXT_VALUE_LENGTH) { - this.textValue = null; - this.data = data.getBytes(StandardCharsets.UTF_8); - } else { - this.textValue = data; - this.data = null; - } - return this; - } - - public LiveMeasureDto setData(@Nullable byte[] data) { - this.textValue = null; - this.data = data; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("LiveMeasureDto{"); - sb.append("componentUuid='").append(componentUuid).append('\''); - sb.append(", projectUuid='").append(projectUuid).append('\''); - sb.append(", metricUuid=").append(metricUuid); - sb.append(", value=").append(value); - sb.append(", textValue='").append(textValue).append('\''); - sb.append(", data=").append(Arrays.toString(data)); - sb.append('}'); - return sb.toString(); - } -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java deleted file mode 100644 index 691168ad52e..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info 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.db.measure; - -import java.util.Collection; -import java.util.List; -import javax.annotation.CheckForNull; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.session.ResultHandler; - -public interface LiveMeasureMapper { - - List<LiveMeasureDto> selectByComponentUuidsAndMetricUuids( - @Param("componentUuids") Collection<String> componentUuids, - @Param("metricUuids") Collection<String> metricUuids); - - LiveMeasureDto selectByComponentUuidAndMetricKey( - @Param("componentUuid") String componentUuid, - @Param("metricKey") String metricKey); - - void insert( - @Param("dto") LiveMeasureDto dto, - @Param("uuid") String uuid, - @Param("now") long now); - - int update( - @Param("dto") LiveMeasureDto dto, - @Param("now") long now); - - int upsert( - @Param("dto") LiveMeasureDto dto, - @Param("now") long now); - - void deleteByComponentUuidExcludingMetricUuids( - @Param("componentUuid") String componentUuid, - @Param("excludedMetricUuids") List<String> excludedMetricUuids); - -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMainBranchLiveMeasureDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMainBranchLiveMeasureDto.java deleted file mode 100644 index 6644b1245bb..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMainBranchLiveMeasureDto.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info 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.db.measure; - -import javax.annotation.Nullable; - -public class ProjectMainBranchLiveMeasureDto { - private String projectUuid; - private String metricUuid; - @Nullable - private Double value; - @Nullable - private String textValue; - - public String getProjectUuid() { - return projectUuid; - } - - @Nullable - public Double getValue() { - return value; - } - - @Nullable - public String getTextValue() { - return textValue; - } - - public String getMetricUuid() { - return metricUuid; - } -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java index 68f55067421..696ad185515 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java @@ -158,15 +158,6 @@ class PurgeCommands { }); profiler.stop(); - profiler.start("purgeDisabledComponents (live_measures)"); - executeLargeInputs( - purgeMapper.selectDisabledComponentsWithLiveMeasures(rootComponentUuid), - input -> { - purgeMapper.deleteLiveMeasuresByComponentUuids(input); - return input; - }); - profiler.stop(); - profiler.start("purgeDisabledComponents (measures)"); executeLargeInputs( purgeMapper.selectDisabledComponentsWithMeasures(rootComponentUuid), @@ -458,13 +449,6 @@ class PurgeCommands { profiler.stop(); } - void deleteLiveMeasures(String rootUuid) { - profiler.start("deleteLiveMeasures (live_measures)"); - purgeMapper.deleteLiveMeasuresByProjectUuid(rootUuid); - session.commit(); - profiler.stop(); - } - void deleteMeasures(String rootUuid) { profiler.start("deleteMeasures (measures)"); purgeMapper.deleteMeasuresByBranchUuid(rootUuid); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java index 51e06e94f90..36bf5417a30 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -271,7 +271,6 @@ public class PurgeDao implements Dao { commands.deleteFileSources(branchUuid); commands.deleteCeActivity(branchUuid); commands.deleteCeQueue(branchUuid); - commands.deleteLiveMeasures(branchUuid); commands.deleteMeasures(branchUuid); commands.deleteNewCodePeriodsForBranch(branchUuid); commands.deleteBranch(branchUuid); @@ -295,7 +294,6 @@ public class PurgeDao implements Dao { commands.deleteCeQueue(projectUuid); commands.deleteWebhooks(projectUuid); commands.deleteWebhookDeliveries(projectUuid); - commands.deleteLiveMeasures(projectUuid); commands.deleteMeasures(projectUuid); commands.deleteProjectAlmSettings(projectUuid); commands.deletePermissions(projectUuid); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java index 6053dc0fe32..00c96ee50bd 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java @@ -38,8 +38,6 @@ public interface PurgeMapper { Set<String> selectDisabledComponentsWithUnresolvedIssues(@Param("branchUuid") String branchUuid); - Set<String> selectDisabledComponentsWithLiveMeasures(@Param("branchUuid") String branchUuid); - Set<String> selectDisabledComponentsWithMeasures(@Param("branchUuid") String branchUuid); void deleteAnalyses(@Param("analysisUuids") List<String> analysisUuids); @@ -169,12 +167,8 @@ public interface PurgeMapper { void deleteBranchByUuid(@Param("uuid") String uuid); - void deleteLiveMeasuresByProjectUuid(@Param("projectUuid") String projectUuid); - void deleteMeasuresByBranchUuid(@Param("branchUuid") String branchUuid); - void deleteLiveMeasuresByComponentUuids(@Param("componentUuids") List<String> componentUuids); - void deleteMeasuresByComponentUuids(@Param("componentUuids") List<String> componentUuids); void deleteNewCodePeriodsByProjectUuid(String projectUuid); |