Search in sources :

Example 6 with LuceneServerConfiguration

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

the class GlobalStateTest method testCreateLegacyGlobalState.

@Test
public void testCreateLegacyGlobalState() throws IOException {
    String configFile = String.join("\n", "stateConfig:", "  backendType: LEGACY");
    LuceneServerConfiguration configuration = getConfig(configFile);
    GlobalState globalState = GlobalState.createState(configuration);
    assertTrue(globalState instanceof LegacyGlobalState);
}
Also used : LegacyGlobalState(com.yelp.nrtsearch.server.luceneserver.state.LegacyGlobalState) LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) BackendGlobalState(com.yelp.nrtsearch.server.luceneserver.state.BackendGlobalState) LegacyGlobalState(com.yelp.nrtsearch.server.luceneserver.state.LegacyGlobalState) Test(org.junit.Test)

Example 7 with LuceneServerConfiguration

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

the class BackendGlobalStateTest method setup.

@BeforeClass
public static void setup() {
    String configFile = "nodeName: \"lucene_server_foo\"";
    LuceneServerConfiguration dummyConfig = new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes()));
    List<Plugin> dummyPlugins = Collections.emptyList();
    // these must be initialized to create an IndexState
    FieldDefCreator.initialize(dummyConfig, dummyPlugins);
    SimilarityCreator.initialize(dummyConfig, dummyPlugins);
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) Plugin(com.yelp.nrtsearch.server.plugins.Plugin) BeforeClass(org.junit.BeforeClass)

Example 8 with LuceneServerConfiguration

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

the class BackendGlobalStateTest method testUseLocalBackend.

@Test
public void testUseLocalBackend() throws IOException {
    String configFile = String.join("\n", "stateConfig:", "  backendType: LOCAL", "stateDir: " + folder.newFolder("state").getAbsolutePath(), "indexDir: " + folder.newFolder("index").getAbsolutePath());
    LuceneServerConfiguration config = new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes()));
    BackendGlobalState backendGlobalState = new BackendGlobalState(config, null);
    assertTrue(backendGlobalState.getStateBackend() instanceof LocalStateBackend);
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) LocalStateBackend(com.yelp.nrtsearch.server.luceneserver.state.backend.LocalStateBackend) Test(org.junit.Test)

Example 9 with LuceneServerConfiguration

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

the class BackendGlobalStateTest method testInvalidBackend.

@Test
public void testInvalidBackend() throws IOException {
    String configFile = String.join("\n", "stateConfig:", "  backendType: LEGACY", "stateDir: " + folder.newFolder("state").getAbsolutePath(), "indexDir: " + folder.newFolder("index").getAbsolutePath());
    LuceneServerConfiguration config = new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes()));
    try {
        new BackendGlobalState(config, null);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Unsupported state backend type: LEGACY", e.getMessage());
    }
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 10 with LuceneServerConfiguration

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

the class IndexState method initWarmer.

public void initWarmer(Archiver archiver) {
    LuceneServerConfiguration configuration = globalState.getConfiguration();
    WarmerConfig warmerConfig = configuration.getWarmerConfig();
    if (warmerConfig.isWarmOnStartup() || warmerConfig.getMaxWarmingQueries() > 0) {
        this.warmer = new Warmer(archiver, configuration.getServiceName(), name, warmerConfig.getMaxWarmingQueries());
    }
}
Also used : Warmer(com.yelp.nrtsearch.server.luceneserver.warming.Warmer) SimpleMergedSegmentWarmer(org.apache.lucene.index.SimpleMergedSegmentWarmer) LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) WarmerConfig(com.yelp.nrtsearch.server.luceneserver.warming.WarmerConfig)

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