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


Java SharedData.getLocalMap方法代码示例

本文整理汇总了Java中io.vertx.core.shareddata.SharedData.getLocalMap方法的典型用法代码示例。如果您正苦于以下问题:Java SharedData.getLocalMap方法的具体用法?Java SharedData.getLocalMap怎么用?Java SharedData.getLocalMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.core.shareddata.SharedData的用法示例。


在下文中一共展示了SharedData.getLocalMap方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public Object execute() throws Exception {
    SharedData sharedData = getVertxService().sharedData();
    LocalMap<Object, Object> map = sharedData.getLocalMap(this.map);

    ShellTable table = new ShellTable();

    table.column("Map[" + this.map + "]\nKey");
    table.column("\nValue");

    if (keys != null) {
        keys.forEach(key -> {
            renderRow(map, table, key);
        });
    } else {
        map.keySet().forEach(key -> {
            renderRow(map, table, (String) key);
        });
    }
    
    table.print(System.out);

    return null;
}
 
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:25,代码来源:VertxMapGet.java

示例2: findRouteSocketInRegistryAndRemove

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public void findRouteSocketInRegistryAndRemove(ServerWebSocket serverSocket) {
    final SharedData sharedData = this.vertx.sharedData();
    final String binaryHandlerID = serverSocket.binaryHandlerID();
    final String textHandlerID = serverSocket.textHandlerID();
    final LocalMap<String, byte[]> wsRegistry = sharedData.getLocalMap(WS_REGISTRY);
    final WSEndpointHolder holder = getWSEndpointHolderFromSharedData(wsRegistry);
    if (holder != null) {
        final List<WSEndpoint> all = holder.getAll();
        final Optional<WSEndpoint> first = all.parallelStream().filter(e -> e.getBinaryHandlerId().equals(binaryHandlerID) && e.getTextHandlerId().equals(textHandlerID)).findFirst();
        first.ifPresent(endpoint -> {
            holder.remove(endpoint);
            wsRegistry.replace(WS_ENDPOINT_HOLDER, serialize(holder));
            log("OK REMOVE: " + serverSocket.binaryHandlerID());
        });
    }
}
 
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:18,代码来源:WSLocalHandler.java

示例3: replyToAllWS

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public void replyToAllWS(Message<byte[]> message) {
    try {
        log("Reply to all: " + this);
        final WSMessageWrapper wrapper = (WSMessageWrapper) Serializer.deserialize(message.body());
        final String stringResult = TypeTool.trySerializeToString(wrapper.getBody());
        final byte[] payload = stringResult != null ? stringResult.getBytes() : Serializer.serialize(wrapper.getBody());

        final SharedData sharedData = this.vertx.sharedData();
        final LocalMap<String, byte[]> wsRegistry = sharedData.getLocalMap(WS_REGISTRY);
        final byte[] holderPayload = wsRegistry.get(WS_ENDPOINT_HOLDER);
        if (holderPayload != null) {
            final WSEndpointHolder holder = (WSEndpointHolder) deserialize(holderPayload);
            final List<WSEndpoint> all = holder.getAll();
            all.parallelStream().
                    filter(endP -> endP.getUrl().equals(wrapper.getEndpoint().getUrl())).
                    forEach(
                            endpoint -> replyToEndpoint(stringResult, payload, endpoint)
                    );
        }


    } catch (IOException | ClassNotFoundException e) {
        e.printStackTrace();
    }
}
 
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:27,代码来源:WSLocalHandler.java

示例4: execute

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public Object execute() throws Exception {
    SharedData sharedData = getVertxService().sharedData();
    LocalMap<Object, Object> localMap = sharedData.getLocalMap(map);
    localMap.put(key, value);

    return "key and value added to map";
}
 
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:9,代码来源:VertxMapPut.java

示例5: execute

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public Object execute() throws Exception {
    SharedData sharedData = getVertxService().sharedData();
    LocalMap<Object, Object> map = sharedData.getLocalMap(this.map);

    if (keys != null) {
        keys.forEach(map::remove);
    }
    
    return "removed keys from map";
}
 
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:12,代码来源:VertxMapRm.java

示例6: start

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
	mongo = MongoClient.createShared(vertx, config().getJsonObject("mongodb", new JsonObject()));
	intervalMS = config().getJsonObject("simulation", new JsonObject()).getInteger("interval_ms", 1000);
	msgInterval = config().getJsonObject("simulation", new JsonObject()).getInteger("msgInterval", 1);

	SharedData sd = vertx.sharedData();
	simulationStatus = sd.getLocalMap("simStatusMap");

	vertx.eventBus().consumer(Bus.START_SIMULATION.address(), this::startSimulation);
	vertx.eventBus().consumer(Bus.STOP_SIMULATION.address(), this::stopSimulation);
	vertx.eventBus().consumer(Bus.SIMULATION_STATUS.address(), this::getSimulationStatus);
	vertx.eventBus().consumer(Bus.SIMULATION_ENDED.address(), this::handleSimulationEnded);
}
 
开发者ID:fleetSim,项目名称:trucksimulation,代码行数:15,代码来源:SimulationControllerVerticle.java

示例7: resolve

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public Object resolve(RoutingContext context, LocalMapValue annotation, String paramName, Class<?> resultClass) {
  SharedData sd = context.vertx().sharedData();
  String mapName = annotation.mapName();
  String key = annotation.key();
  if ("".equals(key)) {
    key = paramName;
  }
  io.vertx.core.shareddata.LocalMap<Object, Object> map = sd.getLocalMap(mapName);
  return map.get(key);
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:12,代码来源:LocalMapValueParamInjector.java

示例8: resolve

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
@Override
public Object resolve(RoutingContext context, VertxLocalMap annotation, String paramName, Class<?> resultClass) {
  SharedData sd = context.vertx().sharedData();
  String mapName = annotation.value();
  if ("".equals(mapName)) {
    mapName = paramName;
  }
  return sd.getLocalMap(mapName);
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:10,代码来源:LocalMapParamInjector.java

示例9: AsyncLocalmap

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
public AsyncLocalmap(Vertx vertx, String mapName) {
  SharedData sd = vertx.sharedData();
  this.map = sd.getLocalMap(mapName);
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:5,代码来源:AsyncLocalmap.java

示例10: createEndpointDefinitionAndRegister

import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
private void createEndpointDefinitionAndRegister(ServerWebSocket serverSocket) {
    final SharedData sharedData = this.vertx.sharedData();
    final LocalMap<String, byte[]> wsRegistry = sharedData.getLocalMap(WS_REGISTRY);
    final WSEndpointHolder holder = getWSEndpointHolderFromSharedData(wsRegistry);
    final String path = serverSocket.path();
    final WSEndpoint endpoint = new WSEndpoint(serverSocket.binaryHandlerID(), serverSocket.textHandlerID(), path);

    replaceOrAddEndpoint(wsRegistry, holder, endpoint);

    sendToWSService(serverSocket, path, endpoint);


}
 
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:14,代码来源:WSLocalHandler.java


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