本文整理汇总了Java中io.vertx.core.spi.cluster.ChoosableIterable类的典型用法代码示例。如果您正苦于以下问题:Java ChoosableIterable类的具体用法?Java ChoosableIterable怎么用?Java ChoosableIterable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChoosableIterable类属于io.vertx.core.spi.cluster包,在下文中一共展示了ChoosableIterable类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: get
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
@Override
public void get(K k, Handler<AsyncResult<ChoosableIterable<V>>> asyncResultHandler) {
if (!keyIsNull(k, asyncResultHandler)) {
vertx.runOnContext(event -> {
Map<String, ChildData> maps = curatorCache.getCurrentChildren(keyPath(k));
ChoosableSet<V> choosableSet = new ChoosableSet<>(0);
if (maps != null) {
for (ChildData childData : maps.values()) {
try {
if (childData != null && childData.getData() != null && childData.getData().length > 0)
choosableSet.add(asObject(childData.getData()));
} catch (Exception ex) {
asyncResultHandler.handle(Future.failedFuture(ex));
}
}
}
asyncResultHandler.handle(Future.succeededFuture(choosableSet));
});
}
}
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:21,代码来源:ZKAsyncMultiMap.java
示例2: get
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
@Override
public void get(K k, Handler<AsyncResult<ChoosableIterable<V>>> resultHandler) {
ContextImpl context = vertx.getOrCreateContext();
@SuppressWarnings("unchecked")
Queue<GetRequest<K, V>> getRequests = (Queue<GetRequest<K, V>>) context.contextData().computeIfAbsent(this, ctx -> new ArrayDeque<>());
synchronized (getRequests) {
ChoosableSet<V> entries = nearCache.get(k);
if (entries != null && entries.isInitialised() && getRequests.isEmpty()) {
context.runOnContext(v -> {
resultHandler.handle(Future.succeededFuture(entries));
});
} else {
getRequests.add(new GetRequest<>(k, resultHandler));
if (getRequests.size() == 1) {
dequeueGet(context, getRequests);
}
}
}
}
开发者ID:vert-x3,项目名称:vertx-infinispan,代码行数:20,代码来源:InfinispanAsyncMultiMap.java
示例3: get
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
@Override
public void get(K k, Handler<AsyncResult<ChoosableIterable<V>>> resultHandler) {
ContextImpl context = vertx.getOrCreateContext();
@SuppressWarnings("unchecked")
Queue<GetRequest<K, V>> getRequests = (Queue<GetRequest<K, V>>) context.contextData().computeIfAbsent(this, ctx -> new ArrayDeque<>());
synchronized (getRequests) {
ChoosableSet<V> entries = cache.get(k);
if (entries != null && entries.isInitialised() && getRequests.isEmpty()) {
context.runOnContext(v -> {
resultHandler.handle(Future.succeededFuture(entries));
});
} else {
getRequests.add(new GetRequest<>(k, resultHandler));
if (getRequests.size() == 1) {
dequeueGet(context, getRequests);
}
}
}
}
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:20,代码来源:HazelcastAsyncMultiMap.java
示例4: get
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
@Override
public void get(final K k, final Handler<AsyncResult<ChoosableIterable<V>>> asyncResultHandler) {
final ContextInternal ctx = FakeClusterManager.this.vertx.getOrCreateContext();
ctx.executeBlocking(fut -> {
ChoosableIterable<V> it = this.map.get(k);
if (it == null) {
it = new ChoosableSet<>(0);
}
fut.complete(it);
}, this.taskQueue, asyncResultHandler);
}
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:12,代码来源:FakeClusterManager.java
示例5: get
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
@Override
public void get(K key, Handler<AsyncResult<ChoosableIterable<V>>> handler) {
execute(
cache -> cache.getAsync(marshal(key)),
(Set<V> items) -> {
Set<V> unmarshalledItems = null;
if (items != null) {
unmarshalledItems = items.stream().map(ClusterSerializationUtils::unmarshal).collect(toSet());
}
Set<V> items0 = unmarshalledItems;
ChoosableIterableImpl<V> it = subs.compute(key, (k, oldValue) -> {
if (items0 == null || items0.isEmpty()) {
return null;
}
if (oldValue == null) {
return new ChoosableIterableImpl<>(new ArrayList<>(items0));
}
else {
oldValue.update(new ArrayList<>(items0));
return oldValue;
}
});
return it == null ? ChoosableIterableImpl.empty() : it;
},
handler
);
}
开发者ID:vert-x3,项目名称:vertx-ignite,代码行数:33,代码来源:AsyncMultiMapImpl.java
示例6: get
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void get(K k, Handler<AsyncResult<ChoosableIterable<V>>> handler) {
map.get(k).whenComplete(VertxFutures.convertHandler(
handler,
collection -> collection != null
? new AtomixChoosableIterable(collection.value())
: new AtomixChoosableIterable<V>(Collections.emptyList()),
vertx.getOrCreateContext()));
}
开发者ID:atomix,项目名称:atomix-vertx,代码行数:11,代码来源:AtomixAsyncMultiMap.java
示例7: shouldNotAddToMapCacheIfKeyDoesntAlreadyExist
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
@Test
public void shouldNotAddToMapCacheIfKeyDoesntAlreadyExist() throws Exception {
String nonexistentKey = "non-existent-key." + UUID.randomUUID();
map.get(nonexistentKey, ar -> {
if (ar.succeeded()) {
try {
ChoosableIterable<ServerID> s = ar.result();
Map<String, ChoosableIterable<ServerID>> cache = getCacheFromMap();
// System.err.println("CACHE CONTENTS: " + cache);
// check result
assertNotNull(s);
assertTrue(s.isEmpty());
// check cache
assertNotNull(cache);
assertFalse(
"Map cache should not contain key " + nonexistentKey,
cache.containsKey(nonexistentKey));
} catch (Exception e) {
fail(e.toString());
} finally {
testComplete();
}
} else {
fail(ar.cause().toString());
}
});
await();
}
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:35,代码来源:HazelcastAsyncMultiMapTest.java
示例8: empty
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
public static <T> ChoosableIterable<T> empty() {
return (ChoosableIterable<T>)EMPTY;
}
开发者ID:vert-x3,项目名称:vertx-ignite,代码行数:4,代码来源:ChoosableIterableImpl.java
示例9: GetRequest
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
GetRequest(K key, Handler<AsyncResult<ChoosableIterable<V>>> handler) {
this.key = key;
this.handler = handler;
}
开发者ID:vert-x3,项目名称:vertx-infinispan,代码行数:5,代码来源:InfinispanAsyncMultiMap.java
示例10: get
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
public void get(K k, Handler<AsyncResult<ChoosableIterable<V>>> handler) {
logTrace(() -> "get k = [" + k + "], handler = [" + handler + "]");
executorService.runAsync(() -> map.get(k), handler);
}
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:5,代码来源:AsyncMultiMapWrapper.java
示例11: getCacheFromMap
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Map<String, ChoosableIterable<ServerID>> getCacheFromMap() throws Exception {
Field field = map.getClass().getDeclaredField("cache");
field.setAccessible(true);
return (Map<String, ChoosableIterable<ServerID>>) field.get(map);
}
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:7,代码来源:HazelcastAsyncMultiMapTest.java
示例12: get
import io.vertx.core.spi.cluster.ChoosableIterable; //导入依赖的package包/类
ChoosableIterable<V> get(K k);
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:2,代码来源:MultiMap.java
注:本文中的io.vertx.core.spi.cluster.ChoosableIterable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论