aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@searchbox.com>2014-08-20 16:22:33 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-08-20 18:18:38 +0200
commit8e32f1abcb4858f867936a44d66a7030324ae828 (patch)
treef1957d7a300ad43ef5947bab9502f8b9dd643d3f /sonar-core
parent008c1d58cc8e0b6fa077f85a18148233db289a04 (diff)
downloadsonarqube-8e32f1abcb4858f867936a44d66a7030324ae828.tar.gz
sonarqube-8e32f1abcb4858f867936a44d66a7030324ae828.zip
Updated indexQueue mechanism for performance (no compression yet).
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/pom.xml5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/cluster/ClusterAction.java (renamed from sonar-core/src/main/java/org/sonar/core/cluster/QueueAction.java)23
-rw-r--r--sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java10
5 files changed, 17 insertions, 35 deletions
diff --git a/sonar-core/pom.xml b/sonar-core/pom.xml
index bad0f4f5503..34c5d976e5b 100644
--- a/sonar-core/pom.xml
+++ b/sonar-core/pom.xml
@@ -184,6 +184,11 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.elasticsearch</groupId>
+ <artifactId>elasticsearch</artifactId>
+ <version>1.1.2</version>
+ </dependency>
</dependencies>
<build>
diff --git a/sonar-core/src/main/java/org/sonar/core/cluster/QueueAction.java b/sonar-core/src/main/java/org/sonar/core/cluster/ClusterAction.java
index f83078d3bb5..bac9518865f 100644
--- a/sonar-core/src/main/java/org/sonar/core/cluster/QueueAction.java
+++ b/sonar-core/src/main/java/org/sonar/core/cluster/ClusterAction.java
@@ -19,27 +19,10 @@
*/
package org.sonar.core.cluster;
-import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Callable;
-public abstract class QueueAction implements Runnable {
-
- protected CountDownLatch latch;
-
- public QueueAction() {
- this.latch = null;
- }
-
- public void setLatch(CountDownLatch latch){
- this.latch = latch;
- }
-
- public abstract void doExecute();
+public interface ClusterAction<K> extends Callable<K> {
@Override
- public void run(){
- this.doExecute();
- if (latch != null){
- latch.countDown();
- }
- }
+ public K call() throws Exception;
}
diff --git a/sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java b/sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java
index 235d2078fef..cccdf7033bc 100644
--- a/sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java
+++ b/sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java
@@ -21,15 +21,10 @@ package org.sonar.core.cluster;
import java.util.List;
-public class NullQueue implements WorkQueue<QueueAction> {
+public class NullQueue implements WorkQueue<ClusterAction> {
@Override
- public void enqueue(QueueAction action) {
- // do nothing
- }
-
- @Override
- public void enqueue(List<QueueAction> actions) {
+ public void enqueue(List<ClusterAction> actions) {
// do nothing
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java b/sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java
index 9b4141f510d..9d5cf998564 100644
--- a/sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java
+++ b/sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java
@@ -20,10 +20,9 @@
package org.sonar.core.cluster;
import java.util.List;
+import java.util.concurrent.Callable;
-public interface WorkQueue<K extends QueueAction> {
-
- void enqueue(K action);
+public interface WorkQueue<K extends Callable> {
void enqueue(List<K> actions);
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java b/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java
index 10e82b803cc..b663b22e35e 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java
@@ -24,7 +24,7 @@ import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
-import org.sonar.core.cluster.QueueAction;
+import org.sonar.core.cluster.ClusterAction;
import org.sonar.core.cluster.WorkQueue;
import java.sql.Connection;
@@ -34,8 +34,8 @@ import java.util.Map;
public class DbSession implements SqlSession {
- private static final Integer IMPLICIT_COMMIT_SIZE = 200;
- private List<QueueAction> actions;
+ private static final Integer IMPLICIT_COMMIT_SIZE = 1000;
+ private List<ClusterAction> actions;
private WorkQueue queue;
private SqlSession session;
@@ -43,10 +43,10 @@ public class DbSession implements SqlSession {
DbSession(WorkQueue queue, SqlSession session) {
this.session = session;
this.queue = queue;
- this.actions = new ArrayList<QueueAction>();
+ this.actions = new ArrayList<ClusterAction>();
}
- public void enqueue(QueueAction action) {
+ public void enqueue(ClusterAction action) {
this.actions.add(action);
if (this.actions.size() > IMPLICIT_COMMIT_SIZE) {
this.commit();