Java Code Examples for javax.cache.processor.MutableEntry#getValue()

The following examples show how to use javax.cache.processor.MutableEntry#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetEntryWithComputedValueProcessor.java    From cache2k with Apache License 2.0 6 votes vote down vote up
@Override
public String process(MutableEntry<K, String> entry, Object... arguments) {
    StringBuffer computedValue = new StringBuffer();
    if (valuePrefix != null) {
        computedValue.append(valuePrefix);
    }
    computedValue.append(entry.getKey().toString());
    if (valuePostfix != null) {
        computedValue.append(valuePostfix);
    }

    // Not trying to be efficient here.
    // For testing purposes in entry processor, follow the set with a get.
    // It would be more efficient to just return value that was passed to setValue.
    // This is testing the entry processor path of create or update an entry followed by an entry access.
    entry.setValue(computedValue.toString());
    return entry.getValue();
}
 
Example 2
Source File: GridCacheQueueAdapter.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public IgniteBiTuple<Long, Long> process(
    MutableEntry<GridCacheQueueHeaderKey, GridCacheQueueHeader> e, Object... args) {
    GridCacheQueueHeader hdr = e.getValue();

    boolean rmvd = queueRemoved(hdr, id);

    if (rmvd)
        return new IgniteBiTuple<>(QUEUE_REMOVED_IDX, QUEUE_REMOVED_IDX);
    else if (hdr.empty())
        return null;

    GridCacheQueueHeader newHdr = new GridCacheQueueHeader(hdr.id(),
        hdr.capacity(),
        hdr.collocated(),
        hdr.tail(),
        hdr.tail(),
        null);

    e.setValue(newHdr);

    return new IgniteBiTuple<>(hdr.head(), hdr.tail());
}
 
Example 3
Source File: GridCacheQueueAdapter.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public Long process(MutableEntry<GridCacheQueueHeaderKey, GridCacheQueueHeader> e, Object... args) {
    GridCacheQueueHeader hdr = e.getValue();

    boolean rmvd = queueRemoved(hdr, id);

    if (rmvd || !spaceAvailable(hdr, size))
        return rmvd ? QUEUE_REMOVED_IDX : null;

    GridCacheQueueHeader newHdr = new GridCacheQueueHeader(hdr.id(),
        hdr.capacity(),
        hdr.collocated(),
        hdr.head(),
        hdr.tail() + size,
        hdr.removedIndexes());

    e.setValue(newHdr);

    return hdr.tail();
}
 
Example 4
Source File: CacheContinuousQueryRandomOperationsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> e, Object... args) {
    if (skipModify)
        return null;

    oldVal = e.getValue();

    Object old = retOld ? e.getValue() : null;

    if (val != null)
        e.setValue(val);
    else
        e.remove();

    return old;
}
 
Example 5
Source File: IgniteCacheReadThroughStoreCallTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> entry, Object... args) {
    Object val = entry.getValue();

    entry.setValue(entry.getKey());

    return val;
}
 
Example 6
Source File: GridCacheAbstractMetricsSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
@Override public Object process(
        MutableEntry<Integer, Integer> entry,
        Object... arguments
) throws EntryProcessorException {

    entry.getValue();

    return null;
}
 
Example 7
Source File: IgniteCacheCrossCacheTxFailoverTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public TestValue process(MutableEntry<TestKey, TestValue> e, Object... args) {
    TestValue old = e.getValue();

    if (val != null)
        e.setValue(new TestValue(val));

    return old;
}
 
Example 8
Source File: IgniteOnePhaseCommitInvokeTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry e, Object... args) {
    Object val = e.getValue();

    if (setVal)
        e.setValue(2);

    return retPrev ? val : null;
}
 
Example 9
Source File: IgniteCacheEntryListenerAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public String process(MutableEntry<Object, Object> e, Object... args) {
    if (e.getValue() instanceof ListenerTestValue)
        return String.valueOf(((ListenerTestValue)e.getValue()).val1);

    return String.valueOf(e.getValue());
}
 
Example 10
Source File: RemoveEntryProcessor.java    From blazingcache with Apache License 2.0 5 votes vote down vote up
@Override
public T process(MutableEntry<K, V> entry, Object... arguments) {
    T result = null;
    if (assertExists) {
        assertTrue(entry.exists());
        result = (T)entry.getValue();
    }
    entry.remove();
    assertFalse(entry.exists());

    return result;
}
 
Example 11
Source File: ReplaceEntryProcessor.java    From cache2k with Apache License 2.0 5 votes vote down vote up
@Override
public T process(MutableEntry<K, V> entry, Object... arguments) {
    assertTrue(entry.exists());
    V value1 = entry.getValue();
    assertEquals(oldValue, entry.getValue());
    entry.setValue(newValue);
    assertTrue(entry.exists());
    assertEquals(newValue, entry.getValue());

    return (T) value1;
}
 
Example 12
Source File: GetEntryProcessor.java    From blazingcache with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public V process(MutableEntry<K, V> entry, Object... arguments) {
    return entry.getValue();
}
 
Example 13
Source File: CacheDeploymenComputeWithNestedEntryProcessor.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Boolean process(MutableEntry entry, Object... arguments) throws EntryProcessorException {
    return entry.getValue() != null;
}
 
Example 14
Source File: WithKeepBinaryCacheFullApiTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
@Override public Object process(MutableEntry entry, Object... arguments) throws EntryProcessorException {
    assertTrue(entry.getKey() instanceof BinaryObject);

    Object val = entry.getValue();

    int valId = 0;

    if (val != null) {
        assertTrue(val instanceof BinaryObject);

        valId = valueOf(((BinaryObject)val).deserialize()) + 1;
    }

    Object newVal = value(valId, (DataMode)arguments[0]);

    Object newBinaryVal = ((Ignite)entry.unwrap(Ignite.class)).binary().toBinary(newVal);

    entry.setValue(newBinaryVal);

    return val;
}
 
Example 15
Source File: GridCacheAtomicLongImpl.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override public Long process(MutableEntry<GridCacheInternalKey, GridCacheAtomicLongValue> e, Object... args) {
    GridCacheAtomicLongValue val = e.getValue();

    if (val == null)
        throw new EntryProcessorException("Failed to find atomic long: " + e.getKey().name());

    long newVal = val.get() - 1;

    e.setValue(new GridCacheAtomicLongValue(newVal));

    return newVal;
}
 
Example 16
Source File: GridCacheAtomicLongImpl.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override public Long process(MutableEntry<GridCacheInternalKey, GridCacheAtomicLongValue> e, Object... args) {
    GridCacheAtomicLongValue val = e.getValue();

    if (val == null)
        throw new EntryProcessorException("Failed to find atomic long: " + e.getKey().name());

    long ret = val.get();

    e.setValue(new GridCacheAtomicLongValue(ret + 1));

    return ret;
}
 
Example 17
Source File: GridCacheAtomicLongImpl.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override public Long process(MutableEntry<GridCacheInternalKey, GridCacheAtomicLongValue> e, Object... args) {
    GridCacheAtomicLongValue val = e.getValue();

    if (val == null)
        throw new EntryProcessorException("Failed to find atomic long: " + e.getKey().name());

    long curVal = val.get();

    e.setValue(new GridCacheAtomicLongValue(newVal));

    return curVal;
}
 
Example 18
Source File: GridCacheAbstractFullApiSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override public String process(MutableEntry<String, Integer> e, Object... args) {
    assertNotNull(e.getKey());

    Integer old = e.getValue();

    e.setValue(old == null ? 1 : old + 1);

    return String.valueOf(old);
}
 
Example 19
Source File: IgfsMetaFileRangeDeleteProcessor.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
    throws EntryProcessorException {
    IgfsEntryInfo oldInfo = entry.getValue();

    IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());

    newMap.deleteRange(range);

    IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);

    entry.setValue(newInfo);

    return newInfo;
}
 
Example 20
Source File: GridCacheInterceptorAbstractSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
@Override public Void process(MutableEntry<String, Integer> e, Object... args) {
    Integer old = e.getValue();

    assertEquals(expOld, old);

    e.setValue(val);

    return null;
}