本文整理汇总了Java中com.gigaspaces.client.ChangeSet类的典型用法代码示例。如果您正苦于以下问题:Java ChangeSet类的具体用法?Java ChangeSet怎么用?Java ChangeSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChangeSet类属于com.gigaspaces.client包,在下文中一共展示了ChangeSet类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAndGet
import com.gigaspaces.client.ChangeSet; //导入依赖的package包/类
/**
* Atomically adds the given value to the current value of an entry's property.
* @param gigaSpace the gigaspace which stores the entry.
* @param idQuery id the query which is used to locate the entry.
* @param path the path to the number property which is being modified.
* @param delta the value to add.
* @param modifiers the change modifiers to use.
* @param timeout time to wait if the entry is locked under a transaction.
* @param timeUnit units for the timeout.
* @return the updated value, null of no matching entry found for the given id query. Therefore you must use the
* primitive wrapper types as the result value (e.g. Integer/Long) otherwise you may get {@link NullPointerException} if no entry was found.
*/
public static <T, D extends Number> D addAndGet(GigaSpace gigaSpace,
IdQuery<T> idQuery, String path, D delta, ChangeModifiers modifiers, long timeout, TimeUnit timeUnit) {
if (idQuery == null)
throw new IllegalArgumentException("query cannot be null");
if (!StringUtils.hasLength(path))
throw new IllegalArgumentException("path cannot be null or empty");
ChangeResult<T> changeResult = gigaSpace.change(idQuery, new ChangeSet().increment(path, delta), modifiers.add(ChangeModifiers.RETURN_DETAILED_RESULTS), timeUnit.toMillis(timeout));
ChangedEntryDetails<T> changedEntryDetails = getSingleChangedEntryDetails(changeResult);
if (changedEntryDetails == null)
return null;
ChangeOperationResult changeOperationResult = changedEntryDetails.getChangeOperationsResults().get(0);
return (D)IncrementOperation.getNewValue(changeOperationResult);
}
示例2: ChangeSet
import com.gigaspaces.client.ChangeSet; //导入依赖的package包/类
public void ChangeSet() {
User user = new User();
user.setId(new Long(1));
user.setName("John Dow");
user.setStatus(EAccountStatus.ACTIVE);
space.write(user);
IdQuery<User> idQuery = new IdQuery<User>(User.class, new Long(1));
ChangeResult<User> changeResult = space.change(idQuery,
new ChangeSet().set("status", EAccountStatus.BLOCKED));
if (changeResult.getNumberOfChangedEntries() == 0) {
System.out.println("Entry does not exist");
}
}
示例3: addRule
import com.gigaspaces.client.ChangeSet; //导入依赖的package包/类
public void addRule(KnowledgePackage knowledgePackage, String ruleName, DroolsRule rule) {
IdQuery<KnowledgePackage> idQuery = new IdQuery<KnowledgePackage>(KnowledgePackage.class, knowledgePackage.getId(), knowledgePackage.getRuleSet());
gigaSpace.change(idQuery, new ChangeSet().set("lastUpdateDate", new Date(System.currentTimeMillis()))
.putInMap("rules", ruleName, rule)
.increment("totalRules" , 1));
}
示例4: removeRule
import com.gigaspaces.client.ChangeSet; //导入依赖的package包/类
public void removeRule(KnowledgePackage knowledgePackage, String ruleName) {
IdQuery<KnowledgePackage> idQuery = new IdQuery<KnowledgePackage>(KnowledgePackage.class, knowledgePackage.getId(), knowledgePackage.getRuleSet());
gigaSpace.change(idQuery, new ChangeSet().removeFromMap("rules", ruleName)
.decrement("totalRules" , 1));
}