@Override public void applyToCursor(DataTreeModificationCursor dataTreeModificationCursor) { delegate.applyToCursor(dataTreeModificationCursor); }
@Override public synchronized void applyToCursor(@Nonnull final DataTreeModificationCursor cursor) { delegate.applyToCursor(cursor); }
@Override public synchronized void applyToCursor(@Nonnull final DataTreeModificationCursor cursor) { delegate.applyToCursor(cursor); }
public static void toFile(File file, DataTreeModification modification) { try(FileOutputStream outStream = new FileOutputStream(file)) { modification.applyToCursor(new DataTreeModificationOutputCursor(new DataOutputStream(outStream))); } catch(Exception e) { LOG.error("Error writing DataTreeModification to file {}", file, e); } }
@Override public final void validate() throws ValidationFailedException { // Modification requires to be sealed before validation. // Sealed modification cannot be altered, so create copy. final CursorAwareDataTreeModification modificationCopy = (CursorAwareDataTreeModification) snapshot.newModification(); final DataTreeModificationCursor cursor = modificationCopy.createCursor(dataTree.getRootPath()); checkState(cursor != null, "DataTreeModificationCursor for root path should not be null"); modification.applyToCursor(cursor); // Then validate it. validateCandidate(prepareCandidateContext(modificationCopy)); }
@Override public void ready() { try { delegate.ready(); } catch (SchemaValidationFailedException e) { DataTreeModification newModification = dataTree.takeSnapshot().newModification(); delegate.applyToCursor(new PruningDataTreeModificationCursor(newModification, this)); delegate = newModification; delegate.ready(); } }
@Override public byte[] toBinary(final Object obj) { Preconditions.checkArgument(obj instanceof ReadyLocalTransaction, "Unsupported object type %s", obj.getClass()); final ReadyLocalTransaction readyLocal = (ReadyLocalTransaction) obj; final BatchedModifications batched = new BatchedModifications(readyLocal.getTransactionID(), readyLocal.getRemoteVersion()); batched.setDoCommitOnReady(readyLocal.isDoCommitOnReady()); batched.setTotalMessagesSent(1); batched.setReady(true); readyLocal.getModification().applyToCursor(new BatchedCursor(batched)); return SerializationUtils.serialize(batched); }
Collection<BatchedModifications> createForwardedBatchedModifications(final BatchedModifications from, final int maxModificationsPerBatch) { CohortEntry cohortEntry = cohortCache.remove(from.getTransactionID()); if (cohortEntry == null || cohortEntry.getTransaction() == null) { return Collections.singletonList(from); } cohortEntry.applyModifications(from.getModifications()); final LinkedList<BatchedModifications> newModifications = new LinkedList<>(); cohortEntry.getTransaction().getSnapshot().applyToCursor(new AbstractBatchedModificationsCursor() { @Override protected BatchedModifications getModifications() { if (newModifications.isEmpty() || newModifications.getLast().getModifications().size() >= maxModificationsPerBatch) { newModifications.add(new BatchedModifications(from.getTransactionID(), from.getVersion())); } return newModifications.getLast(); } }); BatchedModifications last = newModifications.getLast(); last.setDoCommitOnReady(from.isDoCommitOnReady()); last.setReady(from.isReady()); last.setTotalMessagesSent(newModifications.size()); return newModifications; }
cohortEntry.getDataTreeModification().applyToCursor(new AbstractBatchedModificationsCursor() { @Override protected BatchedModifications getModifications() {