if (isLeader()) {
final LocalHistoryIdentifier id = closeTransactionChain.getIdentifier();
askProtocolEncountered(id.getClientId());
-
- // FIXME: CONTROLLER-1628: stage purge once no transactions are present
- store.closeTransactionChain(id, null);
- store.purgeTransactionChain(id, null);
+ store.closeTransactionChain(id);
} else if (getLeader() != null) {
getLeader().forward(closeTransactionChain, getContext());
} else {
* @param callback Callback to invoke upon completion, may be null
*/
void closeTransactionChain(final LocalHistoryIdentifier id, final @Nullable Runnable callback) {
+ if (commonCloseTransactionChain(id, callback)) {
+ replicatePayload(id, CloseLocalHistoryPayload.create(id,
+ shard.getDatastoreContext().getInitialPayloadSerializedBufferCapacity()), callback);
+ }
+ }
+
+ /**
+ * Close a single transaction chain which is received through ask-based protocol. It does not keep a commit record.
+ *
+ * @param id History identifier
+ */
+ void closeTransactionChain(final LocalHistoryIdentifier id) {
+ commonCloseTransactionChain(id, null);
+ }
+
+ private boolean commonCloseTransactionChain(final LocalHistoryIdentifier id, final @Nullable Runnable callback) {
final ShardDataTreeTransactionChain chain = transactionChains.get(id);
if (chain == null) {
LOG.debug("{}: Closing non-existent transaction chain {}", logContext, id);
if (callback != null) {
callback.run();
}
- return;
+ return false;
}
chain.close();
- replicatePayload(id, CloseLocalHistoryPayload.create(
- id, shard.getDatastoreContext().getInitialPayloadSerializedBufferCapacity()), callback);
+ return true;
}
/**