diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-02 13:27:28 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-03 21:03:39 +0100 |
commit | 82faa625e3e6471335321b5d5fb2258809afaa13 (patch) | |
tree | 03cf62e4c1407fc10a25306aca48c3f6a5782401 /sonar-core/src | |
parent | b88fd7049dd271e115bbc1f48b49e5d830ee6ef9 (diff) | |
download | sonarqube-82faa625e3e6471335321b5d5fb2258809afaa13.tar.gz sonarqube-82faa625e3e6471335321b5d5fb2258809afaa13.zip |
SONAR-6229 Indexing of activity logs consumes too much memory during server startup
Diffstat (limited to 'sonar-core/src')
6 files changed, 26 insertions, 184 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/activity/Activity.java b/sonar-core/src/main/java/org/sonar/core/activity/Activity.java deleted file mode 100644 index c5ede01df71..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/activity/Activity.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.core.activity; - -import java.util.Date; -import java.util.Map; - -/** - * @since 4.4 - */ -public interface Activity { - - Type type(); - - String action(); - - Date time(); - - String login(); - - Map<String, String> details(); - - String message(); - - public static enum Type { - NONE, QPROFILE, SERVER, ANALYSIS_REPORT - } - -} diff --git a/sonar-core/src/main/java/org/sonar/core/activity/ActivityLog.java b/sonar-core/src/main/java/org/sonar/core/activity/ActivityLog.java deleted file mode 100644 index 9b0a7f54a24..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/activity/ActivityLog.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.core.activity; - -import java.util.Map; - -/** - * @since 4.4 - */ -public interface ActivityLog { - - Map<String, String> getDetails(); - - public String getAction(); - -} diff --git a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java index 517f0e998a7..298b88faef9 100644 --- a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java +++ b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java @@ -21,44 +21,42 @@ package org.sonar.core.activity.db; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.api.utils.KeyValueFormat; -import org.sonar.api.utils.internal.Uuids; -import org.sonar.core.activity.Activity; -import org.sonar.core.activity.ActivityLog; -import org.sonar.core.persistence.Dto; - -/** - * @since 4.4 - */ -public final class ActivityDto extends Dto<String> { + +import java.util.Date; + +public class ActivityDto { private String key; private String message; - private Activity.Type type; + private String type; private String action; private String author; - private String data; + private Date createdAt; - protected ActivityDto() { - this.key = Uuids.create(); + public ActivityDto setKey(String key) { + this.key = key; + return this; } - @Override public String getKey() { return key; } - @Override - public String toString() { - return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); + public Date getCreatedAt() { + return createdAt; + } + + public ActivityDto setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; } - public Activity.Type getType() { + public String getType() { return type; } - public ActivityDto setType(Activity.Type type) { + public ActivityDto setType(String type) { this.type = type; return this; } @@ -99,21 +97,8 @@ public final class ActivityDto extends Dto<String> { return this; } - public static ActivityDto createFor(String message) { - return new ActivityDto() - .setMessage(message); - } - - public static ActivityDto createFor(String action, String message) { - return new ActivityDto() - .setAction(action) - .setMessage(message); - } - - public static ActivityDto createFor(ActivityLog activityLog) { - return new ActivityDto() - .setAction(activityLog.getAction()) - .setData(KeyValueFormat.format(activityLog.getDetails())); - + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); } } diff --git a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityMapper.java b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityMapper.java index d7f5959c422..175bef8bc30 100644 --- a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityMapper.java @@ -19,21 +19,8 @@ */ package org.sonar.core.activity.db; -import org.apache.ibatis.annotations.Param; - -import javax.annotation.Nullable; - -import java.sql.Timestamp; -import java.util.List; - -/** - * @since 4.4 - */ public interface ActivityMapper { - void insert(ActivityDto rule); - - List<ActivityDto> selectAll(); + void insert(ActivityDto dto); - List<ActivityDto> selectAfterDate(@Nullable @Param("date") Timestamp timestamp); } diff --git a/sonar-core/src/main/java/org/sonar/core/activity/package-info.java b/sonar-core/src/main/java/org/sonar/core/activity/package-info.java deleted file mode 100644 index 8c6baa92aa2..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/activity/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.core.activity; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-core/src/main/resources/org/sonar/core/activity/db/ActivityMapper.xml b/sonar-core/src/main/resources/org/sonar/core/activity/db/ActivityMapper.xml index fecd0b0210f..c3de19773b6 100644 --- a/sonar-core/src/main/resources/org/sonar/core/activity/db/ActivityMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/activity/db/ActivityMapper.xml @@ -3,40 +3,13 @@ <mapper namespace="org.sonar.core.activity.db.ActivityMapper"> - <insert id="insert" parameterType="Activity" useGeneratedKeys="false" > + <insert id="insert" parameterType="Activity" useGeneratedKeys="false"> insert into activities (created_at, log_key, log_type, log_action, user_login, data_field, log_message) - values (#{createdAt}, #{key}, #{type}, #{action}, #{author}, #{data}, #{message}) + values (#{createdAt,jdbcType=TIMESTAMP}, #{key,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, + #{action,jdbcType=VARCHAR}, + #{author,jdbcType=VARCHAR}, #{data,jdbcType=VARCHAR}, #{message,jdbcType=VARCHAR}) </insert> - <select id="selectAll" parameterType="map" resultType="Activity" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY"> - SELECT - created_at as "createdAt", - log_type as "type", - user_login as "author", - data_field as "data", - log_message as "message", - log_key as "key", - log_action as "action" - FROM activities - </select> - - - <select id="selectAfterDate" parameterType="map" resultType="Activity" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY"> - SELECT - created_at as "createdAt", - log_type as "type", - user_login as "author", - data_field as "data", - log_message as "message", - log_key as "key", - log_action as "action" - FROM activities - <where> - <if test="date != null"> - created_at >= #{date} - </if> - </where> - </select> </mapper> |