本文整理汇总了Java中com.basho.riak.client.api.commands.kv.StoreValue类的典型用法代码示例。如果您正苦于以下问题:Java StoreValue类的具体用法?Java StoreValue怎么用?Java StoreValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StoreValue类属于com.basho.riak.client.api.commands.kv包,在下文中一共展示了StoreValue类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import com.basho.riak.client.api.commands.kv.StoreValue; //导入依赖的package包/类
@Override
public void put(Buffer stream, Callback<Boolean> callback) {
BufferIterator it = stream.iterator();
List<StoreValue> all = new ArrayList<StoreValue>();
while (it.hasNext()) {
Buffer keyView = it.next();
Buffer valueView = it.next();
if (valueView != null) {
try {
Location location = new Location(_ns, new String(keyView.data()));
RiakObject riakObject = new RiakObject();
riakObject.setValue(BinaryValue.create(valueView.data()));
StoreValue store = new StoreValue.Builder(riakObject)
.withLocation(location)
.withOption(StoreValue.Option.W, new Quorum(3))
.build();
all.add(store);
} catch (Exception e) {
e.printStackTrace();
}
}
}
//CountDownLatch latch = new CountDownLatch(all.size());
final DeferCounter counter = _graph.newCounter(all.size());
counter.then(() -> {
callback.on(true);
});
for (int i = 0; i < all.size(); i++) {
/*
try {
_client.execute(all.get(i));
counter.count();
} catch (Exception e) {
e.printStackTrace();
}*/
_client.executeAsync(all.get(i)).addListener(new RiakFutureListener<StoreValue.Response, Location>() {
@Override
public void handle(RiakFuture<StoreValue.Response, Location> f) {
//latch.countDown();
counter.count();
}
});
}
/*
try {
latch.await();
callback.on(true);
} catch (InterruptedException e) {
e.printStackTrace();
}*/
}