本文整理汇总了Java中javax.cache.processor.MutableEntry.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java MutableEntry.setValue方法的具体用法?Java MutableEntry.setValue怎么用?Java MutableEntry.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.cache.processor.MutableEntry
的用法示例。
在下文中一共展示了MutableEntry.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
@Override public Object process(MutableEntry<BinaryObject, BinaryObject> entry,
Object... arguments) throws EntryProcessorException {
BinaryObject val = entry.getValue();
/** The message will be printed on the node that stores the entry! */
System.out.println(">> Before update:");
System.out.println(val);
if (increase)
val = val.toBuilder().setField("POPULATION", (int)val.field("POPULATION") + delta).build();
else
val = val.toBuilder().setField("POPULATION", (int)val.field("POPULATION") - delta).build();
entry.setValue(val);
return entry;
}
示例2: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@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();
}
示例3: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Boolean process(MutableEntry<GridCacheInternalKey, GridCacheAtomicReferenceValue<T>> e,
Object... args) {
GridCacheAtomicReferenceValue<T> val = e.getValue();
if (val == null)
throw new EntryProcessorException("Failed to find atomic reference with given name: " + e.getKey().name());
T curVal = val.get();
if (F.eq(expVal, curVal)) {
e.setValue(new GridCacheAtomicReferenceValue<T>(newVal));
return true;
}
return false;
}
示例4: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
IgfsEntryInfo oldInfo = entry.getValue();
Map<String, String> tmp = oldInfo.properties();
tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp);
for (Map.Entry<String, String> e : props.entrySet()) {
if (e.getValue() == null)
// Remove properties with 'null' values.
tmp.remove(e.getKey());
else
// Add/overwrite property.
tmp.put(e.getKey(), e.getValue());
}
IgfsEntryInfo newInfo = oldInfo.properties(tmp);
entry.setValue(newInfo);
return newInfo;
}
示例5: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Boolean process(MutableEntry<Object, Object> entry, Object... arguments)
throws EntryProcessorException {
if (entry.exists())
return false;
entry.setValue(val);
return null; // To leave out only erroneous keys - nulls are skipped on results' processing.
}
示例6: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Integer process(MutableEntry<Integer, Integer> entry, Object... arguments)
throws EntryProcessorException {
entry.setValue(42);
return null;
}
示例7: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@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;
}
示例8: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@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;
}
示例9: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Integer process(MutableEntry<String, Integer> entry, Object... arguments) {
Integer currVal = entry.getValue();
if (currVal == null)
entry.setValue(0);
else
entry.setValue(currVal + 1);
return null;
}
示例10: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@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;
}
示例11: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@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;
}
示例12: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Integer process(MutableEntry<String, Integer> entry,
Object... arguments) throws EntryProcessorException {
Integer val = entry.getValue();
entry.setValue(newVal);
return val;
}
示例13: testInvoke
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
@Test
public void testInvoke()
{
final CacheLoader<String, Integer> cacheLoader = new CacheLoader<String, Integer>()
{
@Override
public Integer load(String key)
throws CacheLoaderException
{
return Integer.valueOf(key);
}
@Override
public Map<String, Integer> loadAll(Iterable<? extends String> keys)
throws CacheLoaderException
{
throw new UnsupportedOperationException("Not supported yet.");
}
};
final EntryProcessor<String, Integer, Boolean> entryProcessor = new EntryProcessor<String, Integer, Boolean>()
{
@Override
public Boolean process(MutableEntry<String, Integer> entry, Object... arguments)
throws EntryProcessorException
{
assertTrue(entry.exists());
assertEquals(Integer.valueOf(1), entry.getValue());
entry.setValue(2);
assertEquals(Integer.valueOf(2), entry.getValue());
entry.remove();
assertFalse(entry.exists());
return Boolean.TRUE;
}
};
MutableConfiguration<String, Integer> custom = new MutableConfiguration<>(configuration);
custom.setReadThrough(true);
custom.setCacheLoaderFactory
(
new Factory<CacheLoader<String, Integer>>()
{
@Override
public CacheLoader<String, Integer> create()
{
return cacheLoader;
}
}
);
Cache<String, Integer> invokingCache = cacheManager.createCache("invokingCache", custom);
assertTrue(invokingCache.invoke("1", entryProcessor));
assertFalse(invokingCache.containsKey("1"));
}
示例14: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Void process(MutableEntry<Integer, Integer> e, Object... args) {
Integer val = e.getValue();
if (val == null) {
failed = true;
System.out.println(Thread.currentThread() + " got null in processor: " + val);
return null;
}
e.setValue(val + 1);
return null;
}
示例15: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
@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]);
assertFalse(newVal instanceof BinaryObject);
entry.setValue(newVal);
return val == null ? null : ((BinaryObject)val).deserialize();
}