本文整理汇总了Java中javax.cache.processor.MutableEntry类的典型用法代码示例。如果您正苦于以下问题:Java MutableEntry类的具体用法?Java MutableEntry怎么用?Java MutableEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MutableEntry类属于javax.cache.processor包,在下文中一共展示了MutableEntry类的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 Void process(MutableEntry<String, WebSession> entry, Object... args) {
if (!entry.exists())
return null;
WebSession ses0 = entry.getValue();
WebSession ses = new WebSession(ses0.getId(), ses0);
for (T2<String, Object> update : updates) {
String name = update.get1();
assert name != null;
Object val = update.get2();
if (val != null)
ses.setAttribute(name, val);
else
ses.removeAttribute(name);
}
entry.setValue(ses);
return null;
}
示例3: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Boolean process(MutableEntry<Object, Object> entry, Object... arguments)
throws EntryProcessorException {
if (!entry.exists())
return null; // Someone got ahead of us and removed this entry, let's skip it.
Object entryVal = entry.getValue();
if (entryVal == null)
return null;
// Something happened to the cache while we were performing map-reduce.
if (!F.eq(entryVal, val))
return false;
entryModifier.apply(entry);
return null; // To leave out only erroneous keys - nulls are skipped on results' processing.
}
示例4: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Object process(MutableEntry<String, Set> entry,
Object... arguments) throws EntryProcessorException {
assert !F.isEmpty(arguments);
Object val = arguments[0];
Set set;
if (!entry.exists())
set = new HashSet<>();
else
set = entry.getValue();
set.add(val);
entry.setValue(set);
return null;
}
示例5: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@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;
}
示例6: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
IgfsEntryInfo fileInfo = e.getValue();
assert fileInfo != null && fileInfo.isDirectory() : fileInfo;
Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
// Modify listing in-place.
IgfsListingEntry oldEntry = listing.put(fileName, entry);
if (oldEntry != null && !oldEntry.fileId().equals(entry.fileId())) {
throw new IgniteException("Directory listing contains unexpected file" +
" [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry +
", oldEntry=" + oldEntry + ']');
}
e.setValue(fileInfo.listing(listing));
return null;
}
示例7: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
IgfsEntryInfo info = IgfsUtils.createDirectory(
entry.getKey(),
null,
props,
accessTime,
modificationTime
);
if (childName != null)
info = info.listing(Collections.singletonMap(childName, childEntry));
entry.setValue(info);
return info;
}
示例8: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
IgfsEntryInfo info = IgfsUtils.createFile(
entry.getKey(),
blockSize,
len,
affKey,
lockId,
evictExclude,
props,
accessTime,
modificationTime
);
entry.setValue(info);
return info;
}
示例9: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
throws EntryProcessorException {
IgfsEntryInfo fileInfo = e.getValue();
assert fileInfo != null;
assert fileInfo.isDirectory();
Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
IgfsListingEntry oldEntry = listing.get(fileName);
if (oldEntry == null || !oldEntry.fileId().equals(fileId))
throw new IgniteException("Directory listing doesn't contain expected file" +
" [listing=" + listing + ", fileName=" + fileName + "]");
// Modify listing in-place.
listing.remove(fileName);
e.setValue(fileInfo.listing(listing));
return null;
}
示例10: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Void process(MutableEntry<String, PlatformDotNetSessionData> entry, Object... args)
throws EntryProcessorException {
assert entry.exists();
PlatformDotNetSessionData data = entry.getValue();
assert data != null;
// Unlock and update.
data = update
? data.updateAndUnlock(lockNodeId, lockId, items, isDiff, staticData, timeout)
: data.unlock(lockNodeId, lockId);
// Apply.
entry.setValue(data);
return null;
}
示例11: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Object process(MutableEntry entry, Object... args)
throws EntryProcessorException {
try {
Ignite ignite = (Ignite)entry.unwrap(Ignite.class);
PlatformProcessor interopProc;
try {
interopProc = PlatformUtils.platformProcessor(ignite);
}
catch (IllegalStateException ex){
throw new EntryProcessorException(ex);
}
interopProc.awaitStart();
return execute0(interopProc.context(), entry);
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
示例12: writeEntryAndProcessor
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/**
* Writes mutable entry and entry processor to the stream.
*
* @param entry Entry to process.
* @param writer Writer.
*/
private void writeEntryAndProcessor(MutableEntry entry, BinaryRawWriter writer) {
if (ptr != 0) {
// Execute locally - we have a pointer to native processor.
writer.writeBoolean(true);
writer.writeLong(ptr);
}
else {
// We are on a remote node. Send processor holder back to native.
writer.writeBoolean(false);
writer.writeObject(proc);
}
writer.writeObject(entry.getKey());
writer.writeObject(entry.getValue());
}
示例13: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@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());
}
示例14: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Integer process(MutableEntry<Integer, Integer> e,
Object... arguments) throws EntryProcessorException {
Ignite ignite = e.unwrap(Ignite.class);
assertNotNull(ignite);
if (e.exists()) {
Integer val = e.getValue();
assertNotNull(val);
e.setValue(val + 1);
assertTrue(e.exists());
assertEquals(val + 1, (int) e.getValue());
return val;
}
else {
e.setValue(1);
return -1;
}
}
示例15: process
import javax.cache.processor.MutableEntry; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Boolean process(MutableEntry<GridCacheInternalKey, GridCacheAtomicStampedValue<T, S>> e,
Object... args) {
GridCacheAtomicStampedValue val = e.getValue();
if (val == null)
throw new EntryProcessorException("Failed to find atomic stamped with given name: " + e.getKey().name());
if (F.eq(expVal, val.value()) && F.eq(expStamp, val.stamp())) {
e.setValue(new GridCacheAtomicStampedValue<>(newVal, newStamp));
return true;
}
return false;
}