Browse Source

add Module for ElasticSearch components

tags/5.2-RC1
Sébastien Lesaint 9 years ago
parent
commit
2d666dab30

+ 4
- 10
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java View File

@@ -19,6 +19,8 @@
*/
package org.sonar.server.platform.platformlevel;

import java.util.Properties;
import javax.annotation.Nullable;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.internal.TempFolderCleaner;
import org.sonar.core.config.CorePropertyDefinitions;
@@ -44,7 +46,6 @@ import org.sonar.server.db.DatabaseChecker;
import org.sonar.server.db.DbClient;
import org.sonar.server.db.EmbeddedDatabaseFactory;
import org.sonar.server.db.migrations.MigrationSteps;
import org.sonar.server.es.EsClient;
import org.sonar.server.event.db.EventDao;
import org.sonar.server.issue.db.IssueDao;
import org.sonar.server.issue.index.IssueIndex;
@@ -63,19 +64,14 @@ import org.sonar.server.ruby.PlatformRackBridge;
import org.sonar.server.rule.db.RuleDao;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleNormalizer;
import org.sonar.server.search.IndexClient;
import org.sonar.server.search.EsSearchModule;
import org.sonar.server.search.IndexQueue;
import org.sonar.server.search.SearchClient;
import org.sonar.server.source.db.FileSourceDao;
import org.sonar.server.user.ThreadLocalUserSession;
import org.sonar.server.user.db.GroupDao;
import org.sonar.server.user.db.UserDao;
import org.sonar.server.user.db.UserGroupDao;

import javax.annotation.Nullable;

import java.util.Properties;

public class PlatformLevel1 extends PlatformLevel {
private final Platform platform;
private final Properties properties;
@@ -122,9 +118,7 @@ public class PlatformLevel1 extends PlatformLevel {
DbClient.class,

// Elasticsearch
SearchClient.class,
IndexClient.class,
EsClient.class,
EsSearchModule.class,

// users
GroupDao.class,

+ 33
- 0
server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java View File

@@ -0,0 +1,33 @@
/*
* 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.sonar.core.component.Module;
import org.sonar.server.es.EsClient;

public class EsSearchModule extends Module {
@Override
protected void configureModule() {
add(
SearchClient.class,
IndexClient.class,
EsClient.class);
}
}

+ 35
- 0
server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java View File

@@ -0,0 +1,35 @@
/*
* 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.junit.Test;
import org.sonar.core.platform.ComponentContainer;

import static org.assertj.core.api.Assertions.assertThat;

public class EsSearchModuleTest {
@Test
public void verify_count_of_added_components() throws Exception {
ComponentContainer container = new ComponentContainer();
new EsSearchModule().configure(container);
assertThat(container.size()).isEqualTo(5);
}

}

+ 4
- 0
sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java View File

@@ -260,4 +260,8 @@ public class ComponentContainer {
public MutablePicoContainer getPicoContainer() {
return pico;
}

public int size() {
return pico.getComponentAdapters().size();
}
}

Loading…
Cancel
Save