本文整理了Java中org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore.updateNode()
方法的一些代码示例,展示了ZookeeperMetadataStore.updateNode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperMetadataStore.updateNode()
方法的具体详情如下:
包路径:org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore
类名称: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");
}
}
}
内容来源于网络,如有侵权,请联系作者删除!