Search in sources :

Example 1 with CacheClearResponse

use of com.hazelcast.cache.impl.CacheClearResponse in project hazelcast by hazelcast.

the class CacheClearMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    for (Map.Entry<Integer, Object> entry : map.entrySet()) {
        if (entry.getValue() == null) {
            continue;
        }
        final CacheClearResponse cacheClearResponse = (CacheClearResponse) nodeEngine.toObject(entry.getValue());
        final Object response = cacheClearResponse.getResponse();
        if (response instanceof CacheException) {
            throw (CacheException) response;
        }
    }
    return null;
}
Also used : CacheClearResponse(com.hazelcast.cache.impl.CacheClearResponse) CacheException(javax.cache.CacheException) Map(java.util.Map)

Example 2 with CacheClearResponse

use of com.hazelcast.cache.impl.CacheClearResponse in project hazelcast by hazelcast.

the class CacheLoadAllMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    for (Map.Entry<Integer, Object> entry : map.entrySet()) {
        if (entry.getValue() == null) {
            continue;
        }
        final CacheClearResponse cacheClearResponse = (CacheClearResponse) nodeEngine.toObject(entry.getValue());
        final Object response = cacheClearResponse.getResponse();
        if (response instanceof CacheException) {
            throw (CacheException) response;
        }
    }
    return null;
}
Also used : CacheClearResponse(com.hazelcast.cache.impl.CacheClearResponse) CacheException(javax.cache.CacheException) Map(java.util.Map)

Example 3 with CacheClearResponse

use of com.hazelcast.cache.impl.CacheClearResponse in project hazelcast by hazelcast.

the class CacheLoadAllOperation method run.

@Override
public void run() throws Exception {
    int partitionId = getPartitionId();
    IPartitionService partitionService = getNodeEngine().getPartitionService();
    Set<Data> filteredKeys = null;
    if (keys != null) {
        filteredKeys = new HashSet<Data>();
        for (Data k : keys) {
            if (partitionService.getPartitionId(k) == partitionId) {
                filteredKeys.add(k);
            }
        }
    }
    if (filteredKeys == null || filteredKeys.isEmpty()) {
        return;
    }
    try {
        ICacheService service = getService();
        cache = service.getOrCreateRecordStore(name, partitionId);
        Set<Data> keysLoaded = cache.loadAll(filteredKeys, replaceExistingValues);
        int loadedKeyCount = keysLoaded.size();
        if (loadedKeyCount > 0) {
            backupRecords = new HashMap<Data, CacheRecord>(loadedKeyCount);
            for (Data key : keysLoaded) {
                CacheRecord record = cache.getRecord(key);
                // So if the loaded key is evicted, don't send it to backup.
                if (record != null) {
                    backupRecords.put(key, record);
                }
            }
            shouldBackup = !backupRecords.isEmpty();
        }
    } catch (CacheException e) {
        response = new CacheClearResponse(e);
    }
}
Also used : CacheClearResponse(com.hazelcast.cache.impl.CacheClearResponse) CacheRecord(com.hazelcast.cache.impl.record.CacheRecord) ICacheService(com.hazelcast.cache.impl.ICacheService) CacheException(javax.cache.CacheException) IPartitionService(com.hazelcast.spi.partition.IPartitionService) Data(com.hazelcast.nio.serialization.Data)

Example 4 with CacheClearResponse

use of com.hazelcast.cache.impl.CacheClearResponse in project hazelcast by hazelcast.

the class CacheClearOperation method run.

@Override
public void run() {
    if (cache == null) {
        return;
    }
    try {
        cache.clear();
        response = new CacheClearResponse(Boolean.TRUE);
    } catch (CacheException e) {
        response = new CacheClearResponse(e);
    }
}
Also used : CacheClearResponse(com.hazelcast.cache.impl.CacheClearResponse) CacheException(javax.cache.CacheException)

Example 5 with CacheClearResponse

use of com.hazelcast.cache.impl.CacheClearResponse in project hazelcast by hazelcast.

the class CacheRemoveAllKeysMessageTask method reduce.

@Override
protected ClientMessage reduce(Map<Integer, Object> map) {
    for (Map.Entry<Integer, Object> entry : map.entrySet()) {
        if (entry.getValue() == null) {
            continue;
        }
        final CacheClearResponse cacheClearResponse = (CacheClearResponse) nodeEngine.toObject(entry.getValue());
        final Object response = cacheClearResponse.getResponse();
        if (response instanceof CacheException) {
            throw (CacheException) response;
        }
    }
    return null;
}
Also used : CacheClearResponse(com.hazelcast.cache.impl.CacheClearResponse) CacheException(javax.cache.CacheException) Map(java.util.Map)

Aggregations

CacheClearResponse (com.hazelcast.cache.impl.CacheClearResponse)6 CacheException (javax.cache.CacheException)6 Map (java.util.Map)4 ICacheService (com.hazelcast.cache.impl.ICacheService)1 CacheRecord (com.hazelcast.cache.impl.record.CacheRecord)1 Data (com.hazelcast.nio.serialization.Data)1 IPartitionService (com.hazelcast.spi.partition.IPartitionService)1