org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore.createNode()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(73)

本文整理了Java中org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore.createNode()方法的一些代码示例,展示了ZookeeperMetadataStore.createNode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperMetadataStore.createNode()方法的具体详情如下:
包路径:org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore
类名称:ZookeeperMetadataStore
方法名:createNode

ZookeeperMetadataStore.createNode介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-integration

@Override
public void put(String key, String value) {
  Assert.notNull(key, "'key' must not be null.");
  Assert.notNull(value, "'value' must not be null.");
  synchronized (this.updateMap) {
    try {
      Stat currentNode = this.client.checkExists().forPath(getPath(key));
      if (currentNode == null) {
        try {
          createNode(key, value);
        }
        catch (KeeperException.NodeExistsException e) {
          updateNode(key, value, -1);
        }
      }
      else {
        updateNode(key, value, -1);
      }
    }
    catch (Exception e) {
      throw new ZookeeperMetadataStoreException("Error while setting value for key '" + key + "':", e);
    }
  }
}

代码示例来源:origin: spring-projects/spring-integration

@Override
public String putIfAbsent(String key, String value) {
  Assert.notNull(key, "'key' must not be null.");
  Assert.notNull(value, "'value' must not be null.");
  synchronized (this.updateMap) {
    try {
      createNode(key, value);
      return null;
    }
    catch (KeeperException.NodeExistsException e) {
      // so the data actually exists, we can read it
      try {
        byte[] bytes = this.client.getData().forPath(getPath(key));
        return IntegrationUtils.bytesToString(bytes, this.encoding);
      }
      catch (Exception exceptionDuringGet) {
        throw new ZookeeperMetadataStoreException("Exception while reading node with key '" + key + "':", e);
      }
    }
    catch (Exception e) {
      throw new ZookeeperMetadataStoreException("Error while trying to set '" + key + "':", e);
    }
  }
}

代码示例来源:origin: org.springframework.integration/spring-integration-zookeeper

@Override
public String putIfAbsent(String key, String value) {
  Assert.notNull(key, "'key' must not be null.");
  Assert.notNull(value, "'value' must not be null.");
  synchronized (this.updateMap) {
    try {
      createNode(key, value);
      return null;
    }
    catch (KeeperException.NodeExistsException e) {
      // so the data actually exists, we can read it
      try {
        byte[] bytes = this.client.getData().forPath(getPath(key));
        return IntegrationUtils.bytesToString(bytes, this.encoding);
      }
      catch (Exception exceptionDuringGet) {
        throw new ZookeeperMetadataStoreException("Exception while reading node with key '" + key + "':", e);
      }
    }
    catch (Exception e) {
      throw new ZookeeperMetadataStoreException("Error while trying to set '" + key + "':", e);
    }
  }
}

代码示例来源:origin: org.springframework.integration/spring-integration-zookeeper

@Override
public void put(String key, String value) {
  Assert.notNull(key, "'key' must not be null.");
  Assert.notNull(value, "'value' must not be null.");
  synchronized (this.updateMap) {
    try {
      Stat currentNode = this.client.checkExists().forPath(getPath(key));
      if (currentNode == null) {
        try {
          createNode(key, value);
        }
        catch (KeeperException.NodeExistsException e) {
          updateNode(key, value, -1);
        }
      }
      else {
        updateNode(key, value, -1);
      }
    }
    catch (Exception e) {
      throw new ZookeeperMetadataStoreException("Error while setting value for key '" + key + "':", e);
    }
  }
}

相关文章