本文整理汇总了Java中io.vertx.core.spi.cluster.AsyncMultiMap类的典型用法代码示例。如果您正苦于以下问题:Java AsyncMultiMap类的具体用法?Java AsyncMultiMap怎么用?Java AsyncMultiMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncMultiMap类属于io.vertx.core.spi.cluster包,在下文中一共展示了AsyncMultiMap类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsyncMultiMap
import io.vertx.core.spi.cluster.AsyncMultiMap; //导入依赖的package包/类
@Override
public <K, V> void getAsyncMultiMap(final String name, final Handler<AsyncResult<AsyncMultiMap<K, V>>> resultHandler) {
ConcurrentMap map = asyncMultiMaps.get(name);
if (map == null) {
map = new ConcurrentHashMap<>();
final ConcurrentMap prevMap = asyncMultiMaps.putIfAbsent(name, map);
if (prevMap != null) {
map = prevMap;
}
}
@SuppressWarnings("unchecked") final ConcurrentMap<K, ChoosableSet<V>> theMap = map;
this.vertx.runOnContext(v -> resultHandler.handle(Future.succeededFuture(new FakeAsyncMultiMap<>(theMap))));
}
示例2: getAsyncMultiMap
import io.vertx.core.spi.cluster.AsyncMultiMap; //导入依赖的package包/类
@Override
public <K, V> void getAsyncMultiMap(String name, Handler<AsyncResult<AsyncMultiMap<K, V>>> resultHandler) {
vertx.executeBlocking(future -> {
Cache<MultiMapKey, Object> cache = cacheManager.getCache(name);
InfinispanAsyncMultiMap<K, V> asyncMultiMap = new InfinispanAsyncMultiMap<>(vertx, cache);
synchronized (this) {
multimaps.add(asyncMultiMap);
}
future.complete(asyncMultiMap);
}, false, resultHandler);
}
示例3: getAsyncMultiMap
import io.vertx.core.spi.cluster.AsyncMultiMap; //导入依赖的package包/类
@Override
public <K, V> void getAsyncMultiMap(String name, Handler<AsyncResult<AsyncMultiMap<K, V>>> handler) {
atomix.<K, V>consistentMultimapBuilder(name)
.withSerializer(createSerializer())
.withConsistency(Consistency.LINEARIZABLE)
.withPersistence(Persistence.PERSISTENT)
.withReplication(Replication.SYNCHRONOUS)
.withRecovery(Recovery.RECOVER)
.withMaxRetries(5)
.buildAsync()
.whenComplete(VertxFutures.convertHandler(
handler, map -> new AtomixAsyncMultiMap<>(vertx, map.async()), vertx.getOrCreateContext()));
}
示例4: getAsyncMultiMap
import io.vertx.core.spi.cluster.AsyncMultiMap; //导入依赖的package包/类
@Override
public <K, V> void getAsyncMultiMap(String name, Handler<AsyncResult<AsyncMultiMap<K, V>>> handler) {
logTrace(() -> String.format("Create new AsyncMultiMap [%s] on address [%s]", name, address));
vertx.executeBlocking((future) -> {
checkCluster();
AsyncMultiMap<K, V> map = cacheManager.<K, V>createAsyncMultiMap(name);
future.complete(map);
}, handler);
}
示例5: getAsyncMultiMap
import io.vertx.core.spi.cluster.AsyncMultiMap; //导入依赖的package包/类
/**
* Every eventbus handler has an ID. SubsMap (subscriber map) is a MultiMap which
* maps handler-IDs with server-IDs and thus allows the eventbus to determine where
* to send messages.
*
* @param name A unique name by which the the MultiMap can be identified within the cluster.
* See the cluster config file (e.g. cluster.xml in case of HazelcastClusterManager) for
* additional MultiMap config parameters.
* @param resultHandler handler receiving the multimap
*/
@Override
public <K, V> void getAsyncMultiMap(String name, Handler<AsyncResult<AsyncMultiMap<K, V>>> resultHandler) {
vertx.executeBlocking(fut -> {
com.hazelcast.core.MultiMap<K, V> multiMap = hazelcast.getMultiMap(name);
HazelcastAsyncMultiMap<K, V> asyncMultiMap = new HazelcastAsyncMultiMap<>(vertx, multiMap);
synchronized (this) {
multimaps.add(asyncMultiMap);
}
fut.complete(asyncMultiMap);
}, resultHandler);
}
示例6: getAsyncMultiMap
import io.vertx.core.spi.cluster.AsyncMultiMap; //导入依赖的package包/类
@Override
public <K, V> void getAsyncMultiMap(String name, Handler<AsyncResult<AsyncMultiMap<K, V>>> handler) {
vertx.executeBlocking(
fut -> fut.complete(new AsyncMultiMapImpl<>(this.<K, Set<V>>getCache(name), vertx)), handler
);
}
示例7: createAsyncMultiMap
import io.vertx.core.spi.cluster.AsyncMultiMap; //导入依赖的package包/类
public <K, V> AsyncMultiMap<K, V> createAsyncMultiMap(String name) {
logDebug(() -> String.format("method createAsyncMultiMap address[%s] name[%s]", channel.getAddressAsString(), name));
MultiMap<K, V> map = multiMapService.<K, V>multiMapCreate(name);
return new AsyncMultiMapWrapper<>(name, map, executorService);
}
示例8: getAsyncMultiMap
import io.vertx.core.spi.cluster.AsyncMultiMap; //导入依赖的package包/类
/**
* Every eventbus handler has an ID. SubsMap (subscriber map) is a MultiMap which
* maps handler-IDs with server-IDs and thus allows the eventbus to determine where
* to send messages.
*
* @param name A unique name by which the the MultiMap can be identified within the cluster.
* See the cluster config file (e.g. io.vertx.spi.cluster.impl.zookeeper.zookeeper.properties in case of ZookeeperClusterManager) for
* additional MultiMap config parameters.
* @return subscription map
*/
@Override
public <K, V> void getAsyncMultiMap(String name, Handler<AsyncResult<AsyncMultiMap<K, V>>> handler) {
vertx.runOnContext(event -> handler.handle(Future.succeededFuture(new ZKAsyncMultiMap<>(vertx, curator, name))));
}