本文整理汇总了Java中org.apache.curator.framework.api.GetDataBuilder.storingStatIn方法的典型用法代码示例。如果您正苦于以下问题:Java GetDataBuilder.storingStatIn方法的具体用法?Java GetDataBuilder.storingStatIn怎么用?Java GetDataBuilder.storingStatIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.curator.framework.api.GetDataBuilder
的用法示例。
在下文中一共展示了GetDataBuilder.storingStatIn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getData
import org.apache.curator.framework.api.GetDataBuilder; //导入方法依赖的package包/类
private <T> Optional<T> getData(String path, Optional<Stat> stat, Transcoder<T> transcoder, Optional<ZkCache<T>> zkCache, Optional<Boolean> shouldCheckExists) {
if (!stat.isPresent() && zkCache.isPresent()) {
Optional<T> cachedValue = zkCache.get().get(path);
if (cachedValue.isPresent() && (!shouldCheckExists.isPresent() || (shouldCheckExists.get().booleanValue() && checkExists(path).isPresent()))) {
return cachedValue;
}
}
final long start = System.currentTimeMillis();
int bytes = 0;
try {
GetDataBuilder bldr = curator.getData();
if (stat.isPresent()) {
bldr.storingStatIn(stat.get());
}
byte[] data = bldr.forPath(path);
if (data == null || data.length == 0) {
LOG.trace("Empty data found for path {}", path);
return Optional.absent();
}
bytes = data.length;
final T object = transcoder.fromBytes(data);
if (zkCache.isPresent()) {
zkCache.get().set(path, object);
}
return Optional.of(object);
} catch (NoNodeException nne) {
return Optional.absent();
} catch (Throwable t) {
throw Throwables.propagate(t);
} finally {
log(OperationType.READ, Optional.<Integer> absent(), Optional.<Integer> of(bytes), start, path);
}
}
示例2: getData
import org.apache.curator.framework.api.GetDataBuilder; //导入方法依赖的package包/类
private <T> Optional<T> getData(String path, Optional<Stat> stat, Transcoder<T> transcoder, Optional<ZkCache<T>> zkCache, Optional<Boolean> shouldCheckExists) {
if (!stat.isPresent() && zkCache.isPresent()) {
Optional<T> cachedValue = zkCache.get().get(path);
if (cachedValue.isPresent() && (!shouldCheckExists.isPresent() || (shouldCheckExists.get().booleanValue() && checkExists(path).isPresent()))) {
return cachedValue;
}
}
final long start = System.currentTimeMillis();
int bytes = 0;
try {
GetDataBuilder bldr = curator.getData();
if (stat.isPresent()) {
bldr.storingStatIn(stat.get());
}
byte[] data = bldr.forPath(path);
if (data == null || data.length == 0) {
LOG.trace("Empty data found for path {}", path);
return Optional.absent();
}
bytes = data.length;
final T object = transcoder.fromBytes(data);
if (zkCache.isPresent()) {
zkCache.get().set(path, object);
}
return Optional.of(object);
} catch (NoNodeException nne) {
LOG.trace("No node found for path {}", path);
return Optional.absent();
} catch (Throwable t) {
throw Throwables.propagate(t);
} finally {
log(OperationType.GET, Optional.absent(), Optional.<Integer> of(bytes), start, path);
}
}