Search in sources :

Example 1 with FileNodeStorer

use of com.bonree.brfs.duplication.coordinator.FileNodeStorer in project BRFS by zhangnianli.

the class TestStorer method main.

public static void main(String[] args) throws Exception {
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    CuratorFramework client = CuratorFrameworkFactory.newClient("122.11.47.17:2181", 5 * 1000, 30 * 1000, retryPolicy);
    client.start();
    client.blockUntilConnected();
    FileNodeStorer storer = new ZkFileNodeStorer(client.usingNamespace("test"));
    FileNode node = new FileNode();
    node.setName("file_node_1");
    node.setServiceId("ser_1");
    node.setStorageName("sn_1");
    node.setDuplicates(new int[] { 1, 2, 3 });
    storer.save(node);
    FileNode node2 = storer.getFileNode("file_node_1");
    System.out.println("node2--" + node2.getName());
    node2.setServiceId("ser_2");
    storer.update("file_node_1", node2);
    List<FileNode> nodeList = storer.listFileNodes();
    for (FileNode nd : nodeList) {
        System.out.println("list--" + nd.getName() + ", " + nd.getServiceId());
        storer.delete(nd.getName());
    }
    synchronized (client) {
        client.wait();
    }
}
Also used : FileNodeStorer(com.bonree.brfs.duplication.coordinator.FileNodeStorer) CuratorFramework(org.apache.curator.framework.CuratorFramework) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) RetryPolicy(org.apache.curator.RetryPolicy) FileNode(com.bonree.brfs.duplication.coordinator.FileNode)

Aggregations

FileNode (com.bonree.brfs.duplication.coordinator.FileNode)1 FileNodeStorer (com.bonree.brfs.duplication.coordinator.FileNodeStorer)1 RetryPolicy (org.apache.curator.RetryPolicy)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)1