diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-04-25 11:13:16 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-04-25 11:13:16 +0200 |
commit | ea1b28dd6df6899d79ad1a13b34a1945483f36ee (patch) | |
tree | 7b83cfd828240256360a6de82c5f6530cf2bd795 /sonar-server/src | |
parent | 6c95411c7beea684ba428d44fbf0dbd967f96c0e (diff) | |
download | sonarqube-ea1b28dd6df6899d79ad1a13b34a1945483f36ee.tar.gz sonarqube-ea1b28dd6df6899d79ad1a13b34a1945483f36ee.zip |
SONAR-5007 - Adding new interface for end-to-end ES integration
Diffstat (limited to 'sonar-server/src')
5 files changed, 229 insertions, 0 deletions
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 index 00000000000..d7ffbd5d448 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/cluster/WorkQueue.java @@ -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 index 00000000000..44fd54dd41a --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/db/Dao.java @@ -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 index 00000000000..483a276f175 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/db/Dto.java @@ -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 index 00000000000..8f5c0960992 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/search/Hit.java @@ -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 index 00000000000..a93d2db89e0 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/search/Index.java @@ -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); +} |