Search in sources :

Example 1 with RemoteStateBackend

use of com.yelp.nrtsearch.server.luceneserver.state.backend.RemoteStateBackend 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

Archiver (com.yelp.nrtsearch.server.backup.Archiver)1 LuceneServerConfiguration (com.yelp.nrtsearch.server.config.LuceneServerConfiguration)1 RemoteStateBackend (com.yelp.nrtsearch.server.luceneserver.state.backend.RemoteStateBackend)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Path (java.nio.file.Path)1 Test (org.junit.Test)1