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);
}
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());
}
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());
}
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);
}
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);
}
Aggregations