- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.griddynamics.jagger.coordinator.zookeeper.ZNode
类的一些代码示例,展示了ZNode
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZNode
类的具体详情如下:
包路径:com.griddynamics.jagger.coordinator.zookeeper.ZNode
类名称:ZNode
[英]A simple API for interaction with zookeeper's znodes.
[中]一个与zookeeper的znodes交互的简单API。
代码示例来源:origin: griddynamics/jagger
@Override
public Set<NodeId> getAvailableNodes(NodeType type) {
Set<NodeId> result = Sets.newHashSet();
ZNode typeNode = rootNode.child(CoordinationUtil.nodeNameOf(type));
for (ZNode node : typeNode.children()) {
if (node.hasChild(CoordinationUtil.AVAILABLE_NODE_NAME)) {
result.add(NodeId.of(type, node.getShortPath()));
}
}
return result;
}
代码示例来源:origin: griddynamics/jagger
@Override
public void terminate() {
log.debug("termination signal received");
if(zooKeeperServer != null) {
try {
if (zoo != null) {
zoo.root().child(rootNode).removeWithChildren();
}
zooKeeperServer.shutdown();
} catch (Exception e) {
log.warn("Error during zookeeper termination. Message: {}", e.getMessage());
}
}
}
代码示例来源:origin: griddynamics/jagger
@Override
public void waitForInitialization() {
log.info("Waiting for coordination znode structure structure initialization");
while (true) {
boolean initialized = rootNode.exists() && rootNode.hasChild(CoordinationUtil.STATUSES_NODE_NAME);
if (initialized) {
log.info("Coordination znode structure initialized");
break;
}
try {
Thread.sleep(INITIALIZATION_SLEEP_PERIOD);
log.info("Znode structure is not initialized. Waiting {} ms", INITIALIZATION_SLEEP_PERIOD);
} catch (InterruptedException e) {
log.warn("Sleep interrupted", e);
}
}
}
代码示例来源:origin: griddynamics/jagger
private <C extends Command<R>, R extends Serializable> List<QueueEntry<C, R>> getEntries(ZNode queueNode, Watcher watcher) {
List<QueueEntry<C, R>> result = Lists.newLinkedList();
List<ZNode> children = queueNode.firstLevelChildren(watcher);
Collections.sort(children, new Comparator<ZNode>() {
@Override
public int compare(ZNode first, ZNode second) {
return first.getPath().compareTo(second.getPath());
}
});
for (ZNode child : children) {
QueueEntry<C, R> entry = child.getObject(QueueEntry.class, classLoaderHolder.get());
child.remove();
result.add(entry);
}
return result;
}
代码示例来源:origin: griddynamics/jagger
log.info("Going to register node {} with {} workers", nodeContext.getId(), workers.size());
ZNode typeNode = rootNode.child(CoordinationUtil.nodeNameOf(nodeContext.getId().getType()));
if (typeNode.hasChild(nodeContext.getId().getIdentifier())) {
typeNode.child(nodeContext.getId().getIdentifier()).removeWithChildren();
ZNode node = typeNode.createChild(znode().withPath(nodeContext.getId().getIdentifier()));
rootNode.addNodeWatcher(new Watcher() {
@Override
public void process(WatchedEvent event) {
ZNode statuses = rootNode.child(CoordinationUtil.STATUSES_NODE_NAME);
statuses.createChild(znode().ephemeralSequential().withDataObject(nodeContext.getId()));
Collection<NodeId> nodeIds = Sets.newHashSet();
StatusWatcher statusWatcher = new StatusWatcher(statuses, lock, nodeIds, listener);
List<ZNode> nodes = statuses.children(statusWatcher);
for (ZNode zNode : nodes) {
nodeIds.add(zNode.getObject(NodeId.class));
node.createChild(znode().withPath(CoordinationUtil.AVAILABLE_NODE_NAME));
代码示例来源:origin: griddynamics/jagger
public void initialize() {
ZooKeeperFactory zooKeeperFactory = new ZooKeeperFactory();
zooKeeperFactory.setConnectString(endpoint);
zooKeeperFactory.setSessionTimeout(sessionTimeout);
log.info("Connect to {} endpoint with timeout {}", endpoint, sessionTimeout);
IZookeeper zooKeeper = null;
try {
zooKeeper = zooKeeperFactory.create();
zoo = new Zoo(zooKeeperFactory.create());
// TODO: timeout only 40000. svi.
if (zoo.root().hasChild(rootNode)) {
log.info("ZNode [" + rootNode + "] was found.");
zoo.root().child(rootNode).removeWithChildren();
log.info("ZNode [" + rootNode + "] with children nodes were removed.");
}
zoo.root().createChild(znode().withPath(rootNode));
log.info("ZNode [" + rootNode + "] was created.");
} finally {
if (zooKeeper != null) {
try {
zooKeeper.close();
} catch (InterruptedException e) {
// do nothing
}
}
}
}
代码示例来源:origin: griddynamics/jagger
@Override
public void lock() {
while (true) {
ZNode node = lockDir().createChild(znode().ephemeralSequential());
final String currentNodeName = node.getShortPath();
int currentFlag = Integer.valueOf(currentNodeName);
final List<ZNode> children = lockDir().children();
int lowestNodeVal = Integer.MAX_VALUE;
int nextNodeFlag = -1;
String childPath = child.getShortPath();
int childFlag = Integer.valueOf(childPath);
boolean hasChild = lockDir().hasChild(nextNodePath, new Watcher() {
@Override
public void process(WatchedEvent event) {
node.remove();
代码示例来源:origin: griddynamics/jagger
@Override
public <C extends Command<R>, R extends Serializable> void run(final C command, final NodeCommandExecutionListener<C> listener, final AsyncCallback<R> callback) {
ZNode commandNode = rootNode.child(nodeId.getType().name().toLowerCase()).child(nodeId.getIdentifier()).child(command.getClass().getName());
ZNode queueNode = commandNode.child("queue");
ZNode resultNode = commandNode.child("result");
final ZNode outputNode = resultNode.createChild(znode().persistentSequential());
outputNode.addNodeWatcher(new Watcher() {
@Override
public void process(WatchedEvent event) {
queueNode.createChild(
znode()
.persistentSequential()
.withDataObject(new QueueEntry<C, R>(command, listener, outputNode.getPath()))
);
log.debug("command {} is ready to be executed", command);
代码示例来源:origin: griddynamics/jagger
@Override
public boolean canExecuteCommands(NodeId nodeId, Set<Qualifier<?>> qualifiers) {
ZNode typeNode = rootNode.child(CoordinationUtil.nodeNameOf(nodeId.getType()));
String identifier = nodeId.getIdentifier();
if (!typeNode.hasChild(identifier)) {
throw new CoordinatorException("Node with id " + nodeId + " is not found");
}
ZNode node = typeNode.child(identifier);
if (!node.hasChild(CoordinationUtil.AVAILABLE_NODE_NAME)) {
return false;
}
for (Qualifier<?> qualifier : qualifiers) {
if (!node.hasChild(nodeNameOf(qualifier))) {
return false;
}
}
return true;
}
代码示例来源:origin: griddynamics/jagger
@Override
public void initialize() {
log.info("Going to initialize required znode structure in zookeeper");
for (NodeType type : NodeType.values()) {
String child = CoordinationUtil.nodeNameOf(type);
if (!rootNode.hasChild(child)) {
rootNode.createChild(znode().withPath(child));
log.info("Created Zookeeper node {}", child);
}
}
if (!rootNode.hasChild(CoordinationUtil.STATUSES_NODE_NAME)) {
rootNode.createChild(znode().withPath(CoordinationUtil.STATUSES_NODE_NAME));
log.info("Created Zookeeper node {}", CoordinationUtil.STATUSES_NODE_NAME);
}
log.info("Successfully initialized");
}
代码示例来源:origin: griddynamics/jagger
private static <C extends Command<R>, R extends Serializable> void executeCommand(CommandExecutor<C, R> executor, ZNode executorNode, final QueueEntry<C, R> entry, final NodeContext nodeContext) {
String relativePath = entry.getResultPath().substring(executorNode.getPath().length() + 1);
final ZNode output = executorNode.child(relativePath);
final NodeCommandExecutionListener<C> listener = entry.getListener();
try {
C command = entry.getCommand();
listener.onCommandExecutionStarted(command, nodeContext);
R result = executor.execute(command, nodeContext);
log.debug("Command {} executed", command);
listener.onCommandExecuted(command);
output.setObject(CommandExecutionResult.success(result));
} catch (Throwable throwable) {
// todo add fail event
log.error("error during task execution", throwable);
output.setObject(CommandExecutionResult.fail(throwable));
}
}
代码示例来源:origin: griddynamics/jagger
private <C extends Command<R>, R extends Serializable> void registerExecutor(final NodeContext nodeContext, final CommandExecutor<C, R> executor, ZNode node) {
final ZNode executorNode = node.createChild(znode().withPath(nodeNameOf(executor.getQualifier())));
final ZNode queueNode = executorNode.createChild(znode().withPath("queue"));
executorNode.createChild(znode().withPath("result"));
log.debug("Created znodes for executor {}", executorNode.getPath());
queueNode.addChildrenWatcher(new Watcher() {
@Override
public void process(WatchedEvent event) {
if (event.getType() != Event.EventType.NodeChildrenChanged) {
return;
}
synchronized (lock) {
if (log.isDebugEnabled()) {
log.debug("Children changed {} event type {}", queueNode.getPath(), event.getType());
}
List<QueueEntry<C, R>> entries = getEntries(queueNode, this);
for (final QueueEntry<C, R> entry : entries) {
Runnable run = new Runnable() {
@Override
public void run() {
executeCommand(executor, executorNode, entry, nodeContext);
}
};
ZookeeperCoordinator.this.executor.execute(run);
}
}
}
});
}
代码示例来源:origin: griddynamics/jagger
@Override
public void process(WatchedEvent event) {
log.debug("command {} execution done", command);
CommandExecutionResult result = outputNode.getObject(CommandExecutionResult.class);
switch (result.getStatus()) {
case SUCCEEDED:
log.debug("success");
callback.onSuccess((R) result.getResult());
break;
case FAILED:
Throwable e = result.getException();
log.error("fail", e);
callback.onFailure(e);
break;
default:
throw new IllegalStateException("Unknown status");
}
outputNode.removeWithChildren();
}
});
代码示例来源:origin: griddynamics/jagger
@Override
public boolean isLockable() {
return node.hasChild(lockPath);
}
代码示例来源:origin: griddynamics/jagger
private ZNode lockDir() {
return node.child(lockPath);
}
代码示例来源:origin: griddynamics/jagger
public void run() {
lock.lock();
try {
List<ZNode> children = node.children();
Collection<NodeId> newIds = Sets.newHashSet();
for (ZNode child : children) {
newIds.add(child.getObject(NodeId.class));
}
Collection<NodeId> copy = Sets.newHashSet(newIds);
newIds.removeAll(currentIds);
currentIds.removeAll(copy);
for (NodeId newId : newIds) {
statusChangeListener.onNodeStatusChanged(newId, NodeStatus.AVAILABLE);
}
for (NodeId newId : currentIds) {
statusChangeListener.onNodeStatusChanged(newId, NodeStatus.DISCONNECTED);
}
currentIds = copy;
} finally {
lock.unlock();
}
}
};
代码示例来源:origin: griddynamics/jagger
@Override
public void removeWithChildren() {
for (ZNode zNode : children()) {
zNode.removeWithChildren();
}
remove();
}
代码示例来源:origin: griddynamics/jagger
@Override
public void makeLockable() {
node.createChild(znode().withPath(lockPath));
}
代码示例来源:origin: griddynamics/jagger
@Override
public void waitForReady() {
while (true) {
try {
rootNode.exists();
break;
} catch (Throwable e) {
// do nothing
}
try {
Thread.sleep(INITIALIZATION_SLEEP_PERIOD);
log.info("Znode structure is not initialized. Waiting {} ms", INITIALIZATION_SLEEP_PERIOD);
} catch (InterruptedException e) {
log.warn("Sleep interrupted", e);
}
}
}
代码示例来源:origin: griddynamics/jagger
node.addChildrenWatcher(this);
我正在开发一个使用 ZooKeeper 作为数据存储的应用程序。对于应用程序中的其中一种方法,我需要使用乐观并发控制。比如我需要实现一个获取znode数据的get方法,我使用znode数据版本进行乐观
我刚开始阅读有关动物园管理员的信息。我对数据复制和数据模块感到困惑。 ZooKeeper 集成将包含多个节点(机器),其中一个领导者和其他人作为追随者。 数据模块是一个树形结构,每个节点为znode。
我正在使用 zookeeper 进行分布式锁定。用例需要锁定分层命名空间,因此我们使用持久性 znode。我们为此使用了 apache-curator。 问题是 znode 数量不断增加,性能会受到影
我想将kafka znodes设置在另一个znode而不是root上。 例如 kafka的默认znode是: /admin /brokers /cluster /config 但我想重新组织它们并将其
这是zookeeper监控的输出 zk_version 3.4.6-1569965, built on 02/20/2014 09:09 GMT zk_avg_latency 0
我已经在 ubuntu 12.04 上安装了 hadoop 2.2.0 & hbase-0.94.18。当我尝试运行命令时 create 't1','c1' 在 hbase shell 中,我得到以下
我按照说明设置 OpenTSDB:http://opentsdb.net/getting-started.html和 http://opentsdb.net/setup-hbase.html .在我使
以下是我的假设/疑问。如果我的理解有错误请指出 通过阅读文档,我了解到 Zookeeper 向 Leader 写入数据,然后将其复制到 Follower。读取请求可以由跟随者(从属)本身提供。因此读取
是否可以通过 Zookeeper CLI 读取带有空格的 znode? 我在区域下有 2 个值('us-west 1' 和 'us-east') [zk: localhost:2181(CONNEC
比如有一个znode路径A/B/C/D。我想在那个 znode 上存储一个字符串列表。显然,我可以使用将字符串列表连接到单个字符串中,然后将其序列化为字节数组,如下所示: curator.create
我正在尝试学习 Hadoop,并且我已经达到了 Hadoop 权威指南中的 HBase 部分。我试图启动 HBase 但出现错误。有人可以给我分步指南吗? opel@ubuntu:~$ zkServe
本文整理了Java中com.griddynamics.jagger.coordinator.zookeeper.ZNode.child()方法的一些代码示例,展示了ZNode.child()的具体用法
本文整理了Java中com.griddynamics.jagger.coordinator.zookeeper.ZNode.removeWithChildren()方法的一些代码示例,展示了ZNode
本文整理了Java中com.griddynamics.jagger.coordinator.zookeeper.ZNode.hasChild()方法的一些代码示例,展示了ZNode.hasChild(
本文整理了Java中com.griddynamics.jagger.coordinator.zookeeper.ZNode.createChild()方法的一些代码示例,展示了ZNode.create
本文整理了Java中org.apache.helix.store.zk.ZNode.addChildren()方法的一些代码示例,展示了ZNode.addChildren()的具体用法。这些代码示例主
本文整理了Java中org.apache.helix.store.zk.ZNode.getStat()方法的一些代码示例,展示了ZNode.getStat()的具体用法。这些代码示例主要来源于Gith
本文整理了Java中org.apache.helix.store.zk.ZNode.getChildSet()方法的一些代码示例,展示了ZNode.getChildSet()的具体用法。这些代码示例主
本文整理了Java中org.apache.helix.store.zk.ZNode.getData()方法的一些代码示例,展示了ZNode.getData()的具体用法。这些代码示例主要来源于Gith
我正在尝试创建一个持久的 ZNode 并存储我已处理的特定文件的行数。创建工作正常,从节点读取数据也是如此,但如果在相同的代码中,删除则不起作用。我会解释我的意思。 我创建了函数: setOrCrea
我是一名优秀的程序员,十分优秀!