package org.opendaylight.controller.cluster.datastore;
import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
abstract class AbstractTransactionContext implements TransactionContext {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractTransactionContext.class);
+
+ private long modificationCount = 0;
+
private final TransactionIdentifier identifier;
protected AbstractTransactionContext(TransactionIdentifier identifier) {
protected final TransactionIdentifier getIdentifier() {
return identifier;
}
+
+ protected void incrementModificationCount(){
+ modificationCount++;
+ }
+
+ protected void logModificationCount(){
+ LOG.debug("Total modifications on Tx {} = [ {} ]", identifier, modificationCount);
+ }
}
\ No newline at end of file
@Override
public void writeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+ incrementModificationCount();
getWriteDelegate().write(path, data);
completer.onComplete(null, null);
}
@Override
public void mergeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+ incrementModificationCount();
getWriteDelegate().merge(path, data);
completer.onComplete(null, null);
}
@Override
public void deleteData(YangInstanceIdentifier path) {
+ incrementModificationCount();
getWriteDelegate().delete(path);
completer.onComplete(null, null);
}
}
private LocalThreePhaseCommitCohort ready() {
+ logModificationCount();
LocalThreePhaseCommitCohort ready = (LocalThreePhaseCommitCohort) getWriteDelegate().ready();
completer.onComplete(null, null);
return ready;
@Override
public Future<ActorSelection> readyTransaction() {
+ logModificationCount();
+
LOG.debug("Tx {} readyTransaction called", getIdentifier());
// Send the remaining batched modifications, if any, with the ready flag set.
}
private void batchModification(Modification modification) {
+ incrementModificationCount();
if(batchedModifications == null) {
batchedModifications = newBatchedModifications();
}