Search in sources :

Example 26 with Configs

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

the class IngestServiceTest method testIngestService.

@Test
void testIngestService() {
    Configs configs = Configs.newBuilder().put(CommonConfig.NODE_IDX.getKey(), "0").put(CommonConfig.STORE_NODE_COUNT.getKey(), "1").put(IngestorConfig.INGESTOR_CHECK_PROCESSOR_INTERVAL_MS.getKey(), "100").build();
    MockDiscovery mockDiscovery = new MockDiscovery();
    MetaService mockMetaService = mock(MetaService.class);
    when(mockMetaService.getQueueIdsForIngestor(0)).thenReturn(Arrays.asList(0));
    LogService mockLogService = mock(LogService.class);
    IngestProgressFetcher mockIngestProgressFetcher = mock(IngestProgressFetcher.class);
    when(mockIngestProgressFetcher.getTailOffsets(Arrays.asList(0))).thenReturn(Arrays.asList(50L));
    StoreWriter mockStoreWriter = mock(StoreWriter.class);
    IngestService spyIngestService = spy(new IngestService(configs, mockDiscovery, mockMetaService, mockLogService, mockIngestProgressFetcher, mockStoreWriter, new MetricsCollector(configs)));
    IngestProcessor mockIngestProcessor = mock(IngestProcessor.class);
    doReturn(mockIngestProcessor).when(spyIngestService).makeIngestProcessor(any(), any(), any(), eq(0), any(), any());
    spyIngestService.start();
    verify(mockIngestProcessor, never()).start();
    mockDiscovery.addNode(RoleType.STORE, Collections.singletonMap(0, null));
    verify(mockIngestProcessor, timeout(5000L)).setTailOffset(50L);
    verify(mockIngestProcessor, timeout(5000L)).start();
    spyIngestService.advanceIngestSnapshotId(5L, null);
    verify(mockIngestProcessor).ingestBatch(eq("marker"), eq(IngestService.MARKER_BATCH), any());
    mockDiscovery.removeNode(RoleType.STORE, Collections.singletonMap(0, null));
    verify(mockIngestProcessor, timeout(5000L).times(2)).stop();
    spyIngestService.stop();
}
Also used : MetricsCollector(com.alibaba.graphscope.groot.metrics.MetricsCollector) IngestService(com.alibaba.graphscope.groot.ingestor.IngestService) MetaService(com.alibaba.graphscope.groot.meta.MetaService) StoreWriter(com.alibaba.graphscope.groot.ingestor.StoreWriter) Configs(com.alibaba.maxgraph.common.config.Configs) IngestProgressFetcher(com.alibaba.graphscope.groot.ingestor.IngestProgressFetcher) LogService(com.alibaba.graphscope.groot.wal.LogService) IngestProcessor(com.alibaba.graphscope.groot.ingestor.IngestProcessor) Test(org.junit.jupiter.api.Test)

Example 27 with Configs

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

the class BackupAgentTest method testBackupAgent.

@Test
void testBackupAgent() throws IOException {
    Configs configs = Configs.newBuilder().put(CommonConfig.NODE_IDX.getKey(), "0").put(BackupConfig.BACKUP_ENABLE.getKey(), "true").put(BackupConfig.STORE_BACKUP_THREAD_COUNT.getKey(), "2").build();
    StoreService mockStoreService = mock(StoreService.class);
    JnaGraphStore mockJnaStore0 = mock(JnaGraphStore.class);
    JnaGraphStore mockJnaStore1 = mock(JnaGraphStore.class);
    JnaGraphBackupEngine mockJnaBackupEngine0 = mock(JnaGraphBackupEngine.class);
    JnaGraphBackupEngine mockJnaBackupEngine1 = mock(JnaGraphBackupEngine.class);
    Map<Integer, GraphPartition> idToPartition = new HashMap<>();
    idToPartition.put(0, mockJnaStore0);
    idToPartition.put(1, mockJnaStore1);
    when(mockStoreService.getIdToPartition()).thenReturn(idToPartition);
    when(mockJnaStore0.openBackupEngine()).thenReturn(mockJnaBackupEngine0);
    when(mockJnaStore1.openBackupEngine()).thenReturn(mockJnaBackupEngine1);
    BackupAgent backupAgent = new BackupAgent(configs, mockStoreService);
    backupAgent.start();
    StoreBackupId storeBackupId = new StoreBackupId(5);
    storeBackupId.addPartitionBackupId(0, 7);
    storeBackupId.addPartitionBackupId(1, 6);
    Map<Integer, List<Integer>> readyPartitionBackupIds = new HashMap<>();
    readyPartitionBackupIds.put(0, Arrays.asList(2, 4, 6));
    readyPartitionBackupIds.put(1, Arrays.asList(3, 5, 7));
    when(mockJnaBackupEngine0.createNewPartitionBackup()).thenReturn(7);
    when(mockJnaBackupEngine1.createNewPartitionBackup()).thenReturn(6);
    CompletionCallback<StoreBackupId> createCallback = mock(CompletionCallback.class);
    backupAgent.createNewStoreBackup(5, createCallback);
    verify(createCallback, timeout(5000L)).onCompleted(storeBackupId);
    CompletionCallback<Void> verifyCallback = mock(CompletionCallback.class);
    backupAgent.verifyStoreBackup(storeBackupId, verifyCallback);
    verify(mockJnaBackupEngine0, timeout(5000L)).verifyPartitionBackup(7);
    verify(mockJnaBackupEngine1, timeout(5000L)).verifyPartitionBackup(6);
    verify(verifyCallback, timeout(5000L)).onCompleted(null);
    CompletionCallback<Void> clearCallback = mock(CompletionCallback.class);
    backupAgent.clearUnavailableStoreBackups(readyPartitionBackupIds, clearCallback);
    verify(mockJnaBackupEngine0, timeout(5000L)).partitionBackupGc(Arrays.asList(2, 4, 6));
    verify(mockJnaBackupEngine1, timeout(5000L)).partitionBackupGc(Arrays.asList(3, 5, 7));
    verify(clearCallback, timeout(5000L)).onCompleted(null);
    CompletionCallback<Void> restoreCallback = mock(CompletionCallback.class);
    backupAgent.restoreFromStoreBackup(storeBackupId, "restore_root", restoreCallback);
    verify(mockJnaBackupEngine0, timeout(5000L)).restoreFromPartitionBackup(7, Paths.get("restore_root", "0").toString());
    verify(mockJnaBackupEngine1, timeout(5000L)).restoreFromPartitionBackup(6, Paths.get("restore_root", "1").toString());
    verify(restoreCallback, timeout(5000L)).onCompleted(null);
    backupAgent.stop();
}
Also used : JnaGraphBackupEngine(com.alibaba.graphscope.groot.store.jna.JnaGraphBackupEngine) HashMap(java.util.HashMap) GraphPartition(com.alibaba.graphscope.groot.store.GraphPartition) StoreService(com.alibaba.graphscope.groot.store.StoreService) JnaGraphStore(com.alibaba.graphscope.groot.store.jna.JnaGraphStore) StoreBackupId(com.alibaba.graphscope.groot.store.StoreBackupId) Configs(com.alibaba.maxgraph.common.config.Configs) BackupAgent(com.alibaba.graphscope.groot.store.BackupAgent) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 28 with Configs

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

the class ZkDiscoveryTest method createNodeDiscovery.

private NodeDiscovery createNodeDiscovery(RoleType role, int idx, int port, Configs zkConfigs, CuratorFramework curator) {
    Configs nodeConfigs = Configs.newBuilder().put(CommonConfig.ROLE_NAME.getKey(), role.getName()).put(CommonConfig.NODE_IDX.getKey(), String.valueOf(idx)).build();
    LocalNodeProvider localNodeProvider = new LocalNodeProvider(nodeConfigs);
    localNodeProvider.apply(port);
    return new ZkDiscovery(zkConfigs, localNodeProvider, curator);
}
Also used : LocalNodeProvider(com.alibaba.graphscope.groot.discovery.LocalNodeProvider) Configs(com.alibaba.maxgraph.common.config.Configs) ZkDiscovery(com.alibaba.graphscope.groot.discovery.ZkDiscovery)

Example 29 with Configs

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

the class Coordinator method main.

public static void main(String[] args) throws IOException {
    String configFile = System.getProperty("config.file");
    Configs conf = new Configs(configFile);
    Coordinator coordinator = new Coordinator(conf);
    NodeLauncher nodeLauncher = new NodeLauncher(coordinator);
    nodeLauncher.start();
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs)

Example 30 with Configs

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

the class Frontend method main.

public static void main(String[] args) throws IOException {
    String configFile = System.getProperty("config.file");
    Configs conf = new Configs(configFile);
    Frontend frontend = new Frontend(conf);
    NodeLauncher nodeLauncher = new NodeLauncher(frontend);
    nodeLauncher.start();
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs)

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