Search in sources :

Example 1 with FrontendSnapshotClient

use of com.alibaba.graphscope.groot.coordinator.FrontendSnapshotClient in project GraphScope by alibaba.

the class SnapshotNotifierTest method testSnapshotNotifier.

@Test
void testSnapshotNotifier() {
    NodeDiscovery discovery = mock(NodeDiscovery.class);
    SnapshotManager snapshotManager = mock(SnapshotManager.class);
    RoleClients<FrontendSnapshotClient> roleClients = mock(RoleClients.class);
    SnapshotNotifier snapshotNotifier = new SnapshotNotifier(discovery, snapshotManager, null, roleClients);
    snapshotNotifier.start();
    MaxGraphNode localNode = MaxGraphNode.createLocalNode(Configs.newBuilder().put(CommonConfig.ROLE_NAME.getKey(), RoleType.COORDINATOR.getName()).build(), 1111);
    snapshotNotifier.nodesJoin(RoleType.FRONTEND, Collections.singletonMap(1, localNode));
    ArgumentCaptor<NotifyFrontendListener> captor = ArgumentCaptor.forClass(NotifyFrontendListener.class);
    verify(snapshotManager).addListener(captor.capture());
    NotifyFrontendListener listener = captor.getValue();
    snapshotNotifier.nodesLeft(RoleType.FRONTEND, Collections.singletonMap(1, localNode));
    verify(snapshotManager).removeListener(listener);
}
Also used : SnapshotNotifier(com.alibaba.graphscope.groot.coordinator.SnapshotNotifier) MaxGraphNode(com.alibaba.graphscope.groot.discovery.MaxGraphNode) NotifyFrontendListener(com.alibaba.graphscope.groot.coordinator.NotifyFrontendListener) NodeDiscovery(com.alibaba.graphscope.groot.discovery.NodeDiscovery) FrontendSnapshotClient(com.alibaba.graphscope.groot.coordinator.FrontendSnapshotClient) SnapshotManager(com.alibaba.graphscope.groot.coordinator.SnapshotManager) Test(org.junit.jupiter.api.Test)

Example 2 with FrontendSnapshotClient

use of com.alibaba.graphscope.groot.coordinator.FrontendSnapshotClient in project GraphScope by alibaba.

the class NotifyFrontendListenerTest method testListener.

@Test
void testListener() {
    FrontendSnapshotClient frontendSnapshotClient = mock(FrontendSnapshotClient.class);
    SchemaManager schemaManager = mock(SchemaManager.class);
    GraphDef graphDef = GraphDef.newBuilder().setVersion(3L).build();
    when(schemaManager.getGraphDef()).thenReturn(graphDef);
    doAnswer(invocationOnMock -> {
        long snapshotId = invocationOnMock.getArgument(0);
        CompletionCallback<Long> callback = invocationOnMock.getArgument(2);
        callback.onCompleted(snapshotId - 1);
        return null;
    }).when(frontendSnapshotClient).advanceQuerySnapshot(anyLong(), any(), any());
    NotifyFrontendListener listener = new NotifyFrontendListener(0, frontendSnapshotClient, schemaManager);
    listener.snapshotAdvanced(10L, 10L);
    verify(frontendSnapshotClient).advanceQuerySnapshot(eq(10L), eq(graphDef), any());
    listener.snapshotAdvanced(20L, 10L);
    verify(frontendSnapshotClient).advanceQuerySnapshot(eq(20L), isNull(), any());
}
Also used : NotifyFrontendListener(com.alibaba.graphscope.groot.coordinator.NotifyFrontendListener) SchemaManager(com.alibaba.graphscope.groot.coordinator.SchemaManager) FrontendSnapshotClient(com.alibaba.graphscope.groot.coordinator.FrontendSnapshotClient) GraphDef(com.alibaba.maxgraph.sdkcommon.schema.GraphDef) Test(org.junit.jupiter.api.Test)

Aggregations

FrontendSnapshotClient (com.alibaba.graphscope.groot.coordinator.FrontendSnapshotClient)2 NotifyFrontendListener (com.alibaba.graphscope.groot.coordinator.NotifyFrontendListener)2 Test (org.junit.jupiter.api.Test)2 SchemaManager (com.alibaba.graphscope.groot.coordinator.SchemaManager)1 SnapshotManager (com.alibaba.graphscope.groot.coordinator.SnapshotManager)1 SnapshotNotifier (com.alibaba.graphscope.groot.coordinator.SnapshotNotifier)1 MaxGraphNode (com.alibaba.graphscope.groot.discovery.MaxGraphNode)1 NodeDiscovery (com.alibaba.graphscope.groot.discovery.NodeDiscovery)1 GraphDef (com.alibaba.maxgraph.sdkcommon.schema.GraphDef)1