use of com.alibaba.graphscope.groot.coordinator.SnapshotNotifier 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);
}
Aggregations