- }
- }
-
- return messages;
- }
-
- /**
- * Returns the cohort entry for the Tx commit currently in progress if the given transaction ID
- * matches the current entry.
- *
- * @param transactionID the ID of the transaction
- * @return the current CohortEntry or null if the given transaction ID does not match the
- * current entry.
- */
- CohortEntry getCohortEntryIfCurrent(String transactionID) {
- if(isCurrentTransaction(transactionID)) {
- return currentCohortEntry;
- }
-
- return null;
- }
-
- CohortEntry getCurrentCohortEntry() {
- return currentCohortEntry;
- }
-
- CohortEntry getAndRemoveCohortEntry(String transactionID) {
- return cohortCache.remove(transactionID);
- }
-
- boolean isCurrentTransaction(String transactionID) {
- return currentCohortEntry != null &&
- currentCohortEntry.getTransactionID().equals(transactionID);
- }
-
- /**
- * This method is called when a transaction is complete, successful or not. If the given
- * given transaction ID matches the current in-progress transaction, the next cohort entry,
- * if any, is dequeued and processed.
- *
- * @param transactionID the ID of the completed transaction
- * @param removeCohortEntry if true the CohortEntry for the transaction is also removed from
- * the cache.
- */
- void currentTransactionComplete(String transactionID, boolean removeCohortEntry) {
- if(removeCohortEntry) {
- cohortCache.remove(transactionID);
- }
-
- if(isCurrentTransaction(transactionID)) {
- currentCohortEntry = null;
-
- log.debug("{}: currentTransactionComplete: {}", name, transactionID);
-
- maybeProcessNextCohortEntry();
- }
- }