/** {@inheritDoc} */ @Nullable @Override public EntryProcessorResult invoke( @Nullable AffinityTopologyVersion topVer, Object key, EntryProcessor entryProcessor, Object... args ) throws IgniteCheckedException { return delegate.get().invoke(topVer, key, entryProcessor, args); }
/** * @throws Exception If failed. */ @Test public void testInternalInvokeNullable() throws Exception { IgniteInternalCache<Integer, Integer> cache = grid(0).cachex(DEFAULT_CACHE_NAME); EntryProcessor<Integer, Integer, Void> processor = new NullableProcessor(); for (final Integer key : keys()) { log.info("Test invoke with a nullable result [key=" + key + ']'); EntryProcessorResult<Void> result = cache.invoke(key, processor); EntryProcessorResult<Void> resultAsync = cache.invokeAsync(key, processor).get(); assertNotNull(result); assertNotNull(resultAsync); assertNull(result.get()); assertNull(resultAsync.get()); } }
/** {@inheritDoc} */ @Nullable @Override public EntryProcessorResult invoke( Object key, EntryProcessor entryProcessor, Object... args ) throws IgniteCheckedException { return delegate.get().invoke(keyTransformer.transform(key), entryProcessor, args); }
/** {@inheritDoc} */ @Nullable @Override public <T> EntryProcessorResult<T> invoke( AffinityTopologyVersion topVer, K key, EntryProcessor<K, V, T> entryProcessor, Object... args) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { return delegate.invoke(topVer, key, entryProcessor, args); } finally { gate.leave(prev); } }
/** {@inheritDoc} */ @Override public <T> EntryProcessorResult<T> invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... args) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { return delegate.invoke(key, entryProcessor, args); } finally { gate.leave(prev); } }
/** * Invoke some processor and return new value. * * @param id ID. * @param proc Processor. * @return New file info. * @throws IgniteCheckedException If failed. */ private IgfsEntryInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo> proc) throws IgniteCheckedException { validTxState(true); EntryProcessorResult<IgfsEntryInfo> res = id2InfoPrj.invoke(id, proc); assert res != null; return res.get(); }
/** * Stores the given block in data cache. * * @param blockSize The size of the block. * @param key The data cache key of the block. * @param data The new value of the block. * @throws IgniteCheckedException If failed. */ private void putBlock(int blockSize, IgfsBlockKey key, byte[] data) throws IgniteCheckedException { if (data.length < blockSize) // partial (incomplete) block: dataCachePrj.invoke(key, new IgfsDataPutProcessor(data)); else { // whole block: assert data.length == blockSize; dataCachePrj.put(key, data); } }
/** * Success if implicit tx fails. * * @param cache Cache instance. * @throws Exception If failed. */ protected void checkImplicitTxSuccess(final IgniteInternalCache<Object, Object> cache) throws Exception { cache.invoke("key", new EntryProcessor<Object, Object, Object>() { @Override public Object process(final MutableEntry<Object, Object> entry, final Object... args) throws EntryProcessorException { try { sleepForTxFailure(); } catch (InterruptedException e) { throw new EntryProcessorException(e); } return null; } }); cache.clear(); }
/** {@inheritDoc} */ @Override public long getAndIncrement() { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, GetAndIncrementProcessor.INSTANCE); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public long getAndDecrement() { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, GetAndDecrementProcessor.INSTANCE); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public long incrementAndGet() { checkRemoved(); try{ EntryProcessorResult<Long> res = cacheView.invoke(key, IncrementAndGetProcessor.INSTANCE); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public long decrementAndGet() { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, DecrementAndGetProcessor.INSTANCE); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... args) throws EntryProcessorException { IgniteInternalCache<K, V> delegate = getDelegateSafe(); try { if (isAsync()) { setFuture(invokeAsync0(key, entryProcessor, args)); return null; } else { EntryProcessorResult<T> res = delegate.invoke(key, entryProcessor, args); return res != null ? res.get() : null; } } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public long getAndAdd(long l) { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, new GetAndAddProcessor(l)); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public long getAndSet(long l) { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, new GetAndSetProcessor(l)); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public long addAndGet(long l) { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, new AddAndGetProcessor(l)); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public boolean compareAndSet(long expVal, long newVal) { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, new CompareAndSetProcessor(expVal, newVal)); assert res != null && res.get() != null : res; return res.get() == expVal; } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
@Override public Void applyx() throws IgniteCheckedException { validTxState(true); // Lock file ID for this transaction. IgfsEntryInfo oldInfo = info(fileId); if (oldInfo == null) throw fsException(new IgfsPathNotFoundException("Failed to unlock file (file not " + "found): " + fileId)); if (!F.eq(lockId, oldInfo.lockId())) throw new IgniteCheckedException("Failed to unlock file (inconsistent file lock ID) " + "[fileId=" + fileId + ", lockId=" + lockId + ", actualLockId=" + oldInfo.lockId() + ']'); id2InfoPrj.invoke(fileId, new IgfsMetaFileUnlockProcessor(modificationTime, updateSpace, space, affRange)); return null; } });
/** * @param expVal Expected value. * @param newVal New value. * @return Old value. */ public long compareAndSetAndGet(long expVal, long newVal) { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, new CompareAndSetProcessor(expVal, newVal)); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** * Put new entry to meta cache immediately linking it to parent. * * @param info Info to put. * @param parentId Parent ID. * @param name Name in parent. * @throws IgniteCheckedException If failed. */ private void createNewEntry(IgfsEntryInfo info, IgniteUuid parentId, String name) throws IgniteCheckedException { validTxState(true); if (!id2InfoPrj.putIfAbsent(info.id(), info)) throw fsException("Failed to create new metadata entry due to ID conflict: " + info.id()); if (parentId != null) id2InfoPrj.invoke(parentId, new IgfsMetaDirectoryListingAddProcessor(name, new IgfsListingEntry(info))); }