]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 - Adding new interface for end-to-end ES integration
authorStephane Gamard <stephane.gamard@searchbox.com>
Fri, 25 Apr 2014 09:13:16 +0000 (11:13 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Fri, 25 Apr 2014 09:13:16 +0000 (11:13 +0200)
sonar-server/src/main/java/org/sonar/server/cluster/WorkQueue.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/db/Dao.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/db/Dto.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/search/Hit.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/search/Index.java [new file with mode: 0644]

diff --git a/sonar-server/src/main/java/org/sonar/server/cluster/WorkQueue.java b/sonar-server/src/main/java/org/sonar/server/cluster/WorkQueue.java
new file mode 100644 (file)
index 0000000..d7ffbd5
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.cluster;
+
+import java.io.Serializable;
+
+
+public interface WorkQueue {
+
+  Integer enqueInsert(String indexName, Serializable key);
+
+  Integer enqueUpdate(String indexName, Serializable key);
+
+  Integer enqueDelete(String indexName, Serializable key);
+
+  Serializable dequeInsert(String indexName);
+
+  Serializable dequeUpdate(String indexName);
+
+  Serializable dequeDelete(String indexName);
+
+  Status getStatus(Integer workId);
+
+  interface Status {
+
+  }
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/db/Dao.java b/sonar-server/src/main/java/org/sonar/server/db/Dao.java
new file mode 100644 (file)
index 0000000..44fd54d
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.db;
+
+import java.io.Serializable;
+
+public interface Dao<E extends Dto<K>, K extends Serializable> {
+
+  public E getByKey(K key);
+
+  public E update(E item);
+
+  public E insert(E item);
+
+  public void delete(E item);
+
+  public void deleteByKey(K key);
+
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/db/Dto.java b/sonar-server/src/main/java/org/sonar/server/db/Dto.java
new file mode 100644 (file)
index 0000000..483a276
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.db;
+
+import java.io.Serializable;
+
+public interface Dto<K extends Serializable> {
+
+  K getKey();
+
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/search/Hit.java b/sonar-server/src/main/java/org/sonar/server/search/Hit.java
new file mode 100644 (file)
index 0000000..8f5c096
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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.search;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Hit implements Comparable<Hit> {
+
+  private Map<String, Collection<Serializable>> fields;
+
+  private Integer rank;
+
+  public Hit(Integer rank){
+    this.fields = new HashMap<String, Collection<Serializable>>();
+    this.rank = rank;
+  }
+
+  public Collection<Serializable> getFieldValues(String field){
+    return this.fields.get(field);
+  }
+
+  public Serializable getFieldValue(String field){
+    if(this.hasField(field)){
+      return fields.get(field).iterator().next();
+    } else {
+      return null;
+    }
+  }
+
+  public Hit addFieldValue(String field, Serializable value){
+    if(!this.hasField(field)){
+      this.fields.put(field, new ArrayList<Serializable>());
+    }
+    return this;
+  }
+
+  public boolean hasField(String field){
+    return this.fields.containsKey(field) &&
+      !this.fields.get(field).isEmpty();
+  }
+
+  public Integer getRank(){
+    return this.rank;
+  }
+
+  @Override
+  public int compareTo(Hit hit) {
+    return this.getRank().compareTo(hit.getRank());
+  }
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/search/Index.java b/sonar-server/src/main/java/org/sonar/server/search/Index.java
new file mode 100644 (file)
index 0000000..a93d2db
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.search;
+
+import org.picocontainer.Startable;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+
+public interface Index<K extends Serializable> extends Startable {
+
+  Hit getByKey(K key);
+
+  void insert(K key);
+
+  void udpate(K key);
+
+  void delete(K key);
+
+  K dequeueInsert();
+
+  K dequeueUpdate();
+
+  K dequeueDelete();
+
+  Map<String, Object> normalize(K key);
+
+  Date getLastSynchronization();
+
+  Collection<K> synchronizeSince(Date date);
+}