gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-20 22:00:48 27 4
gpt4 key购买 nike

本文整理了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);
    }
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com