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

The following examples show how to use javax.cache.processor.MutableEntry#setValue() . 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: IgfsDataManager.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public Void process(MutableEntry<IgfsBlockKey, byte[]> entry, Object... args) {
    byte[] e = entry.getValue();

    final int size = data.length;

    if (e == null || e.length == 0)
        e = new byte[start + size]; // Don't allocate more, then required.
    else if (e.length < start + size) {
        // Expand stored data array, if it less, then required.
        byte[] tmp = new byte[start + size]; // Don't allocate more than required.

        U.arrayCopy(e, 0, tmp, 0, e.length);

        e = tmp;
    }

    // Copy data into entry.
    U.arrayCopy(data, 0, e, start, size);

    entry.setValue(e);

    return null;
}
 
Example 2
Source File: IgniteCacheInvokeReadThroughAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> entry, Object... args) {
    if (!entry.exists()) {
        failed = true;

        fail();
    }

    Integer val = (Integer)entry.getValue();

    if (!val.equals(entry.getKey())) {
        failed = true;

        assertEquals(val, entry.getKey());
    }

    entry.setValue(val + 1);

    return val;
}
 
Example 3
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 4
Source File: GridCacheAtomicLongImpl.java    From ignite with Apache License 2.0 5 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();

    if (curVal == expVal)
        e.setValue(new GridCacheAtomicLongValue(newVal));

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

    e.setValue(ThreadLocalRandom.current().nextInt() + (oldVal == null ? 0 : oldVal));

    return super.process(e, args);
}
 
Example 6
Source File: CrossCacheTxRandomOperationsTest.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 7
Source File: CacheContinuousQueryVariationsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> e, Object... args) {
    if (skipModify)
        return null;

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

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

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

    entry.setValue(v);

    return null;
}
 
Example 9
Source File: IgniteTransactionalInvokeRetryBenchmark.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Long process(MutableEntry<String, Long> entry,
    Object... arguments) throws EntryProcessorException {
    long newVal = entry.getValue() == null ? 0 : entry.getValue() + 1;

    entry.setValue(newVal);

    return newVal;
}
 
Example 10
Source File: CacheEntryProcessorExternalizableFailedTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Integer process(MutableEntry<Integer, Integer> entry, Object... arguments)
    throws EntryProcessorException {
    entry.setValue(42);

    return null;
}
 
Example 11
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 12
Source File: CacheContinuousQueryOperationFromCallbackTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<QueryTestKey, QueryTestValue> entry, Object... arguments)
    throws EntryProcessorException {
    if (entry.exists())
        entry.setValue(new QueryTestValue(entry.getValue().val1 + 1));
    else
        entry.setValue(new QueryTestValue(0));

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

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

    return old;
}
 
Example 14
Source File: IgniteCacheBinaryEntryProcessorSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Void process(MutableEntry<Integer, BinaryObject> entry, Object... arguments)
    throws EntryProcessorException {
    BinaryObjectBuilder bldr = entry.getValue().toBuilder();

    Integer val = bldr.<Integer>getField("val");

    bldr.setField("val", val + 1);
    bldr.setField("strVal", "updated-" + val);

    entry.setValue(bldr.build());

    return null;
}
 
Example 15
Source File: HadoopJobTracker.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Void process(MutableEntry<HadoopJobId, HadoopJobMetadata> e, Object... args) {
    HadoopJobMetadata val = apply(e.getValue());

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

    return null;
}
 
Example 16
Source File: IgfsDataPutProcessor.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Void process(MutableEntry<IgfsBlockKey, byte[]> entry, Object... args)
    throws EntryProcessorException {
    byte[] curVal = entry.getValue();

    if (curVal == null || newVal.length > curVal.length)
        entry.setValue(newVal);

    return null;
}
 
Example 17
Source File: GridCacheTransformEventSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Void process(MutableEntry<Integer, Integer> e, Object... args) {
    e.setValue(e.getValue() + 1);

    return null;
}
 
Example 18
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(curVal + delta));

    return curVal;
}
 
Example 19
Source File: IgfsMetaFileRangeUpdateProcessor.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.updateRangeStatus(range, status);

    IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);

    entry.setValue(newInfo);

    return newInfo;
}
 
Example 20
Source File: IgfsMetaFileReserveSpaceProcessor.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.addRange(affRange);

    IgfsEntryInfo newInfo = oldInfo.length(oldInfo.length() + space).fileMap(newMap);

    entry.setValue(newInfo);

    return newInfo;
}