Search in sources :

Example 1 with GraknKeyspaceStore

use of ai.grakn.engine.GraknKeyspaceStore in project grakn by graknlabs.

the class PostProcessingTaskTest method setupMocks.

@Before
public void setupMocks() {
    GraknKeyspaceStore graknKeyspaceStore = mock(GraknKeyspaceStore.class);
    when(graknKeyspaceStore.keyspaces()).thenReturn(keyspaces);
    factory = mock(EngineGraknTxFactory.class);
    when(factory.keyspaceStore()).thenReturn(graknKeyspaceStore);
    indexPostProcessor = mock(IndexPostProcessor.class);
    postProcessor = PostProcessor.create(indexPostProcessor, mock(CountPostProcessor.class));
    config = mock(GraknConfig.class);
    when(config.getProperty(GraknConfigKey.POST_PROCESSOR_POOL_SIZE)).thenReturn(5);
    when(config.getProperty(GraknConfigKey.POST_PROCESSOR_DELAY)).thenReturn(1);
    postProcessingTask = new PostProcessingTask(factory, indexPostProcessor, config);
}
Also used : GraknConfig(ai.grakn.engine.GraknConfig) EngineGraknTxFactory(ai.grakn.engine.factory.EngineGraknTxFactory) GraknKeyspaceStore(ai.grakn.engine.GraknKeyspaceStore) Before(org.junit.Before)

Example 2 with GraknKeyspaceStore

use of ai.grakn.engine.GraknKeyspaceStore in project grakn by graknlabs.

the class CountPostProcessorTest method setupMocks.

@Before
public void setupMocks() {
    countStorage = mock(RedisCountStorage.class);
    when(countStorage.getCount(any())).thenReturn(1L);
    configMock = mock(GraknConfig.class);
    when(configMock.getProperty(GraknConfigKey.SHARDING_THRESHOLD)).thenReturn(5L);
    GraknKeyspaceStore graknKeyspaceStoreMock = mock(GraknKeyspaceStore.class);
    when(graknKeyspaceStoreMock.containsKeyspace(any())).thenReturn(true);
    EmbeddedGraknTx txMock = mock(EmbeddedGraknTx.class);
    when(txMock.admin()).thenReturn(mock(GraknAdmin.class));
    factoryMock = mock(EngineGraknTxFactory.class);
    when(factoryMock.keyspaceStore()).thenReturn(graknKeyspaceStoreMock);
    when(factoryMock.tx(any(Keyspace.class), any())).thenReturn(txMock);
    lockProviderMock = mock(LockProvider.class);
    when(lockProviderMock.getLock(any())).thenReturn(new ReentrantLock());
    metricRegistry = new MetricRegistry();
    countPostProcessor = CountPostProcessor.create(configMock, factoryMock, lockProviderMock, metricRegistry, countStorage);
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) GraknConfig(ai.grakn.engine.GraknConfig) RedisCountStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage) Keyspace(ai.grakn.Keyspace) MetricRegistry(com.codahale.metrics.MetricRegistry) EngineGraknTxFactory(ai.grakn.engine.factory.EngineGraknTxFactory) GraknAdmin(ai.grakn.kb.admin.GraknAdmin) LockProvider(ai.grakn.engine.lock.LockProvider) EmbeddedGraknTx(ai.grakn.kb.internal.EmbeddedGraknTx) GraknKeyspaceStore(ai.grakn.engine.GraknKeyspaceStore) Before(org.junit.Before)

Example 3 with GraknKeyspaceStore

use of ai.grakn.engine.GraknKeyspaceStore in project grakn by graknlabs.

the class EngineGraknSessionTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    JedisLockProvider lockProvider = new JedisLockProvider(inMemoryRedisContext.jedisPool());
    GraknKeyspaceStore keyspaceStore = GraknKeyspaceStoreFake.of();
    graknFactory = EngineGraknTxFactory.create(lockProvider, config, keyspaceStore);
    graknFactory.keyspaceStore().loadSystemSchema();
}
Also used : JedisLockProvider(ai.grakn.engine.lock.JedisLockProvider) GraknKeyspaceStore(ai.grakn.engine.GraknKeyspaceStore) BeforeClass(org.junit.BeforeClass)

Example 4 with GraknKeyspaceStore

use of ai.grakn.engine.GraknKeyspaceStore in project grakn by graknlabs.

the class PostProcessingTask method run.

@Override
public void run() {
    UUID executionId = UUID.randomUUID();
    LOG.info("starting post-processing task with ID '" + executionId + "' ... ");
    GraknKeyspaceStore keyspaceStore = factory.keyspaceStore();
    if (keyspaceStore != null) {
        keyspaceStore.keyspaces().forEach(keyspace -> runPostProcessing(executionId, keyspace));
        LOG.info("post-processing task with ID " + executionId + "finished.");
    } else {
        LOG.info("post-processing " + executionId + ": waiting for system keyspace to be ready.");
    }
}
Also used : UUID(java.util.UUID) GraknKeyspaceStore(ai.grakn.engine.GraknKeyspaceStore)

Aggregations

GraknKeyspaceStore (ai.grakn.engine.GraknKeyspaceStore)4 GraknConfig (ai.grakn.engine.GraknConfig)2 EngineGraknTxFactory (ai.grakn.engine.factory.EngineGraknTxFactory)2 Before (org.junit.Before)2 Keyspace (ai.grakn.Keyspace)1 JedisLockProvider (ai.grakn.engine.lock.JedisLockProvider)1 LockProvider (ai.grakn.engine.lock.LockProvider)1 RedisCountStorage (ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage)1 GraknAdmin (ai.grakn.kb.admin.GraknAdmin)1 EmbeddedGraknTx (ai.grakn.kb.internal.EmbeddedGraknTx)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 UUID (java.util.UUID)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 BeforeClass (org.junit.BeforeClass)1