- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.alibaba.wasp.zookeeper.ZKUtil
类的一些代码示例,展示了ZKUtil
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil
类的具体详情如下:
包路径:com.alibaba.wasp.zookeeper.ZKUtil
类名称:ZKUtil
[英]Internal Wasp utility class for ZooKeeper.
Contains only static methods and constants.
Methods all throw org.apache.zookeeper.KeeperException if there is an unexpected zookeeper exception, so callers of these methods must handle appropriately. If ZK is required for the operation, the server will need to be aborted.
[中]动物园管理员的内部黄蜂实用类。
只包含静态方法和常量。
方法所有病例均经组织学检查。阿帕奇。动物园管理员。KeeperException如果出现意外的zookeeper异常,那么这些方法的调用方必须正确处理。如果操作需要ZK,则需要中止服务器。
代码示例来源:origin: alibaba/wasp
private void setTableState(final String tableName,
final ZooKeeperProtos.Table.State state) throws KeeperException {
String znode = ZKUtil.joinZNode(this.watcher.tableZNode, tableName);
if (ZKUtil.checkExists(this.watcher, znode) == -1) {
ZKUtil.createAndFailSilent(this.watcher, znode);
}
synchronized (this.cache) {
ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table
.newBuilder();
builder.setState(state);
byte[] data = builder.build().toByteArray();
ZKUtil.setData(this.watcher, znode, data);
this.cache.put(tableName, state);
}
}
代码示例来源:origin: alibaba/wasp
/**
* Delete the specified node. Sets no watches. Throws all exceptions.
*/
public static void deleteNode(ZooKeeperWatcher zkw, String node)
throws KeeperException {
deleteNode(zkw, node, -1);
}
代码示例来源:origin: alibaba/wasp
/**
* Deletes the table in zookeeper. Fails silently if the table is not
* currently disabled in zookeeper. Sets no watches.
*
* @param tableName
* @throws org.apache.zookeeper.KeeperException
* unexpected zookeeper exception
*/
public void setDeletedTable(final String tableName) throws KeeperException {
synchronized (this.cache) {
if (this.cache.remove(tableName) == null) {
LOG.warn("Moving table " + tableName + " state to deleted but was "
+ "already deleted");
}
ZKUtil.deleteNodeFailSilent(this.watcher,
ZKUtil.joinZNode(this.watcher.tableZNode, tableName));
}
}
代码示例来源:origin: alibaba/wasp
/**
* Set data into node creating node if it doesn't yet exist. Does not set
* watch.
*
* @param zkw
* zk reference
* @param znode
* path of node
* @param data
* data to set for node
* @throws org.apache.zookeeper.KeeperException
*/
public static void createSetData(final ZooKeeperWatcher zkw,
final String znode, final byte[] data) throws KeeperException {
if (checkExists(zkw, znode) == -1) {
ZKUtil.createWithParents(zkw, znode);
}
ZKUtil.setData(zkw, znode, data);
}
代码示例来源:origin: alibaba/wasp
/**
* List all the children of the specified znode, setting a watch for children
* changes and also setting a watch on every individual child in order to get
* the NodeCreated and NodeDeleted events.
*
* @param zkw
* zookeeper reference
* @param znode
* node to get children of and watch
* @return list of znode names, null if the node doesn't exist
* @throws org.apache.zookeeper.KeeperException
*/
public static List<String> listChildrenAndWatchThem(ZooKeeperWatcher zkw,
String znode) throws KeeperException {
List<String> children = listChildrenAndWatchForNewChildren(zkw, znode);
if (children == null) {
return null;
}
for (String child : children) {
watchAndCheckExists(zkw, joinZNode(znode, child));
}
return children;
}
代码示例来源:origin: alibaba/wasp
public static ClusterId readClusterIdZNode(ZooKeeperWatcher watcher)
throws KeeperException {
if (ZKUtil.checkExists(watcher, watcher.clusterIdZNode) != -1) {
byte[] data = ZKUtil.getData(watcher, watcher.clusterIdZNode);
if (data != null) {
try {
return ClusterId.parseFrom(data);
} catch (DeserializationException e) {
throw ZKUtil.convert(e);
}
}
}
return null;
}
代码示例来源:origin: alibaba/wasp
String backupZNode = ZKUtil.joinZNode(
this.watcher.backupMasterAddressesZNode, this.sn.toString());
if (MasterAddressTracker.setMasterAddress(this.watcher,
if (ZKUtil.checkExists(this.watcher, backupZNode) != -1) {
LOG.info("Deleting ZNode for " + backupZNode
+ " from backup master directory");
ZKUtil.deleteNodeFailSilent(this.watcher, backupZNode);
byte[] bytes = ZKUtil.getDataAndWatch(this.watcher,
this.watcher.getMasterAddressZNode());
if (bytes == null) {
msg = ("Current master has this master's address, " + currentMaster + "; master was restarted? Deleting node.");
ZKUtil.deleteNode(this.watcher,
this.watcher.getMasterAddressZNode());
代码示例来源:origin: alibaba/wasp
return;
waitForZKConnectionIfAuthenticating(zkw);
zkw.getRecoverableZooKeeper().create(znode, new byte[0],
createACL(zkw, znode), CreateMode.PERSISTENT);
} catch (KeeperException.NodeExistsException nee) {
return;
} catch (KeeperException.NoNodeException nne) {
createWithParents(zkw, getParent(znode));
createWithParents(zkw, znode);
} catch (InterruptedException ie) {
zkw.interruptedException(ie);
代码示例来源:origin: alibaba/wasp
String znode, byte[] data) throws KeeperException {
try {
waitForZKConnectionIfAuthenticating(zkw);
zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
CreateMode.EPHEMERAL);
} catch (KeeperException.NodeExistsException nee) {
if (!watchAndCheckExists(zkw, znode)) {
return createEphemeralNodeAndWatch(zkw, znode, data);
代码示例来源:origin: alibaba/wasp
ZKUtil.waitForZKConnectionIfAuthenticating(watcher);
} catch (InterruptedException e) {
throw new IllegalStateException("ZookeeperNodeTracker on " + this.node
if (ZKUtil.watchAndCheckExists(watcher, node)) {
byte[] data = ZKUtil.getDataAndWatch(watcher, node);
if (data != null) {
this.data = data;
代码示例来源:origin: alibaba/wasp
try {
this.data = ZKUtil.getDataAndWatch(watcher, node);
} catch (KeeperException e) {
if (!nodeExistsChecked) {
try {
nodeExistsChecked = (ZKUtil.checkExists(watcher, node) != -1);
} catch (KeeperException e) {
LOG.warn(
try {
this.data = ZKUtil.getDataAndWatch(watcher, node);
} catch (KeeperException e) {
LOG.warn("Unexpected exception handling blockUntilAvailable", e);
代码示例来源:origin: alibaba/wasp
/**
* @return True if cluster has an active master.
*/
public boolean isActiveMaster() {
try {
if (ZKUtil.checkExists(watcher, watcher.getMasterAddressZNode()) >= 0) {
return true;
}
}
catch (KeeperException ke) {
LOG.info("Received an unexpected KeeperException when checking "
+ "isActiveMaster : " + ke);
}
return false;
}
代码示例来源:origin: alibaba/wasp
/**
* Gets the current data in the unassigned node for the specified entityGroup
* name or fully-qualified path.
*
* <p>
* Returns null if the entityGroup does not currently have a node.
*
* <p>
* Sets a watch on the node if the node exists.
*
* @param zkw zk reference
* @param pathOrEntityGroupName fully-specified path or entityGroup name
* @return znode content
* @throws org.apache.zookeeper.KeeperException if unexpected zookeeper exception
*/
public static byte[] getData(ZooKeeperWatcher zkw, String pathOrEntityGroupName)
throws KeeperException {
String node = getPath(zkw, pathOrEntityGroupName);
return ZKUtil.getDataAndWatch(zkw, node);
}
代码示例来源:origin: alibaba/wasp
String node = getNodeName(zkw, entityGroup.getEncodedName());
zkw.sync(node);
int version = ZKUtil.checkExists(zkw, node);
if (version == -1) {
return ZKUtil.createAndWatch(zkw, node, data);
} else {
boolean setData = false;
try {
setData = ZKUtil.setData(zkw, node, data, version);
代码示例来源:origin: alibaba/wasp
/**
* Blocks until there is at least one node in entityGroups in transition.
* <p>
* Used in testing only.
* @param zkw zk reference
* @throws org.apache.zookeeper.KeeperException
* @throws InterruptedException
*/
public static void blockUntilRIT(ZooKeeperWatcher zkw)
throws KeeperException, InterruptedException {
while (!ZKUtil.nodeHasChildren(zkw, zkw.assignmentZNode)) {
List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
zkw.assignmentZNode);
if (znodes == null || znodes.isEmpty()) {
LOG.debug("No RIT in ZK");
}
Thread.sleep(100);
}
}
代码示例来源:origin: alibaba/wasp
/**
* delete the master znode if its content is same as the parameter
*/
public static boolean deleteIfEquals(ZooKeeperWatcher zkw,
final String content) {
if (content == null) {
throw new IllegalArgumentException("Content must not be null");
}
try {
Stat stat = new Stat();
byte[] data = ZKUtil.getDataNoWatch(zkw, zkw.getMasterAddressZNode(),
stat);
ServerName sn = ServerName.parseFrom(data);
if (sn != null && content.equals(sn.toString())) {
return (ZKUtil.deleteNode(zkw, zkw.getMasterAddressZNode(),
stat.getVersion()));
}
} catch (KeeperException e) {
LOG.warn("Can't get or delete the master znode", e);
} catch (DeserializationException e) {
LOG.warn("Can't get or delete the master znode", e);
}
return false;
}
}
代码示例来源:origin: alibaba/wasp
String nodeName = ZKAssign.getNodeName(zkw, entityGroup
.getEntityGroupInfo().getEncodedName());
ZKUtil.getDataAndWatch(zkw, nodeName, stat);
List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
zkw.assignmentZNode);
String entityGroupName = znodes.get(0);
代码示例来源:origin: alibaba/wasp
byte[] data, final AsyncCallback.StringCallback cb, final Object ctx) {
try {
waitForZKConnectionIfAuthenticating(zkw);
zkw.getRecoverableZooKeeper().getZooKeeper().create(znode, data,
createACL(zkw, znode), CreateMode.PERSISTENT, cb, ctx);
} catch (InterruptedException e) {
zkw.interruptedException(e);
代码示例来源:origin: alibaba/wasp
/**
* Delete the assignment node regardless of its current state.
* <p>
* Fail silent even if the node does not exist at all.
* @param watcher
* @param entityGroupInfo
* @throws org.apache.zookeeper.KeeperException
*/
public static void deleteNodeFailSilent(ZooKeeperWatcher watcher,
EntityGroupInfo entityGroupInfo) throws KeeperException {
String node = getNodeName(watcher, entityGroupInfo.getEncodedName());
ZKUtil.deleteNodeFailSilent(watcher, node);
}
代码示例来源:origin: alibaba/wasp
nodes = ZKUtil.listChildrenAndWatchForNewChildren(this.watcher,
this.watcher.assignmentZNode);
if (!nodes.isEmpty()) {
鉴权中心服务 认识JWT json web token 是一个开放的标准 ,它定义了一个种紧凑的,自包含的方式,用于作为json对象在各方之间安全的传输信息 服务器鉴权完成之后 会生成 json 对象
我正在使用阿里巴巴的对象存储服务的图像处理来处理我的图像。我需要一种方法来将一些图像连接(拼接)在一起并创建一个更大的图像。 背景:我想使用 OSS 图像处理将图像放大到 7680 × 4320 (8
SpringCloud 一、微服务概述 集群:cluster 同一种软件服务的多个服务节点共同为系统提供服务过程 称之为该软件服务集群 分布式:distribute 不同软件集群共同为一个系统提供服务
前置内容 1、SpringCloud Alibaba简介和Nacos【注册中心】 1、Nacos(下) 1.1、服务配置中心演示 1.1.1、基础配置 1. 建Module Module的名称为clo
Seata安装 Windows下安装 下载并解压缩:http://seata.io/zh-cn/blog/download.html 修改conf/file.conf文件 将mode="file"改为
Sentinel 是什么 随着微服务的流行,服务和服务之间的稳定性变得越来越重要。Sentinel 以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。 官网:http
1 本地调试介绍 本地调试: 这里是指在开发环境中,部署了一整套的某个项目或者产品的服务,开发人员开发时,本地会起一个或多个服务,这些服务和开发环境中部署的服务是相同的,这种情况下,一个服务就会有
前言: Sentinel的如果没有配置持久化的话配置一些 流控 和服务降级 从启项目就会置空所以需要持久化的操作 动态规则扩展 拉模式:客户端主动向某个规则管理中心定期轮询拉取规则,这个规则中心
首先从github上下载nacos的压缩包:https://github.com/alibaba/nacos/releases 下载完成之后,通过WinSCP把文件传到linux服务器上 接着
本文整理了Java中com.alibaba.wasp.zookeeper.ZKAssign类的一些代码示例,展示了ZKAssign类的具体用法。这些代码示例主要来源于Github/Stackoverf
本文整理了Java中com.alibaba.wasp.zookeeper.ZKUtil类的一些代码示例,展示了ZKUtil类的具体用法。这些代码示例主要来源于Github/Stackoverflow/
本文整理了Java中com.alibaba.wasp.zookeeper.ZooKeeperWatcher类的一些代码示例,展示了ZooKeeperWatcher类的具体用法。这些代码示例主要来源于G
目录 1、SpringBoot 使用 Nacos Config 实现多环境切换 1. 现象 2. 引入依赖 3. 添加bootst
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界. 这篇CFSDN的博客文章Spring Cloud Alibaba Nacos 入门详解由作者收集
本文整理了Java中com.alibaba.dubbo.common.json.Yylex类的一些代码示例,展示了Yylex类的具体用法。这些代码示例主要来源于Github/Stackoverflow
本文整理了Java中com.alibaba.dubbo.remoting.zookeeper.ZookeeperClient类的一些代码示例,展示了ZookeeperClient类的具体用法。这些代码
本文整理了Java中com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry类的一些代码示例,展示了ZookeeperRegistry类的具体用法。
本文整理了Java中com.alibaba.otter.canal.common.zookeeper.ZkClientx类的一些代码示例,展示了ZkClientx类的具体用法。这些代码示例主要来源于G
本文整理了Java中com.alibaba.otter.canal.common.zookeeper.ZookeeperPathUtils类的一些代码示例,展示了ZookeeperPathUtils类
本文整理了Java中com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient类的一些代码示例,展示了ZkclientZ
我是一名优秀的程序员,十分优秀!