Search in sources :

Example 6 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class MaxTestGraph method open.

public static MaxTestGraph open(final Configuration conf) throws Exception {
    if (INSTANCE == null) {
        logger.info("open new MaxTestGraph");
        String log4rsPath = Paths.get(Thread.currentThread().getContextClassLoader().getResource("log4rs.yml").toURI()).toString();
        Configs.Builder builder = Configs.newBuilder();
        conf.getKeys().forEachRemaining((k) -> builder.put(k, conf.getString(k)));
        Configs configs = builder.put(CommonConfig.LOG4RS_CONFIG.getKey(), log4rsPath).build();
        INSTANCE = new MaxTestGraph(configs);
    }
    return INSTANCE;
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs)

Example 7 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class KafkaWalTest method testDoubleInit.

@Test
void testDoubleInit() {
    Configs configs = Configs.newBuilder().put(KafkaConfig.KAFKA_SERVERS.getKey(), sharedKafkaTestResource.getKafkaConnectString()).put(KafkaConfig.KAKFA_TOPIC.getKey(), "test_double_init").put(CommonConfig.INGESTOR_QUEUE_COUNT.getKey(), "1").build();
    LogService logService = new KafkaLogService(configs);
    logService.init();
    assertThrows(Exception.class, () -> logService.init());
    logService.destroy();
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs) KafkaLogService(com.alibaba.graphscope.groot.wal.kafka.KafkaLogService) KafkaLogService(com.alibaba.graphscope.groot.wal.kafka.KafkaLogService) LogService(com.alibaba.graphscope.groot.wal.LogService) Test(org.junit.jupiter.api.Test)

Example 8 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class IngestorWriteSnapshotIdNotifierTest method testNotifier.

@Test
void testNotifier() {
    Configs configs = Configs.newBuilder().put(CommonConfig.INGESTOR_NODE_COUNT.getKey(), "1").build();
    RoleClients<IngestorSnapshotClient> roleClients = mock(RoleClients.class);
    IngestorSnapshotClient ingestorSnapshotClient = mock(IngestorSnapshotClient.class);
    when(roleClients.getClient(0)).thenReturn(ingestorSnapshotClient);
    IngestorWriteSnapshotIdNotifier notifier = new IngestorWriteSnapshotIdNotifier(configs, roleClients);
    notifier.notifyWriteSnapshotIdChanged(10L);
    verify(ingestorSnapshotClient).advanceIngestSnapshotId(eq(10L), any());
}
Also used : IngestorSnapshotClient(com.alibaba.graphscope.groot.coordinator.IngestorSnapshotClient) Configs(com.alibaba.maxgraph.common.config.Configs) IngestorWriteSnapshotIdNotifier(com.alibaba.graphscope.groot.coordinator.IngestorWriteSnapshotIdNotifier) Test(org.junit.jupiter.api.Test)

Example 9 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class SnapshotManagerTest method testSnapshotManager.

@Test
void testSnapshotManager() throws IOException, InterruptedException {
    Configs configs = Configs.newBuilder().put(CommonConfig.INGESTOR_QUEUE_COUNT.getKey(), "1").put(CommonConfig.STORE_NODE_COUNT.getKey(), "2").put(CommonConfig.FRONTEND_NODE_COUNT.getKey(), "1").put(CommonConfig.INGESTOR_NODE_COUNT.getKey(), "1").put(CoordinatorConfig.SNAPSHOT_INCREASE_INTERVAL_MS.getKey(), "1000").put(CoordinatorConfig.OFFSETS_PERSIST_INTERVAL_MS.getKey(), "1000").build();
    long querySnapshotId = 10L;
    long writeSnapshotId = 12L;
    List<Long> queueOffsets = Arrays.asList(50L);
    long commitSnapshotId1 = 11L;
    long commitSnapshotId2 = 12L;
    List<Long> commitQueueOffsets1 = Arrays.asList(60L);
    List<Long> commitQueueOffsets2 = Arrays.asList(70L);
    ObjectMapper objectMapper = new ObjectMapper();
    MetaStore mockMetaStore = mock(MetaStore.class);
    when(mockMetaStore.exists(anyString())).thenReturn(true);
    when(mockMetaStore.read(QUERY_SNAPSHOT_INFO_PATH)).thenReturn(objectMapper.writeValueAsBytes(new SnapshotInfo(querySnapshotId, querySnapshotId)));
    when(mockMetaStore.read(WRITE_SNAPSHOT_ID_PATH)).thenReturn(objectMapper.writeValueAsBytes(writeSnapshotId));
    when(mockMetaStore.read(QUEUE_OFFSETS_PATH)).thenReturn(objectMapper.writeValueAsBytes(queueOffsets));
    CountDownLatch updateWriteSnapshotLatch = new CountDownLatch(1);
    doAnswer(invocationOnMock -> {
        updateWriteSnapshotLatch.countDown();
        return null;
    }).when(mockMetaStore).write(WRITE_SNAPSHOT_ID_PATH, objectMapper.writeValueAsBytes(writeSnapshotId + 1));
    CountDownLatch updateQueueOffsetLatch = new CountDownLatch(1);
    doAnswer(invocationOnMock -> {
        updateQueueOffsetLatch.countDown();
        return null;
    }).when(mockMetaStore).write(QUEUE_OFFSETS_PATH, objectMapper.writeValueAsBytes(commitQueueOffsets1));
    IngestorWriteSnapshotIdNotifier mockWriteSnapshotIdNotifier = mock(IngestorWriteSnapshotIdNotifier.class);
    CountDownLatch updateIngestorLatch = new CountDownLatch(1);
    doAnswer(invocationOnMock -> {
        updateIngestorLatch.countDown();
        return null;
    }).when(mockWriteSnapshotIdNotifier).notifyWriteSnapshotIdChanged(writeSnapshotId + 1);
    LogService mockLogService = mock(LogService.class);
    SnapshotManager snapshotManager = new SnapshotManager(configs, mockMetaStore, mockLogService, mockWriteSnapshotIdNotifier);
    snapshotManager.start();
    assertEquals(snapshotManager.getQueueOffsets(), queueOffsets);
    assertTrue(updateWriteSnapshotLatch.await(5L, TimeUnit.SECONDS));
    assertTrue(updateIngestorLatch.await(5L, TimeUnit.SECONDS));
    snapshotManager.commitSnapshotId(0, commitSnapshotId1, 10L, commitQueueOffsets1);
    snapshotManager.commitSnapshotId(1, commitSnapshotId2, 10L, commitQueueOffsets2);
    verify(mockMetaStore).write(QUERY_SNAPSHOT_INFO_PATH, objectMapper.writeValueAsBytes(new SnapshotInfo(commitSnapshotId1, 10L)));
    assertTrue(updateQueueOffsetLatch.await(5L, TimeUnit.SECONDS));
    assertEquals(snapshotManager.getQueueOffsets(), commitQueueOffsets1);
    snapshotManager.stop();
}
Also used : MetaStore(com.alibaba.graphscope.groot.meta.MetaStore) SnapshotInfo(com.alibaba.graphscope.groot.coordinator.SnapshotInfo) Configs(com.alibaba.maxgraph.common.config.Configs) CountDownLatch(java.util.concurrent.CountDownLatch) IngestorWriteSnapshotIdNotifier(com.alibaba.graphscope.groot.coordinator.IngestorWriteSnapshotIdNotifier) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LogService(com.alibaba.graphscope.groot.wal.LogService) SnapshotManager(com.alibaba.graphscope.groot.coordinator.SnapshotManager) Test(org.junit.jupiter.api.Test)

Example 10 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class DefaultMetaServiceTest method testMeta.

@Test
void testMeta() {
    Configs configs = Configs.newBuilder().put("partition.count", "10").put("ingestor.queue.count", "3").put("store.node.count", "4").build();
    /**
     * Partitions assignment
     *
     * <p>| storeID | Partitions | | 0 | 0, 1, 2 | | 1 | 3, 4, 5 | | 2 | 6, 7 | | 3 | 8, 9 |
     */
    MetaService metaService = new DefaultMetaService(configs);
    metaService.start();
    Assertions.assertAll(() -> assertEquals(metaService.getPartitionCount(), 10), () -> assertEquals(metaService.getStoreIdByPartition(0), 0), () -> assertEquals(metaService.getStoreIdByPartition(5), 1), () -> assertEquals(metaService.getStoreIdByPartition(6), 2), () -> assertEquals(metaService.getStoreIdByPartition(8), 3), () -> assertEquals(metaService.getPartitionsByStoreId(2), Arrays.asList(6, 7)), () -> assertEquals(metaService.getQueueCount(), 3), () -> assertEquals(metaService.getQueueIdsForIngestor(2), Arrays.asList(2)), () -> assertEquals(metaService.getIngestorIdForQueue(1), 1));
    metaService.stop();
}
Also used : DefaultMetaService(com.alibaba.graphscope.groot.meta.DefaultMetaService) DefaultMetaService(com.alibaba.graphscope.groot.meta.DefaultMetaService) MetaService(com.alibaba.graphscope.groot.meta.MetaService) Configs(com.alibaba.maxgraph.common.config.Configs) Test(org.junit.jupiter.api.Test)

Aggregations

Configs (com.alibaba.maxgraph.common.config.Configs)33 Test (org.junit.jupiter.api.Test)22 MetaService (com.alibaba.graphscope.groot.meta.MetaService)7 LogService (com.alibaba.graphscope.groot.wal.LogService)7 MetricsCollector (com.alibaba.graphscope.groot.metrics.MetricsCollector)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 LocalNodeProvider (com.alibaba.graphscope.groot.discovery.LocalNodeProvider)4 StoreDataBatch (com.alibaba.graphscope.groot.operation.StoreDataBatch)4 MetaStore (com.alibaba.graphscope.groot.meta.MetaStore)3 OperationBatch (com.alibaba.graphscope.groot.operation.OperationBatch)3 GraphPartition (com.alibaba.graphscope.groot.store.GraphPartition)3 StoreService (com.alibaba.graphscope.groot.store.StoreService)3 KafkaLogService (com.alibaba.graphscope.groot.wal.kafka.KafkaLogService)3 RoleType (com.alibaba.maxgraph.common.RoleType)3 CuratorFramework (org.apache.curator.framework.CuratorFramework)3 TestingServer (org.apache.curator.test.TestingServer)3 IngestorWriteSnapshotIdNotifier (com.alibaba.graphscope.groot.coordinator.IngestorWriteSnapshotIdNotifier)2 SnapshotManager (com.alibaba.graphscope.groot.coordinator.SnapshotManager)2 MaxGraphNode (com.alibaba.graphscope.groot.discovery.MaxGraphNode)2 NodeDiscovery (com.alibaba.graphscope.groot.discovery.NodeDiscovery)2