- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.liveramp.hank.zookeeper.ZooKeeperPlus.getData()
方法的一些代码示例,展示了ZooKeeperPlus.getData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperPlus.getData()
方法的具体详情如下:
包路径:com.liveramp.hank.zookeeper.ZooKeeperPlus
类名称:ZooKeeperPlus
方法名:getData
暂无
代码示例来源:origin: LiveRamp/hank
public String getString(String path) throws KeeperException, InterruptedException {
try {
byte[] data = getData(path, false, null);
if (data == null) {
return null;
}
return new String(data, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: LiveRamp/hank
public int getInt(String path) throws KeeperException, InterruptedException {
return Integer.parseInt(new String(getData(path, false, new Stat())));
}
代码示例来源:origin: LiveRamp/hank
public long getLong(String path) throws KeeperException, InterruptedException {
return Long.parseLong(new String(getData(path, false, new Stat())));
}
代码示例来源:origin: LiveRamp/hank
public Long getLongOrNull(String path) throws KeeperException, InterruptedException {
if (exists(path, false) == null) {
return null;
} else {
return Long.parseLong(new String(getData(path, false, new Stat())));
}
}
代码示例来源:origin: LiveRamp/hank
public static Boolean get(ZooKeeperPlus zk, String nodePath) throws InterruptedException, KeeperException {
return decodeValue(zk.getData(nodePath, null, null));
}
代码示例来源:origin: LiveRamp/hank
public static Integer get(ZooKeeperPlus zk, String nodePath) throws InterruptedException, KeeperException {
return decodeValue(zk.getData(nodePath, null, null));
}
代码示例来源:origin: LiveRamp/hank
private boolean watchForData() throws InterruptedException, KeeperException {
if (LOG.isTraceEnabled()) {
LOG.trace(String.format("Getting value for %s", nodePath));
}
try {
synchronized (this) {
value = decode(zk.getData(nodePath, watcher, stat));
return true;
}
} catch (KeeperException.NoNodeException e) {
watchForCreation();
return false;
}
}
代码示例来源:origin: LiveRamp/hank
private void dumpZk(String parentPath, String nodeName, int depth) throws Exception {
System.err.print(StringUtils.repeat(" ", depth));
System.err.print("/" + nodeName);
String nodePath = ZkPath.append(parentPath, nodeName);
nodePath = nodePath.replace("//", "/");
byte[] data = zk.getData(nodePath, false, null);
if (data == null) {
System.err.print(" -> null");
} else {
System.err.print(" -> [bytes]");
}
System.err.println();
List<String> children = zk.getChildren(nodePath, false);
for (String child : children) {
dumpZk(nodePath, child, depth + 1);
}
}
代码示例来源:origin: LiveRamp/hank
private int getNextDomainId() throws KeeperException, InterruptedException {
final String domainIdCounterPath = ZkPath.append(domainsRoot, KEY_DOMAIN_ID_COUNTER);
if (zk.exists(domainIdCounterPath, false) == null) {
zk.create(domainIdCounterPath, Integer.toString(1).getBytes());
return 1;
}
while (true) {
final Stat stat = new Stat();
final byte[] data = zk.getData(domainIdCounterPath, false, stat);
int lastVersionNumber = Integer.parseInt(new String(data));
try {
lastVersionNumber++;
zk.setData(domainIdCounterPath, Integer.toString(lastVersionNumber).getBytes(), stat.getVersion());
return lastVersionNumber;
} catch (KeeperException.BadVersionException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Tried to set the domain id counter to " + lastVersionNumber + " but was preempted by another writer. Retrying.");
}
}
}
}
代码示例来源:origin: LiveRamp/hank
@Override
public String load(ZooKeeperPlus zk, String basePath, String relPath) {
try {
return new String(zk.getData(ZkPath.append(basePath, relPath), false, new Stat()));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: LiveRamp/hank
@Test
public void testIt() throws Exception {
final ZooKeeperPlus zk = getZk();
zk.ensureCreated("/", null, CreateMode.PERSISTENT);
assertExists("/", zk);
zk.ensureCreated("/simple", "1".getBytes(), CreateMode.PERSISTENT);
assertExists("/simple", zk);
zk.ensureCreated("/simple", "2".getBytes(), CreateMode.PERSISTENT);
assertExists("/simple", zk);
assertTrue(Arrays.equals(zk.getData("/simple", false, null), "1".getBytes()));
zk.ensureCreated("/deeper/file", null, CreateMode.PERSISTENT);
assertExists("/deeper/file", zk);
assertExists("/deeper", zk);
zk.ensureCreated("/simple/even/deeper", "3".getBytes(), CreateMode.PERSISTENT);
assertTrue(Arrays.equals(zk.getData("/simple", false, null), "1".getBytes()));
}
代码示例来源:origin: LiveRamp/hank
@Test
public void testIt() throws Exception {
final ZooKeeperPlus zk = getZk();
final String colRoot = ZkPath.append(getRoot(), "collection");
zk.create(colRoot, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
final ElementLoader<String> elementLoader = (zk1, basePath, relPath) -> {
try {
return new String(zk1.getData(ZkPath.append(basePath, relPath), false, new Stat()));
} catch (Exception e) {
throw new RuntimeException(e);
}
};
final WatchedMap<String> c1 = new WatchedMap<>(zk, colRoot, elementLoader);
dumpZk();
WaitUntil.orDie(() -> 0 == c1.size());
assertEquals(0, c1.size());
zk.create(ZkPath.append(colRoot, "first"), "data".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
WaitUntil.orDie(() -> 1 == c1.size());
assertEquals(1, c1.size());
}
本文整理了Java中com.liveramp.hank.zookeeper.ZooKeeperPlus.setData()方法的一些代码示例,展示了ZooKeeperPlus.setData()的具体
本文整理了Java中com.liveramp.hank.zookeeper.ZooKeeperPlus.getData()方法的一些代码示例,展示了ZooKeeperPlus.getData()的具体
本文整理了Java中com.liveramp.hank.zookeeper.ZooKeeperPlus.exists()方法的一些代码示例,展示了ZooKeeperPlus.exists()的具体用法
本文整理了Java中com.liveramp.hank.zookeeper.ZooKeeperPlus.delete()方法的一些代码示例,展示了ZooKeeperPlus.delete()的具体用法
我是一名优秀的程序员,十分优秀!