Search in sources :

Example 21 with LuceneServerConfiguration

use of com.yelp.nrtsearch.server.config.LuceneServerConfiguration in project nrtsearch by Yelp.

the class LuceneServerTestConfigurationFactory method getConfig.

public static LuceneServerConfiguration getConfig(Mode mode, File dataRootDir, Path archiverDirectory, String extraConfig) {
    String dirNum = String.valueOf(atomicLong.addAndGet(1));
    if (mode.equals(Mode.STANDALONE)) {
        String stateDir = Paths.get(dataRootDir.getAbsolutePath(), "standalone", dirNum, "state").toString();
        String indexDir = Paths.get(dataRootDir.getAbsolutePath(), "standalone", dirNum, "index").toString();
        String config = String.join("\n", "nodeName: standalone", "stateDir: " + stateDir, "indexDir: " + indexDir, "port: " + (9700 + atomicLong.intValue()), "replicationPort: " + (17000 + atomicLong.intValue()), "archiveDirectory: " + archiverDirectory.toString(), extraConfig);
        return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes()));
    } else if (mode.equals(Mode.PRIMARY)) {
        String stateDir = Paths.get(dataRootDir.getAbsolutePath(), "primary", dirNum, "state").toString();
        String indexDir = Paths.get(dataRootDir.getAbsolutePath(), "primary", dirNum, "index").toString();
        String config = String.join("\n", "nodeName: primary", "stateDir: " + stateDir, "indexDir: " + indexDir, "port: " + 9900, "replicationPort: " + 9001, "archiveDirectory: " + archiverDirectory.toString(), extraConfig);
        return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes()));
    } else if (mode.equals(Mode.REPLICA)) {
        String stateDir = Paths.get(dataRootDir.getAbsolutePath(), "replica", dirNum, "state").toString();
        String indexDir = Paths.get(dataRootDir.getAbsolutePath(), "replica", dirNum, "index").toString();
        String config = String.join("\n", "nodeName: replica", "stateDir: " + stateDir, "indexDir: " + indexDir, "port: " + 9902, "replicationPort: " + 9003, extraConfig);
        return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes()));
    }
    throw new RuntimeException("Invalid mode %s, cannot build config" + mode);
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 22 with LuceneServerConfiguration

use of com.yelp.nrtsearch.server.config.LuceneServerConfiguration in project nrtsearch by Yelp.

the class PluginsServiceTest method testGetMultiPluginSearchPath.

@Test
public void testGetMultiPluginSearchPath() {
    String searchPath = "some1/plugin1/path1" + File.pathSeparator + "some2/plugin2/path2" + File.pathSeparator + "some3/plugin3/path3" + File.pathSeparator;
    LuceneServerConfiguration config = getConfigWithSearchPath(searchPath);
    PluginsService pluginsService = new PluginsService(config);
    List<File> expectedPaths = new ArrayList<>();
    expectedPaths.add(new File("some1/plugin1/path1"));
    expectedPaths.add(new File("some2/plugin2/path2"));
    expectedPaths.add(new File("some3/plugin3/path3"));
    assertEquals(expectedPaths, pluginsService.getPluginSearchPath());
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 23 with LuceneServerConfiguration

use of com.yelp.nrtsearch.server.config.LuceneServerConfiguration in project nrtsearch by Yelp.

the class PluginsServiceTest method testGetSinglePluginSearchPath.

@Test
public void testGetSinglePluginSearchPath() {
    LuceneServerConfiguration config = getConfigWithSearchPath("some/plugin/path");
    PluginsService pluginsService = new PluginsService(config);
    List<File> expectedPaths = new ArrayList<>();
    expectedPaths.add(new File("some/plugin/path"));
    assertEquals(expectedPaths, pluginsService.getPluginSearchPath());
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 24 with LuceneServerConfiguration

use of com.yelp.nrtsearch.server.config.LuceneServerConfiguration in project nrtsearch by Yelp.

the class PluginsServiceTest method testGetPluginInstanceHasConfig.

@Test
public void testGetPluginInstanceHasConfig() {
    LuceneServerConfiguration config = getEmptyConfig();
    PluginsService pluginsService = new PluginsService(config);
    Plugin loadedPlugin = pluginsService.getPluginInstance(LoadTestPlugin.class);
    LoadTestPlugin loadTestPlugin = (LoadTestPlugin) loadedPlugin;
    assertSame(config, loadTestPlugin.config);
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) Test(org.junit.Test)

Example 25 with LuceneServerConfiguration

use of com.yelp.nrtsearch.server.config.LuceneServerConfiguration in project nrtsearch by Yelp.

the class BackendGlobalStateTest method testUseRemoteBackend.

@Test
public void testUseRemoteBackend() throws IOException {
    String configFile = String.join("\n", "stateConfig:", "  backendType: REMOTE", "stateDir: " + folder.newFolder("state").getAbsolutePath(), "indexDir: " + folder.newFolder("index").getAbsolutePath());
    LuceneServerConfiguration config = new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes()));
    Path tmpStateFolder = Paths.get(folder.getRoot().getAbsolutePath(), StateUtils.GLOBAL_STATE_FOLDER);
    StateUtils.ensureDirectory(tmpStateFolder);
    StateUtils.writeStateToFile(new PersistentGlobalState(), tmpStateFolder, StateUtils.GLOBAL_STATE_FILE);
    Archiver archiver = mock(Archiver.class);
    when(archiver.download(any(), any())).thenReturn(Paths.get(folder.getRoot().getAbsolutePath()));
    BackendGlobalState backendGlobalState = new BackendGlobalState(config, archiver);
    assertTrue(backendGlobalState.getStateBackend() instanceof RemoteStateBackend);
}
Also used : Path(java.nio.file.Path) RemoteStateBackend(com.yelp.nrtsearch.server.luceneserver.state.backend.RemoteStateBackend) LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) Archiver(com.yelp.nrtsearch.server.backup.Archiver) Test(org.junit.Test)

Aggregations

LuceneServerConfiguration (com.yelp.nrtsearch.server.config.LuceneServerConfiguration)34 GlobalState (com.yelp.nrtsearch.server.luceneserver.GlobalState)17 Test (org.junit.Test)10 ByteArrayInputStream (java.io.ByteArrayInputStream)6 AnonymousAWSCredentials (com.amazonaws.auth.AnonymousAWSCredentials)3 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)3 ArchiverImpl (com.yelp.nrtsearch.server.backup.ArchiverImpl)3 TarImpl (com.yelp.nrtsearch.server.backup.TarImpl)3 GrpcServer (com.yelp.nrtsearch.server.grpc.GrpcServer)3 PersistentGlobalState (com.yelp.nrtsearch.server.luceneserver.state.PersistentGlobalState)3 File (java.io.File)3 Before (org.junit.Before)3 BackendGlobalState (com.yelp.nrtsearch.server.luceneserver.state.BackendGlobalState)2 LegacyGlobalState (com.yelp.nrtsearch.server.luceneserver.state.LegacyGlobalState)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 Inject (com.google.inject.Inject)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 Archiver (com.yelp.nrtsearch.server.backup.Archiver)1