Search in sources :

Example 1 with ZkMetaStore

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

the class ZkMetaStoreTest method testMetaStore.

@Test
void testMetaStore() throws Exception {
    try (TestingServer testingServer = new TestingServer(-1)) {
        int zkPort = testingServer.getPort();
        Configs configs = Configs.newBuilder().put(ZkConfig.ZK_CONNECT_STRING.getKey(), "localhost:" + zkPort).put(ZkConfig.ZK_BASE_PATH.getKey(), "test_meta_store").build();
        CuratorFramework curator = CuratorUtils.makeCurator(configs);
        curator.start();
        MetaStore metaStore = new ZkMetaStore(configs, curator);
        String path = "test_path";
        String data = "test_data";
        assertFalse(metaStore.exists(path));
        metaStore.write(path, data.getBytes());
        assertTrue(metaStore.exists(path));
        assertEquals(new String(metaStore.read(path)), data);
        metaStore.delete(path);
        assertFalse(metaStore.exists(path));
        curator.close();
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) ZkMetaStore(com.alibaba.graphscope.groot.coordinator.ZkMetaStore) MetaStore(com.alibaba.graphscope.groot.meta.MetaStore) CuratorFramework(org.apache.curator.framework.CuratorFramework) Configs(com.alibaba.maxgraph.common.config.Configs) ZkMetaStore(com.alibaba.graphscope.groot.coordinator.ZkMetaStore) Test(org.junit.jupiter.api.Test)

Aggregations

ZkMetaStore (com.alibaba.graphscope.groot.coordinator.ZkMetaStore)1 MetaStore (com.alibaba.graphscope.groot.meta.MetaStore)1 Configs (com.alibaba.maxgraph.common.config.Configs)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 TestingServer (org.apache.curator.test.TestingServer)1 Test (org.junit.jupiter.api.Test)1