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