Search in sources :

Example 6 with BatchSearchLoop

use of org.icij.datashare.tasks.BatchSearchLoop in project datashare by ICIJ.

the class BatchSearchLoopTestInt method test_queued_batch_search_requeueing.

@Test
public void test_queued_batch_search_requeueing() throws Exception {
    when(repository.getQueued()).thenReturn(asList("uuid1", "uuid2"));
    BatchSearchLoop app = new BatchSearchLoop(repository, batchSearchQueue, factory);
    assertThat(app.requeueDatabaseBatches()).isEqualTo(2);
    app.enqueuePoison();
    app.run();
    verify(batchSearchRunner, times(2)).call();
}
Also used : BatchSearchLoop(org.icij.datashare.tasks.BatchSearchLoop) Test(org.junit.Test)

Example 7 with BatchSearchLoop

use of org.icij.datashare.tasks.BatchSearchLoop in project datashare by ICIJ.

the class BatchSearchLoopTestInt method test_main_loop.

@Test
public void test_main_loop() {
    BatchSearchLoop app = new BatchSearchLoop(repository, batchSearchQueue, factory);
    batchSearchQueue.add(batchSearch.uuid);
    app.enqueuePoison();
    app.run();
    verify(batchSearchRunner).call();
    verify(repository).setState(batchSearch.uuid, BatchSearch.State.RUNNING);
    verify(repository).setState(batchSearch.uuid, BatchSearch.State.SUCCESS);
}
Also used : BatchSearchLoop(org.icij.datashare.tasks.BatchSearchLoop) Test(org.junit.Test)

Example 8 with BatchSearchLoop

use of org.icij.datashare.tasks.BatchSearchLoop in project datashare by ICIJ.

the class BatchSearchApp method start.

public static void start(Properties properties) throws Exception {
    Injector injector = createInjector(CommonMode.create(properties));
    BatchSearchLoop batchSearchLoop = injector.getInstance(TaskFactory.class).createBatchSearchLoop();
    batchSearchLoop.requeueDatabaseBatches();
    batchSearchLoop.run();
    batchSearchLoop.close();
    // to avoid being blocked
    injector.getInstance(Indexer.class).close();
}
Also used : Indexer(org.icij.datashare.text.indexing.Indexer) Injector(com.google.inject.Injector) Guice.createInjector(com.google.inject.Guice.createInjector) TaskFactory(org.icij.datashare.tasks.TaskFactory) BatchSearchLoop(org.icij.datashare.tasks.BatchSearchLoop)

Aggregations

BatchSearchLoop (org.icij.datashare.tasks.BatchSearchLoop)8 Test (org.junit.Test)7 Signal (sun.misc.Signal)4 Guice.createInjector (com.google.inject.Guice.createInjector)1 Injector (com.google.inject.Injector)1 Date (java.util.Date)1 BatchSearch (org.icij.datashare.batch.BatchSearch)1 SearchException (org.icij.datashare.batch.SearchException)1 TaskFactory (org.icij.datashare.tasks.TaskFactory)1 Indexer (org.icij.datashare.text.indexing.Indexer)1