Search in sources :

Example 1 with ByteArray

use of com.tvd12.calabash.core.util.ByteArray in project calabash by youngmonkeys.

the class BytesMapPartitionImpl method remove.

@Override
public void remove(Set<ByteArray> keys) {
    synchronized (map) {
        for (ByteArray key : keys) {
            map.remove(key);
        }
        mapBackupExecutor.remove(mapSetting, keys);
        mapPersistExecutor.delete(mapSetting, keys);
    }
    for (ByteArray key : keys) {
        lockProvider.removeLock(key);
    }
    mapEviction.removeKeys(keys);
}
Also used : ByteArray(com.tvd12.calabash.core.util.ByteArray)

Example 2 with ByteArray

use of com.tvd12.calabash.core.util.ByteArray in project calabash by youngmonkeys.

the class BytesMapPartitionImpl method get.

@Override
public Map<ByteArray, byte[]> get(Set<ByteArray> keys) {
    Map<ByteArray, byte[]> answer = new HashMap<>();
    Set<ByteArray> unloadKeys = new HashSet<>();
    synchronized (map) {
        for (ByteArray key : keys) {
            byte[] value = map.get(key);
            if (value != null) {
                answer.put(key, value);
            } else {
                unloadKeys.add(key);
            }
        }
    }
    if (unloadKeys.size() > 0) {
        Map<ByteArray, byte[]> unloadItems = mapPersistExecutor.load(mapSetting, keys);
        synchronized (map) {
            for (ByteArray key : unloadItems.keySet()) {
                byte[] value = map.get(key);
                if (value == null) {
                    value = unloadItems.get(key);
                    map.put(key, value);
                }
                answer.put(key, value);
            }
        }
    }
    mapEviction.updateKeysTime(answer.keySet());
    return answer;
}
Also used : ByteArray(com.tvd12.calabash.core.util.ByteArray)

Example 3 with ByteArray

use of com.tvd12.calabash.core.util.ByteArray in project calabash by youngmonkeys.

the class SimpleBytesMapPersistExecutor method delete.

@Override
public void delete(MapSetting mapSetting, ByteArray key) {
    BytesMapPersist mapPersist = getMapPersist(mapSetting);
    if (mapPersist != null) {
        PersistDeleteOneAction action = new PersistDeleteOneAction(key);
        addPersistActionToQueue(mapSetting, action);
    }
}
Also used : BytesMapPersist(com.tvd12.calabash.persist.BytesMapPersist)

Example 4 with ByteArray

use of com.tvd12.calabash.core.util.ByteArray in project calabash by youngmonkeys.

the class EntityBytesMapPersist method delete.

@Override
public void delete(Set<ByteArray> keys) {
    Set keyEntities = new HashSet<>();
    for (ByteArray key : keys) {
        Object keyEntity = entityCodec.deserialize(key.getBytes(), keyType);
        keyEntities.add(keyEntity);
    }
    entityMapPersist.delete(keyEntities);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ByteArray(com.tvd12.calabash.core.util.ByteArray) HashSet(java.util.HashSet)

Example 5 with ByteArray

use of com.tvd12.calabash.core.util.ByteArray in project calabash by youngmonkeys.

the class BytesMapPersist method load.

default Map<ByteArray, byte[]> load(Set<ByteArray> keys) {
    Map<ByteArray, byte[]> keyValues = new HashMap<>();
    for (ByteArray key : keys) {
        byte[] value = load(key);
        keyValues.put(key, value);
    }
    return keyValues;
}
Also used : HashMap(java.util.HashMap) ByteArray(com.tvd12.calabash.core.util.ByteArray)

Aggregations

ByteArray (com.tvd12.calabash.core.util.ByteArray)10 BytesMapPersist (com.tvd12.calabash.persist.BytesMapPersist)4 BytesMap (com.tvd12.calabash.core.BytesMap)3 HashMap (java.util.HashMap)3 SimpleSettings (com.tvd12.calabash.server.core.setting.SimpleSettings)2 Calabash (com.tvd12.calabash.Calabash)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 Rpc (com.tvd12.quick.rpc.server.annotation.Rpc)1