gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-13 13:25:12 28 4
gpt4 key购买 nike

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

ZookeeperMetadataStore.updateNode介绍

暂无

代码示例

代码示例来源: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 boolean replace(String key, String oldValue, String newValue) {
  Assert.notNull(key, "'key' must not be null.");
  Assert.notNull(oldValue, "'oldValue' must not be null.");
  Assert.notNull(newValue, "'newValue' must not be null.");
  synchronized (this.updateMap) {
    Stat currentStat = new Stat();
    try {
      byte[] bytes = this.client.getData().storingStatIn(currentStat).forPath(getPath(key));
      if (oldValue.equals(IntegrationUtils.bytesToString(bytes, this.encoding))) {
        updateNode(key, newValue, currentStat.getVersion());
      }
      return true;
    }
    catch (KeeperException.NoNodeException e) {
      // ignore, the node doesn't exist there's nothing to replace
      return false;
    }
    catch (KeeperException.BadVersionException e) {
      // ignore
      return false;
    }
    catch (Exception e) {
      throw new ZookeeperMetadataStoreException("Cannot replace value");
    }
  }
}

代码示例来源: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);
    }
  }
}

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

@Override
public boolean replace(String key, String oldValue, String newValue) {
  Assert.notNull(key, "'key' must not be null.");
  Assert.notNull(oldValue, "'oldValue' must not be null.");
  Assert.notNull(newValue, "'newValue' must not be null.");
  synchronized (this.updateMap) {
    Stat currentStat = new Stat();
    try {
      byte[] bytes = this.client.getData().storingStatIn(currentStat).forPath(getPath(key));
      if (oldValue.equals(IntegrationUtils.bytesToString(bytes, this.encoding))) {
        updateNode(key, newValue, currentStat.getVersion());
      }
      return true;
    }
    catch (KeeperException.NoNodeException e) {
      // ignore, the node doesn't exist there's nothing to replace
      return false;
    }
    catch (KeeperException.BadVersionException e) {
      // ignore
      return false;
    }
    catch (Exception e) {
      throw new ZookeeperMetadataStoreException("Cannot replace value");
    }
  }
}

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