use of com.cinchapi.concourse.server.ConcourseServer.DeferredWrite in project concourse by cinchapi.
the class Operations method insertDeferredAtomic.
/**
* Atomically insert a list of {@link DeferredWrite deferred writes}. This
* method should only be called after all necessary calls to
* {@link #insertAtomic(Multimap, long, AtomicOperation, List)} have been
* made.
*
* @param parser
* @param deferred
* @param atomic
* @return {@code true} if all the writes are successful
*/
public static boolean insertDeferredAtomic(List<DeferredWrite> deferred, AtomicOperation atomic) {
// have already been checked
for (DeferredWrite write : deferred) {
if (write.getValue() instanceof ResolvableLink) {
ResolvableLink rlink = (ResolvableLink) write.getValue();
AbstractSyntaxTree ast = ConcourseCompiler.get().parse(rlink.getCcl());
Set<Long> targets = ast.accept(Finder.instance(), atomic);
for (long target : targets) {
if (target == write.getRecord()) {
// accidentally creates self links.
continue;
}
TObject link = Convert.javaToThrift(Link.to(target));
if (!atomic.add(write.getKey(), link, write.getRecord())) {
return false;
}
}
} else if (!atomic.add(write.getKey(), Convert.javaToThrift(write.getValue()), write.getRecord())) {
return false;
}
}
return true;
}
Aggregations