BUG-8402: Separate out OutOfOrderRequestException
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / AbstractFrontendHistory.java
index 6ca58888d3a830e772dc07fd95988bac0ef42e1e..f2612949e0bf602cc3d70eb33fc667cfd4c76159 100644 (file)
@@ -44,7 +44,6 @@ import org.slf4j.LoggerFactory;
  */
 abstract class AbstractFrontendHistory implements Identifiable<LocalHistoryIdentifier> {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractFrontendHistory.class);
-    private static final OutOfOrderRequestException UNSEQUENCED_START = new OutOfOrderRequestException(0);
 
     private final Map<TransactionIdentifier, FrontendTransaction> transactions = new HashMap<>();
     private final RangeSet<UnsignedLong> purgedTransactions;
@@ -137,7 +136,7 @@ abstract class AbstractFrontendHistory implements Identifiable<LocalHistoryIdent
             // The transaction does not exist and we are about to create it, check sequence number
             if (request.getSequence() != 0) {
                 LOG.debug("{}: no transaction state present, unexpected request {}", persistenceId(), request);
-                throw UNSEQUENCED_START;
+                throw new OutOfOrderRequestException(0);
             }
 
             tx = createTransaction(request, id);
@@ -172,16 +171,19 @@ abstract class AbstractFrontendHistory implements Identifiable<LocalHistoryIdent
             throws RequestException {
         if (request instanceof CommitLocalTransactionRequest) {
             LOG.debug("{}: allocating new ready transaction {}", persistenceId(), id);
+            tree.getStats().incrementReadWriteTransactionCount();
             return createReadyTransaction(id, ((CommitLocalTransactionRequest) request).getModification());
         }
         if (request instanceof AbstractReadTransactionRequest) {
             if (((AbstractReadTransactionRequest<?>) request).isSnapshotOnly()) {
-                LOG.debug("{}: allocatint new open snapshot {}", persistenceId(), id);
+                LOG.debug("{}: allocating new open snapshot {}", persistenceId(), id);
+                tree.getStats().incrementReadOnlyTransactionCount();
                 return createOpenSnapshot(id);
             }
         }
 
         LOG.debug("{}: allocating new open transaction {}", persistenceId(), id);
+        tree.getStats().incrementReadWriteTransactionCount();
         return createOpenTransaction(id);
     }