本文整理汇总了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;
}
示例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());
});
}
}
示例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();
}
}
示例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";
}
示例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";
}
示例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);
}
示例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);
}
示例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);
}
示例9: AsyncLocalmap
import io.vertx.core.shareddata.SharedData; //导入方法依赖的package包/类
public AsyncLocalmap(Vertx vertx, String mapName) {
SharedData sd = vertx.sharedData();
this.map = sd.getLocalMap(mapName);
}
示例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);
}