Search in sources :

Example 1 with BytesMap

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

the class CalabashServerContext method newAtomicLongManager.

protected AtomicLongManager newAtomicLongManager() {
    String mapName = settings.getAtomicLongMapName();
    BytesMap map = getBytesMap(mapName);
    return new SimpleAtomicLongManager(map);
}
Also used : BytesMap(com.tvd12.calabash.core.BytesMap)

Example 2 with BytesMap

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

the class LocalMapPersistExample method test.

@SuppressWarnings("rawtypes")
public void test() {
    EzyEntityCodec entityCodec = newEntityCodec();
    SimpleSettings settings = new SimpleSettings();
    SimpleMapPersistSetting mapPersistSetting = new SimpleMapPersistSetting();
    SimpleMapSetting mapSetting = new SimpleMapSetting();
    mapSetting.setMapName(CollectionNames.PERSON);
    mapSetting.setPersistSetting(mapPersistSetting);
    settings.addMapSetting(mapSetting);
    EzyBeanContext beanContext = newBeanContext();
    SimpleEntityMapPersistFactory.Builder mapPersistFactoryBuilder = SimpleEntityMapPersistFactory.builder();
    List mapPersistenceList = beanContext.getSingletons(MapPersistence.class);
    for (Object mapPersist : mapPersistenceList) {
        String mapName = MapPersistenceAnnotations.getMapName(mapPersist);
        mapPersistFactoryBuilder.addMapPersist(mapName, (EntityMapPersist) mapPersist);
    }
    BytesMapPersistFactory bytesMapPersistFactory = EntityBytesMapPersistFactory.builder().entityCodec(entityCodec).entityMapPersistFactory(mapPersistFactoryBuilder.build()).build();
    Calabash calabash = CalabashServerContext.builder().settings(settings).bytesMapPersistFactory(bytesMapPersistFactory).build();
    ByteArray keyBytes = new ByteArray(entityCodec.serialize(1L));
    byte[] values = entityCodec.serialize(new Person(9L, "bar", 29));
    BytesMap bytesMap = calabash.getBytesMap(CollectionNames.PERSON);
    bytesMap.put(keyBytes, values);
}
Also used : SimpleSettings(com.tvd12.calabash.server.core.setting.SimpleSettings) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) BytesMap(com.tvd12.calabash.core.BytesMap) SimpleMapSetting(com.tvd12.calabash.server.core.setting.SimpleMapSetting) ByteArray(com.tvd12.calabash.core.util.ByteArray) List(java.util.List) SimpleMapPersistSetting(com.tvd12.calabash.persist.setting.SimpleMapPersistSetting) Calabash(com.tvd12.calabash.Calabash) SimpleEntityMapPersistFactory(com.tvd12.calabash.persist.factory.SimpleEntityMapPersistFactory) EntityBytesMapPersistFactory(com.tvd12.calabash.persist.factory.EntityBytesMapPersistFactory) BytesMapPersistFactory(com.tvd12.calabash.persist.factory.BytesMapPersistFactory)

Example 3 with BytesMap

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

the class MapRequestController method mapRemoveMany.

@Rpc(Commands.MAP_REMOVE_MANY)
public boolean mapRemoveMany(MapRemoveManyRequest request) {
    BytesMap map = getBytesMap(request.getMapId());
    map.remove(request.getKeys());
    return Boolean.TRUE;
}
Also used : BytesMap(com.tvd12.calabash.core.BytesMap) Rpc(com.tvd12.quick.rpc.server.annotation.Rpc)

Example 4 with BytesMap

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

the class MapRequestController method mapSet.

@Rpc(Commands.MAP_SET)
public boolean mapSet(MapSetRequest request) {
    BytesMap map = getBytesMap(request.getMapId());
    map.set(request.getKey(), request.getValue());
    return Boolean.TRUE;
}
Also used : BytesMap(com.tvd12.calabash.core.BytesMap) Rpc(com.tvd12.quick.rpc.server.annotation.Rpc)

Example 5 with BytesMap

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

the class MapRequestController method mapGetMany.

@Rpc(Commands.MAP_GET_MANY)
public List<byte[]> mapGetMany(MapGetManyRequest request) {
    BytesMap map = getBytesMap(request.getMapId());
    List<ByteArray> keys = ByteArray.wrap(request.getKeys());
    Map<ByteArray, byte[]> m = map.get(keys);
    List<byte[]> answer = new ArrayList<>(keys.size());
    for (ByteArray key : keys) {
        answer.add(m.get(key));
    }
    return answer;
}
Also used : BytesMap(com.tvd12.calabash.core.BytesMap) ArrayList(java.util.ArrayList) ByteArray(com.tvd12.calabash.core.util.ByteArray) 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