本文整理汇总了Java中io.vertx.core.shareddata.SharedData.getClusterWideMap方法的典型用法代码示例。如果您正苦于以下问题:Java SharedData.getClusterWideMap方法的具体用法?Java SharedData.getClusterWideMap怎么用?Java SharedData.getClusterWideMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.shareddata.SharedData
的用法示例。
在下文中一共展示了SharedData.getClusterWideMap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
/**
* Create a AsyncMap
*
* @param <K> Key type
* @param <V> Value type
* @param vertx
* @param mapName name of the map. If null, will always create a local map
* @param fut
*/
public static <K, V> void create(Vertx vertx, String mapName, Handler<ExtendedAsyncResult<AsyncMap<K, V>>> fut) {
if (vertx.isClustered() && mapName != null) {
SharedData shared = vertx.sharedData();
shared.<K, V>getClusterWideMap(mapName, res -> {
if (res.succeeded()) {
fut.handle(new Success<>(res.result()));
} else {
fut.handle(new Failure<>(INTERNAL, res.cause()));
}
});
} else {
// Dirty trickery to make sure we can run two verticles in our tests,
// without them sharing the 'shared' memory. Only when running in non-
// clustered mode, of course.
// Also used in deploy-only nodes, where we want local-only tenant and
// module lists with only the hard-coded supertenant and internalModule.
Random r = new Random();
String newid = String.format("%09d", r.nextInt(1000000000));
if (mapName != null) {
newid = mapName + newid;
}
AsyncLocalmap<K, V> l = new AsyncLocalmap<>(vertx, newid);
fut.handle(new Success<>(l));
}
}
示例2: findRouteToWSServiceAndRegister
import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public void findRouteToWSServiceAndRegister(ServerWebSocket serverSocket) {
final SharedData sharedData = this.vertx.sharedData();
sharedData.<String, ServiceInfoHolder>getClusterWideMap(REGISTRY, onSuccess(resultMap ->
resultMap.get(GlobalKeyHolder.SERVICE_HOLDER, onSuccess(resultHolder -> findServiceEntryAndRegisterWS(serverSocket, resultHolder, sharedData)))
));
}
示例3: getSharedRegistryAndPing
import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
private void getSharedRegistryAndPing() {
final SharedData sharedData = this.vertx.sharedData();
sharedData.<String, ServiceInfoHolder>getClusterWideMap(GlobalKeyHolder.REGISTRY_MAP_KEY, onSuccess(resultMap -> {
logDebug("resultMap " + resultMap);
getServiceHolderAndPingServices(resultMap);
}
));
}
示例4: createEndpointDefinitionAndRegister
import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
private void createEndpointDefinitionAndRegister(ServerWebSocket serverSocket, final SharedData sharedData) {
sharedData.<String, WSEndpointHolder>getClusterWideMap(WS_REGISTRY, onSuccess(registryMap ->
getEndpointHolderAndAdd(serverSocket, registryMap)
));
}