当前位置: 首页>>代码示例>>Java>>正文


Java SharedData.getClusterWideMap方法代码示例

本文整理汇总了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));
  }
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:35,代码来源:AsyncMapFactory.java

示例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)))
    ));
}
 
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:8,代码来源:WSClusterHandler.java

示例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);
            }
    ));
}
 
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:9,代码来源:ServiceRegistry.java

示例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)
    ));
}
 
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:6,代码来源:WSClusterHandler.java


注:本文中的io.vertx.core.shareddata.SharedData.getClusterWideMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。