Search in sources :

Example 1 with WriterAgent

use of com.alibaba.graphscope.groot.store.WriterAgent in project GraphScope by alibaba.

the class WriterAgentTest method testWriterAgent.

@Test
void testWriterAgent() throws InterruptedException, ExecutionException {
    Configs configs = Configs.newBuilder().put(CommonConfig.NODE_IDX.getKey(), "0").put(StoreConfig.STORE_COMMIT_INTERVAL_MS.getKey(), "10").build();
    StoreService mockStoreService = mock(StoreService.class);
    MetaService mockMetaService = mock(MetaService.class);
    when(mockMetaService.getQueueCount()).thenReturn(1);
    SnapshotCommitter mockSnapshotCommitter = mock(SnapshotCommitter.class);
    WriterAgent writerAgent = new WriterAgent(configs, mockStoreService, mockMetaService, mockSnapshotCommitter, new MetricsCollector(configs));
    writerAgent.init(0L);
    writerAgent.start();
    StoreDataBatch storeDataBatch = StoreDataBatch.newBuilder().snapshotId(2L).queueId(0).offset(10L).build();
    writerAgent.writeStore(storeDataBatch);
    verify(mockStoreService, timeout(5000L).times(1)).batchWrite(storeDataBatch);
    verify(mockSnapshotCommitter, timeout(5000L).times(1)).commitSnapshotId(0, 1L, 0L, Collections.singletonList(10L));
    writerAgent.stop();
}
Also used : MetricsCollector(com.alibaba.graphscope.groot.metrics.MetricsCollector) SnapshotCommitter(com.alibaba.graphscope.groot.store.SnapshotCommitter) MetaService(com.alibaba.graphscope.groot.meta.MetaService) Configs(com.alibaba.maxgraph.common.config.Configs) StoreDataBatch(com.alibaba.graphscope.groot.operation.StoreDataBatch) StoreService(com.alibaba.graphscope.groot.store.StoreService) WriterAgent(com.alibaba.graphscope.groot.store.WriterAgent) Test(org.junit.jupiter.api.Test)

Aggregations

MetaService (com.alibaba.graphscope.groot.meta.MetaService)1 MetricsCollector (com.alibaba.graphscope.groot.metrics.MetricsCollector)1 StoreDataBatch (com.alibaba.graphscope.groot.operation.StoreDataBatch)1 SnapshotCommitter (com.alibaba.graphscope.groot.store.SnapshotCommitter)1 StoreService (com.alibaba.graphscope.groot.store.StoreService)1 WriterAgent (com.alibaba.graphscope.groot.store.WriterAgent)1 Configs (com.alibaba.maxgraph.common.config.Configs)1 Test (org.junit.jupiter.api.Test)1