Search in sources :

Example 1 with IgniteCacheFutureImpl

use of org.apache.ignite.internal.processors.cache.IgniteCacheFutureImpl in project ignite by apache.

the class DataStreamerImpl method addData.

/** {@inheritDoc} */
@Override
public IgniteFuture<?> addData(Collection<? extends Map.Entry<K, V>> entries) {
    A.notEmpty(entries, "entries");
    checkSecurityPermission(SecurityPermission.CACHE_PUT);
    enterBusy();
    try {
        GridFutureAdapter<Object> resFut = new GridFutureAdapter<>();
        resFut.listen(rmvActiveFut);
        activeFuts.add(resFut);
        Collection<KeyCacheObjectWrapper> keys = new GridConcurrentHashSet<>(entries.size(), U.capacity(entries.size()), 1);
        Collection<DataStreamerEntry> entries0 = new ArrayList<>(entries.size());
        for (Map.Entry<K, V> entry : entries) {
            KeyCacheObject key = cacheObjProc.toCacheKeyObject(cacheObjCtx, null, entry.getKey(), true);
            CacheObject val = cacheObjProc.toCacheObject(cacheObjCtx, entry.getValue(), true);
            keys.add(new KeyCacheObjectWrapper(key));
            entries0.add(new DataStreamerEntry(key, val));
        }
        load0(entries0, resFut, keys, 0);
        return new IgniteCacheFutureImpl<>(resFut);
    } catch (IgniteDataStreamerTimeoutException e) {
        throw e;
    } catch (IgniteException e) {
        return new IgniteFinishedFutureImpl<>(e);
    } finally {
        leaveBusy();
    }
}
Also used : ArrayList(java.util.ArrayList) GridConcurrentHashSet(org.apache.ignite.internal.util.GridConcurrentHashSet) IgniteCacheFutureImpl(org.apache.ignite.internal.processors.cache.IgniteCacheFutureImpl) IgniteDataStreamerTimeoutException(org.apache.ignite.IgniteDataStreamerTimeoutException) IgniteException(org.apache.ignite.IgniteException) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 IgniteDataStreamerTimeoutException (org.apache.ignite.IgniteDataStreamerTimeoutException)1 IgniteException (org.apache.ignite.IgniteException)1 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)1 IgniteCacheFutureImpl (org.apache.ignite.internal.processors.cache.IgniteCacheFutureImpl)1 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)1 GridConcurrentHashSet (org.apache.ignite.internal.util.GridConcurrentHashSet)1 GridFutureAdapter (org.apache.ignite.internal.util.future.GridFutureAdapter)1