本文整理汇总了Java中javax.cache.processor.MutableEntry.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java MutableEntry.getKey方法的具体用法?Java MutableEntry.getKey怎么用?Java MutableEntry.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.cache.processor.MutableEntry
的用法示例。
在下文中一共展示了MutableEntry.getKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Boolean process(MutableEntry<String, String> entry, Object... arguments)
throws EntryProcessorException {
String val = entry.getKey();
return true;
}
示例2: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Long, String> entry, Object... args) {
long key = entry.getKey();
if (key % 2 == 0)
entry.remove();
else
entry.setValue(entry.getValue() + "-");
return null;
}
示例3: process
import javax.cache.processor.MutableEntry; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Result process(MutableEntry<IntegerKey, Integer> entry, Object... objects) {
try {
Ignite ignite = entry.unwrap(Ignite.class);
PartitionObserver observer = ignite.services().service(PartitionObserver.class.getName());
assertNotNull(observer);
IgniteCache<IntegerKey, Integer> cache = ignite.cache(TEST_CACHE_NAME);
Affinity<IntegerKey> affinity = ignite.affinity(TEST_CACHE_NAME);
Set<IntegerKey> exp = this.keys;
Set<IntegerKey> missing = getMissingKeys(cache, exp);
IntegerKey key = entry.getKey();
int part = affinity.partition(key);
String ownership = affinity.isPrimary(ignite.cluster().localNode(), key) ? "primary" : "backup";
// Wait for the local listener to sync past events.
if (!observer.getIgniteLocalSyncListener().isSynced()) {
ignite.log().info("Retrying validation for " + ownership + " partition " + part
+ " due to initial sync");
return Result.RETRY;
}
// Determine if the partition is being loaded and wait for it to load completely.
if (observer.getLoadingMap().containsKey(part)) {
ignite.log().info("Retrying validation due to forming partition [ownership=" + ownership +
", partition=" + part +
", expKeys=" + exp +
", loadedKeys=" + observer.getLoadingMap().get(part) +
", missingLocalKeys=" + missing + ']');
return Result.RETRY;
}
if (!observer.getPartitionMap().containsKey(part)) {
ignite.log().info("Retrying validation due to newly arrived partition [ownership=" + ownership +
", partition=" + part +
", missingLocalKeys=" + missing + ']');
return Result.RETRY;
}
// Validate the key count.
Set<IntegerKey> curr = observer.ensureKeySet(part);
if (curr.equals(exp) && missing.isEmpty())
return Result.OK;
String msg = String.format("For %s partition %s:\n\texpected %s,\n\t" +
"but found %s;\n\tmissing local keys: %s",
ownership, part, new TreeSet<>(exp), new TreeSet<>(curr), new TreeSet<>(missing));
ignite.log().info(">>> " + msg);
throw new EntryProcessorException(msg);
}
catch (NullPointerException e) {
e.printStackTrace();
throw e;
}
}