Search in sources :

Example 6 with BytesMap

use of com.tvd12.calabash.core.BytesMap in project calabash by youngmonkeys.

the class SimpleBytesMapManager method addStatistics.

@Override
public void addStatistics(Map<String, Object> statistics) {
    synchronized (maps) {
        statistics.put("numberOfMaps", maps.size());
        List<Map<String, Object>> mapStats = new ArrayList<>();
        for (String mapName : maps.keySet()) {
            BytesMap map = maps.get(mapName);
            Map<String, Object> mapStat = new HashMap<>();
            mapStat.put("name", mapName);
            ((StatisticsAware) map).addStatistics(mapStat);
            mapStats.add(mapStat);
        }
        statistics.put("maps", mapStats);
    }
}
Also used : HashMap(java.util.HashMap) BytesMap(com.tvd12.calabash.core.BytesMap) ArrayList(java.util.ArrayList) StatisticsAware(com.tvd12.calabash.core.statistic.StatisticsAware) Map(java.util.Map) BytesMap(com.tvd12.calabash.core.BytesMap) HashMap(java.util.HashMap)

Example 7 with BytesMap

use of com.tvd12.calabash.core.BytesMap in project calabash by youngmonkeys.

the class SimpleBytesMapManager method newMap.

protected BytesMap newMap(String mapName) {
    synchronized (maps) {
        BytesMap map = maps.get(mapName);
        if (map == null) {
            map = mapFactory.newMap(mapName);
            maps.put(mapName, map);
        }
        return map;
    }
}
Also used : BytesMap(com.tvd12.calabash.core.BytesMap)

Example 8 with BytesMap

use of com.tvd12.calabash.core.BytesMap in project calabash by youngmonkeys.

the class LocalExample method main.

public static void main(String[] args) {
    Settings settings = new SimpleSettings();
    MapPersistManager mapPersistManager = new SimpleMapPersistManager();
    BytesMapBackupExecutor backupExecutor = new SimpleBytesMapBackupExecutor();
    BytesMapPersistExecutor persistExecutor = SimpleBytesMapPersistExecutor.builder().mapPersistManager(mapPersistManager).build();
    BytesMap bytesMap = BytesMapImpl.builder().mapSetting(settings.getMapSetting("test")).mapBackupExecutor(backupExecutor).mapPersistExecutor(persistExecutor).build();
    bytesMap.loadAll();
    bytesMap.put(new ByteArray(new byte[] { 1, 2, 3 }), new byte[] { 1, 2, 3 });
    System.out.println(Arrays.toString(bytesMap.get(new ByteArray(new byte[] { 1, 2, 3 }))));
}
Also used : BytesMapBackupExecutor(com.tvd12.calabash.server.core.executor.BytesMapBackupExecutor) SimpleBytesMapBackupExecutor(com.tvd12.calabash.server.core.executor.SimpleBytesMapBackupExecutor) SimpleBytesMapPersistExecutor(com.tvd12.calabash.server.core.executor.SimpleBytesMapPersistExecutor) BytesMapPersistExecutor(com.tvd12.calabash.server.core.executor.BytesMapPersistExecutor) SimpleMapPersistManager(com.tvd12.calabash.persist.manager.SimpleMapPersistManager) SimpleSettings(com.tvd12.calabash.server.core.setting.SimpleSettings) SimpleBytesMapBackupExecutor(com.tvd12.calabash.server.core.executor.SimpleBytesMapBackupExecutor) BytesMap(com.tvd12.calabash.core.BytesMap) ByteArray(com.tvd12.calabash.core.util.ByteArray) SimpleSettings(com.tvd12.calabash.server.core.setting.SimpleSettings) Settings(com.tvd12.calabash.server.core.setting.Settings) MapPersistManager(com.tvd12.calabash.persist.manager.MapPersistManager) SimpleMapPersistManager(com.tvd12.calabash.persist.manager.SimpleMapPersistManager)

Example 9 with BytesMap

use of com.tvd12.calabash.core.BytesMap in project calabash by youngmonkeys.

the class MapRequestController method mapPutAll.

@Rpc(Commands.MAP_PUT_ALL)
public boolean mapPutAll(MapPutAllRequest request) {
    BytesMap map = getBytesMap(request.getMapId());
    map.setAll(request.getValueMap());
    return Boolean.TRUE;
}
Also used : BytesMap(com.tvd12.calabash.core.BytesMap) Rpc(com.tvd12.quick.rpc.server.annotation.Rpc)

Example 10 with BytesMap

use of com.tvd12.calabash.core.BytesMap in project calabash by youngmonkeys.

the class MapRequestController method mapClear.

@Rpc(Commands.MAP_CLEAR)
public boolean mapClear(MapClearRequest request) {
    BytesMap map = getBytesMap(request.getMapId());
    map.clear();
    return Boolean.TRUE;
}
Also used : BytesMap(com.tvd12.calabash.core.BytesMap) Rpc(com.tvd12.quick.rpc.server.annotation.Rpc)

Aggregations

BytesMap (com.tvd12.calabash.core.BytesMap)11 Rpc (com.tvd12.quick.rpc.server.annotation.Rpc)5 ByteArray (com.tvd12.calabash.core.util.ByteArray)3 SimpleSettings (com.tvd12.calabash.server.core.setting.SimpleSettings)2 ArrayList (java.util.ArrayList)2 Calabash (com.tvd12.calabash.Calabash)1 StatisticsAware (com.tvd12.calabash.core.statistic.StatisticsAware)1 BytesMapPersistFactory (com.tvd12.calabash.persist.factory.BytesMapPersistFactory)1 EntityBytesMapPersistFactory (com.tvd12.calabash.persist.factory.EntityBytesMapPersistFactory)1 SimpleEntityMapPersistFactory (com.tvd12.calabash.persist.factory.SimpleEntityMapPersistFactory)1 MapPersistManager (com.tvd12.calabash.persist.manager.MapPersistManager)1 SimpleMapPersistManager (com.tvd12.calabash.persist.manager.SimpleMapPersistManager)1 SimpleMapPersistSetting (com.tvd12.calabash.persist.setting.SimpleMapPersistSetting)1 BytesMapBackupExecutor (com.tvd12.calabash.server.core.executor.BytesMapBackupExecutor)1 BytesMapPersistExecutor (com.tvd12.calabash.server.core.executor.BytesMapPersistExecutor)1 SimpleBytesMapBackupExecutor (com.tvd12.calabash.server.core.executor.SimpleBytesMapBackupExecutor)1 SimpleBytesMapPersistExecutor (com.tvd12.calabash.server.core.executor.SimpleBytesMapPersistExecutor)1 Settings (com.tvd12.calabash.server.core.setting.Settings)1 SimpleMapSetting (com.tvd12.calabash.server.core.setting.SimpleMapSetting)1 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)1