* @param ready the ForwardedReadyTransaction message to process
* @param sender the sender of the message
* @param shard the transaction's shard actor
* @param ready the ForwardedReadyTransaction message to process
* @param sender the sender of the message
* @param shard the transaction's shard actor
*/
void handleForwardedReadyTransaction(final ForwardedReadyTransaction ready, final ActorRef sender,
final Shard shard) {
log.debug("{}: Readying transaction {}, client version {}", name,
*/
void handleForwardedReadyTransaction(final ForwardedReadyTransaction ready, final ActorRef sender,
final Shard shard) {
log.debug("{}: Readying transaction {}, client version {}", name,
final ShardDataTreeCohort cohort = ready.getTransaction().ready();
final CohortEntry cohortEntry = CohortEntry.createReady(cohort, ready.getTxnClientVersion());
final ShardDataTreeCohort cohort = ready.getTransaction().ready();
final CohortEntry cohortEntry = CohortEntry.createReady(cohort, ready.getTxnClientVersion());
* @param sender the sender of the message
*/
void handleBatchedModifications(final BatchedModifications batched, final ActorRef sender, final Shard shard) {
* @param sender the sender of the message
*/
void handleBatchedModifications(final BatchedModifications batched, final ActorRef sender, final Shard shard) {
}
if (log.isDebugEnabled()) {
log.debug("{}: Applying {} batched modifications for Tx {}", name,
}
if (log.isDebugEnabled()) {
log.debug("{}: Applying {} batched modifications for Tx {}", name,
}
cohortEntry.applyModifications(batched.getModifications());
if (batched.isReady()) {
if (cohortEntry.getLastBatchedModificationsException() != null) {
}
cohortEntry.applyModifications(batched.getModifications());
if (batched.isReady()) {
if (cohortEntry.getLastBatchedModificationsException() != null) {
throw cohortEntry.getLastBatchedModificationsException();
}
if (cohortEntry.getTotalBatchedModificationsReceived() != batched.getTotalMessagesSent()) {
throw cohortEntry.getLastBatchedModificationsException();
}
if (cohortEntry.getTotalBatchedModificationsReceived() != batched.getTotalMessagesSent()) {
throw new IllegalStateException(String.format(
"The total number of batched messages received %d does not match the number sent %d",
cohortEntry.getTotalBatchedModificationsReceived(), batched.getTotalMessagesSent()));
throw new IllegalStateException(String.format(
"The total number of batched messages received %d does not match the number sent %d",
cohortEntry.getTotalBatchedModificationsReceived(), batched.getTotalMessagesSent()));
if (log.isDebugEnabled()) {
log.debug("{}: Readying Tx {}, client version {}", name,
if (log.isDebugEnabled()) {
log.debug("{}: Readying Tx {}, client version {}", name,
* @param shard the transaction's shard actor
*/
void handleReadyLocalTransaction(final ReadyLocalTransaction message, final ActorRef sender, final Shard shard) {
* @param shard the transaction's shard actor
*/
void handleReadyLocalTransaction(final ReadyLocalTransaction message, final ActorRef sender, final Shard shard) {
- final ShardDataTreeCohort cohort = dataTree.createReadyCohort(message.getTransactionID(),
- message.getModification());
+ final TransactionIdentifier txId = message.getTransactionId();
+ final ShardDataTreeCohort cohort = dataTree.newReadyCohort(txId, message.getModification());
Collection<BatchedModifications> createForwardedBatchedModifications(final BatchedModifications from,
final int maxModificationsPerBatch) {
Collection<BatchedModifications> createForwardedBatchedModifications(final BatchedModifications from,
final int maxModificationsPerBatch) {
if (cohortEntry == null || cohortEntry.getTransaction() == null) {
return Collections.singletonList(from);
}
if (cohortEntry == null || cohortEntry.getTransaction() == null) {
return Collections.singletonList(from);
}
cohortEntry.getTransaction().getSnapshot().applyToCursor(new AbstractBatchedModificationsCursor() {
@Override
protected BatchedModifications getModifications() {
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()));
+ if (newModifications.isEmpty()
+ || newModifications.getLast().getModifications().size() >= maxModificationsPerBatch) {
+ newModifications.add(new BatchedModifications(from.getTransactionId(), from.getVersion()));
- cohortCache.remove(cohortEntry.getTransactionID());
- cohortEntry.getReplySender().tell(new Failure(t), cohortEntry.getShard().self());
+ cohortCache.remove(cohortEntry.getTransactionId());
+ cohortEntry.getReplySender().tell(new Failure(failure), cohortEntry.getShard().self());
- private void doCommit(final CohortEntry cohortEntry) {
- log.debug("{}: Committing transaction {}", name, cohortEntry.getTransactionID());
+ void doCommit(final CohortEntry cohortEntry) {
+ log.debug("{}: Committing transaction {}", name, cohortEntry.getTransactionId());
// We perform the preCommit phase here atomically with the commit phase. This is an
// optimization to eliminate the overhead of an extra preCommit message. We lose front-end
// We perform the preCommit phase here atomically with the commit phase. This is an
// optimization to eliminate the overhead of an extra preCommit message. We lose front-end
- cohortCache.remove(cohortEntry.getTransactionID());
- cohortEntry.getReplySender().tell(new Failure(t), cohortEntry.getShard().self());
+ cohortCache.remove(cohortEntry.getTransactionId());
+ cohortEntry.getReplySender().tell(new Failure(failure), cohortEntry.getShard().self());
- private void finishCommit(@Nonnull final ActorRef sender, @Nonnull final CohortEntry cohortEntry) {
- log.debug("{}: Finishing commit for transaction {}", persistenceId(), cohortEntry.getTransactionID());
+ void finishCommit(@Nonnull final ActorRef sender, @Nonnull final CohortEntry cohortEntry) {
+ log.debug("{}: Finishing commit for transaction {}", persistenceId(), cohortEntry.getTransactionId());
cohortEntry.commit(new FutureCallback<UnsignedLong>() {
@Override
public void onSuccess(final UnsignedLong result) {
cohortEntry.commit(new FutureCallback<UnsignedLong>() {
@Override
public void onSuccess(final UnsignedLong result) {
log.debug("{}: Transaction {} committed as {}, sending response to {}", persistenceId(), txId, result,
sender);
log.debug("{}: Transaction {} committed as {}, sending response to {}", persistenceId(), txId, result,
sender);
sender.tell(CommitTransactionReply.instance(cohortEntry.getClientVersion()).toSerializable(),
cohortEntry.getShard().self());
}
@Override
sender.tell(CommitTransactionReply.instance(cohortEntry.getClientVersion()).toSerializable(),
cohortEntry.getShard().self());
}
@Override
log.error("{}, An exception occurred while committing transaction {}", persistenceId(),
log.error("{}, An exception occurred while committing transaction {}", persistenceId(),
- cohortCache.remove(cohortEntry.getTransactionID());
- sender.tell(new Failure(t), cohortEntry.getShard().self());
+ cohortCache.remove(cohortEntry.getTransactionId());
+ sender.tell(new Failure(failure), cohortEntry.getShard().self());
void handleAbort(final Identifier transactionID, final ActorRef sender, final Shard shard) {
CohortEntry cohortEntry = cohortCache.remove(transactionID);
if (cohortEntry == null) {
void handleAbort(final Identifier transactionID, final ActorRef sender, final Shard shard) {
CohortEntry cohortEntry = cohortCache.remove(transactionID);
if (cohortEntry == null) {
log.debug("{}: Aborting transaction {}", name, transactionID);
final ActorRef self = shard.getSelf();
log.debug("{}: Aborting transaction {}", name, transactionID);
final ActorRef self = shard.getSelf();
}
void checkForExpiredTransactions(final long timeout, final Shard shard) {
Iterator<CohortEntry> iter = cohortCache.values().iterator();
while (iter.hasNext()) {
CohortEntry cohortEntry = iter.next();
}
void checkForExpiredTransactions(final long timeout, final Shard shard) {
Iterator<CohortEntry> iter = cohortCache.values().iterator();
while (iter.hasNext()) {
CohortEntry cohortEntry = iter.next();