Search in sources :

Example 6 with GlobalState

use of com.yelp.nrtsearch.server.luceneserver.GlobalState in project nrtsearch by Yelp.

the class CustomFieldTypeTest method setUpGrpcServer.

private GrpcServer setUpGrpcServer(CollectorRegistry collectorRegistry) throws IOException {
    String testIndex = "test_index";
    LuceneServerConfiguration luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot());
    GlobalState globalState = GlobalState.createState(luceneServerConfiguration);
    return new GrpcServer(collectorRegistry, grpcCleanup, luceneServerConfiguration, folder, false, globalState, luceneServerConfiguration.getIndexDir(), testIndex, globalState.getPort(), null, Collections.singletonList(new TestFieldTypePlugin()));
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) GlobalState(com.yelp.nrtsearch.server.luceneserver.GlobalState)

Example 7 with GlobalState

use of com.yelp.nrtsearch.server.luceneserver.GlobalState in project nrtsearch by Yelp.

the class LuceneServerTest method setUpGrpcServer.

private GrpcServer setUpGrpcServer(CollectorRegistry collectorRegistry) throws IOException {
    String testIndex = "test_index";
    LuceneServerConfiguration luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot());
    GlobalState globalState = GlobalState.createState(luceneServerConfiguration);
    return new GrpcServer(collectorRegistry, grpcCleanup, luceneServerConfiguration, folder, false, globalState, luceneServerConfiguration.getIndexDir(), testIndex, globalState.getPort(), null, Collections.emptyList());
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) GlobalState(com.yelp.nrtsearch.server.luceneserver.GlobalState)

Example 8 with GlobalState

use of com.yelp.nrtsearch.server.luceneserver.GlobalState in project nrtsearch by Yelp.

the class LuceneServerTest method testReCreateDeletedIndex.

/**
 * This test creates the index, deletes the same index and then creates the same index again. This
 * verifies whether the global state is correctly updated, flushed to disk and the previous global
 * states are deleted.
 */
@Test
public void testReCreateDeletedIndex() throws IOException {
    String indexName = "test_idx_1";
    LuceneServerGrpc.LuceneServerBlockingStub blockingStub = grpcServer.getBlockingStub();
    GlobalState globalState = grpcServer.getGlobalState();
    // verify that globalState has no content
    assertEquals(0, Files.list(globalState.getStateDir()).count());
    CreateIndexRequest createIndexRequest = CreateIndexRequest.newBuilder().setIndexName(indexName).build();
    CreateIndexResponse createIndexResponse = blockingStub.createIndex(createIndexRequest);
    assertEquals(String.format("Created Index name: %s", indexName, grpcServer.getIndexDir()), createIndexResponse.getResponse());
    // verify that only indices.0 exists and has the same content on disk as in-memory
    assertEquals(1, Files.list(globalState.getStateDir()).count());
    assertEquals("indices.0", Files.list(globalState.getStateDir()).findAny().get().getFileName().toString());
    Path primaryStateIndexPath = globalState.getStateDir().resolve("indices.0");
    JsonObject persistedIndexNames = JsonParser.parseString(Files.readString(primaryStateIndexPath)).getAsJsonObject();
    assertEquals(globalState.getIndexNames(), persistedIndexNames.keySet());
    // delete the index
    DeleteIndexRequest deleteIndexRequest = DeleteIndexRequest.newBuilder().setIndexName(indexName).build();
    DeleteIndexResponse deleteIndexResponse = grpcServer.getBlockingStub().deleteIndex(deleteIndexRequest);
    // verify that globalState indices.1 exists only and has the required empty content
    assertEquals(1, Files.list(globalState.getStateDir()).count());
    assertEquals("indices.1", Files.list(globalState.getStateDir()).findAny().get().getFileName().toString());
    primaryStateIndexPath = globalState.getStateDir().resolve("indices.1");
    persistedIndexNames = JsonParser.parseString(Files.readString(primaryStateIndexPath)).getAsJsonObject();
    assertEquals(globalState.getIndexNames(), persistedIndexNames.keySet());
    // create the index
    createIndexRequest = CreateIndexRequest.newBuilder().setIndexName(indexName).build();
    createIndexResponse = blockingStub.createIndex(createIndexRequest);
    assertEquals(String.format("Created Index name: %s", indexName, grpcServer.getIndexDir()), createIndexResponse.getResponse());
    // verify that globalState indices.2 exists only and has the required content
    assertEquals(1, Files.list(globalState.getStateDir()).count());
    assertEquals("indices.2", Files.list(globalState.getStateDir()).findAny().get().getFileName().toString());
    primaryStateIndexPath = globalState.getStateDir().resolve("indices.2");
    persistedIndexNames = JsonParser.parseString(Files.readString(primaryStateIndexPath)).getAsJsonObject();
    assertEquals(globalState.getIndexNames(), persistedIndexNames.keySet());
}
Also used : Path(java.nio.file.Path) GlobalState(com.yelp.nrtsearch.server.luceneserver.GlobalState) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test)

Example 9 with GlobalState

use of com.yelp.nrtsearch.server.luceneserver.GlobalState in project nrtsearch by Yelp.

the class LuceneServerTest method setUpReplicaGrpcServer.

private GrpcServer setUpReplicaGrpcServer(CollectorRegistry collectorRegistry) throws IOException {
    String testIndex = "test_index";
    LuceneServerConfiguration luceneServerReplicaConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.REPLICA, folder.getRoot(), getExtraConfig());
    GlobalState globalStateSecondary = GlobalState.createState(luceneServerReplicaConfiguration);
    return new GrpcServer(grpcCleanup, luceneServerReplicaConfiguration, folder, false, globalStateSecondary, luceneServerReplicaConfiguration.getIndexDir(), testIndex, globalStateSecondary.getPort(), archiver);
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) GlobalState(com.yelp.nrtsearch.server.luceneserver.GlobalState)

Example 10 with GlobalState

use of com.yelp.nrtsearch.server.luceneserver.GlobalState in project nrtsearch by Yelp.

the class MergeBehaviorTests method setUpGrpcServer.

private GrpcServer setUpGrpcServer(CollectorRegistry collectorRegistry) throws IOException {
    String testIndex = "test_index";
    LuceneServerConfiguration luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot());
    GlobalState globalState = GlobalState.createState(luceneServerConfiguration);
    return new GrpcServer(collectorRegistry, grpcCleanup, luceneServerConfiguration, folder, false, globalState, luceneServerConfiguration.getIndexDir(), testIndex, globalState.getPort(), null, Collections.emptyList());
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) GlobalState(com.yelp.nrtsearch.server.luceneserver.GlobalState)

Aggregations

GlobalState (com.yelp.nrtsearch.server.luceneserver.GlobalState)19 LuceneServerConfiguration (com.yelp.nrtsearch.server.config.LuceneServerConfiguration)17 PersistentGlobalState (com.yelp.nrtsearch.server.luceneserver.state.PersistentGlobalState)3 AnonymousAWSCredentials (com.amazonaws.auth.AnonymousAWSCredentials)2 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)2 ArchiverImpl (com.yelp.nrtsearch.server.backup.ArchiverImpl)2 TarImpl (com.yelp.nrtsearch.server.backup.TarImpl)2 GrpcServer (com.yelp.nrtsearch.server.grpc.GrpcServer)2 Path (java.nio.file.Path)2 Before (org.junit.Before)2 Test (org.junit.Test)2 JsonObject (com.google.gson.JsonObject)1