当前位置: 首页>>代码示例>>Java>>正文


Java EtcdKeysResponse.EtcdNode方法代码示例

本文整理汇总了Java中mousio.etcd4j.responses.EtcdKeysResponse.EtcdNode方法的典型用法代码示例。如果您正苦于以下问题:Java EtcdKeysResponse.EtcdNode方法的具体用法?Java EtcdKeysResponse.EtcdNode怎么用?Java EtcdKeysResponse.EtcdNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mousio.etcd4j.responses.EtcdKeysResponse的用法示例。


在下文中一共展示了EtcdKeysResponse.EtcdNode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetAll

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
@Test
public void testGetAll() throws IOException, EtcdException, EtcdAuthenticationException, TimeoutException {
  EtcdKeysResponse.EtcdNode root;
  List<EtcdKeysResponse.EtcdNode> nodes;

  EtcdClient client = new EtcdClient();

  root = client.getAll().timeout(30, TimeUnit.SECONDS).send().get().getNode();
  nodes = root.getNodes();

  LOGGER.info("Nodes (1) {}", nodes);

  assertNotNull(nodes);
  assertTrue(root.isDir());

  client.put("etcd4j_testGetAll_1/foo1", "bar").prevExist(false).send().get();
  client.put("etcd4j_testGetAll_2/foo1", "bar").prevExist(false).send().get();

  root = client.getAll().timeout(30, TimeUnit.SECONDS).send().get().getNode();
  nodes = root.getNodes();

  LOGGER.info("Nodes (2) {}", nodes);

  assertNotNull(nodes);
  assertEquals(2, nodes.size());
}
 
开发者ID:jurmous,项目名称:etcd4j,代码行数:27,代码来源:TestFunctionality.java

示例2: testGetHugeDir

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
@Test
public void testGetHugeDir() throws IOException, EtcdException, EtcdAuthenticationException, TimeoutException {
  EtcdNettyConfig config = new EtcdNettyConfig();
  config.setMaxFrameSize(1024 * 1024); // Desired max size

  EtcdNettyClient nettyClient = new EtcdNettyClient(config, URI.create("http://localhost:4001"));

  EtcdClient client = new EtcdClient(nettyClient);

  for (int i = 0; i < 2000; i++) {
    client.put("/etcd4j_test/huge-dir/node-" + i, "bar").send().get();
  }

  List<EtcdKeysResponse.EtcdNode> nodes;

  nodes = client.getDir("/etcd4j_test/huge-dir/").send().get().getNode().getNodes();
  assertNotNull(nodes);
  assertEquals(2000, nodes.size());
}
 
开发者ID:jurmous,项目名称:etcd4j,代码行数:20,代码来源:TestFunctionality.java

示例3: readNode

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
private EtcdKeysResponse.EtcdNode readNode(
        final String path,
        final Function<String, EtcdKeyGetRequest> executor) {
    return Fn.getJvm(null, () -> {
        final EtcdKeyGetRequest request = executor.apply(path);
        /** Timeout **/
        if (-1 != this.timeout) {
            request.timeout(this.timeout, TimeUnit.SECONDS);
        }
        final EtcdResponsePromise<EtcdKeysResponse> promise = request.send();
        final EtcdKeysResponse response = promise.get();
        return response.getNode();
    }, path);
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:15,代码来源:EtcdData.java

示例4: toNode

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
private KvNode toNode(EtcdKeysResponse resp) {
    EtcdKeysResponse.EtcdNode node = resp.node;
    if(node.dir) {
        // we must not return dir value
        return KvNode.dir(node.modifiedIndex);
    }
    return KvNode.leaf(node.modifiedIndex, node.value);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:9,代码来源:EtcdClientWrapper.java

示例5: cleanup

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
protected void cleanup(EtcdClient etcd) {
    try {
        for (EtcdKeysResponse.EtcdNode node: etcd.getAll().send().get().getNode().getNodes()) {
            if (node.isDir()) {
                etcd.deleteDir(node.key).recursive().send().get();
            } else {
                etcd.delete(node.key).send().get();
            }
        }
    } catch (Exception e) {}
}
 
开发者ID:jurmous,项目名称:etcd4j,代码行数:12,代码来源:EtcdKeystoreTest.java

示例6: cleanup

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
protected void cleanup() {
  try {
    for (EtcdKeysResponse.EtcdNode node: etcd.getAll().send().get().getNode().getNodes()) {
      if (node.isDir()) {
        LOGGER.info("Delete dir {}", node.key);
        etcd.deleteDir(node.key).recursive().send().get();
      } else {
        LOGGER.info("Delete entry {}", node.key);
        etcd.delete(node.key).send().get();
      }
    }
  } catch (Exception e) {
  }
}
 
开发者ID:jurmous,项目名称:etcd4j,代码行数:15,代码来源:TestFunctionality.java

示例7: cleanup

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
protected void cleanup() {
    try {
        for (EtcdKeysResponse.EtcdNode node: etcd.getAll().send().get().getNode().getNodes()) {
            if (node.isDir()) {
                LOGGER.info("Delete dir {}", node.key);
                etcd.deleteDir(node.key).recursive().send().get();
            } else {
                LOGGER.info("Delete entry {}", node.key);
                etcd.delete(node.key).send().get();
            }
        }
    } catch (Exception e) {
    }
}
 
开发者ID:jurmous,项目名称:etcd4j,代码行数:15,代码来源:EtcdJsonTest.java

示例8: read

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
public String read(final String path) {
    final EtcdKeysResponse.EtcdNode node = readNode(path, this.client::get);
    return null == node ? null : node.getValue();
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:5,代码来源:EtcdData.java

示例9: run

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
/**
 * Gets the etcd state and then waits for changes in etcd before updating the tree.
 */
@Override
public void run() {
    // Run once to get currentstate
    DiscoveryStoredNode storedRoot;
    EtcdKeysResponse.EtcdNode etcdNode;
    Tuple<EtcdKeysResponse.EtcdNode, Long> discovererData;

    Logger.getLogger(EtcdChangeHandler.class).info("Starting EtcdChangeHandler...");

    discovererData = discoverer.getFromRoot(null, false);
    if(discovererData != null) {
        etcdNode = discovererData.getT1();

        if(etcdNode != null) {
            nextModifiedIndex = discovererData.getT2();
            storedRoot = new DiscoveryStoredEtcdNode(etcdNode);

            synchronized (this) {
                cachedRoot.updateTree(storedRoot);
            }
        }
    }

    Logger.getLogger(EtcdChangeHandler.class).info("Started EtcdChangeHandler!");

    while(!this.isInterrupted()) {
        discovererData = discoverer.getFromRoot(nextModifiedIndex, true);
        if(discovererData != null) {
            etcdNode = discovererData.getT1();

            if(etcdNode != null) {
                storedRoot = new DiscoveryStoredEtcdNode(etcdNode);
                nextModifiedIndex = discovererData.getT2();

                synchronized (this) {
                    cachedRoot.updateTree(storedRoot);
                }
            }
        }
    }

    Logger.getLogger(EtcdChangeHandler.class).info("Stopped EtcdChangeHandler!");
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:47,代码来源:EtcdChangeHandler.java

示例10: DiscoveryStoredEtcdNode

import mousio.etcd4j.responses.EtcdKeysResponse; //导入方法依赖的package包/类
/**
 * Instantiates a new node using the given etcd node.
 * @param etcdNode The etcd node.
 */
public DiscoveryStoredEtcdNode(EtcdKeysResponse.EtcdNode etcdNode) {
    this.etcdNode = etcdNode;
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:8,代码来源:DiscoveryStoredEtcdNode.java


注:本文中的mousio.etcd4j.responses.EtcdKeysResponse.EtcdNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。