Skip to content

Commit

Permalink
调整事务提交逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyangming committed Jun 5, 2017
1 parent b1eed64 commit d065b1d
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,27 @@ public synchronized void participantCommit(boolean opc) throws RollbackException
}
}

private void checkForTransactionExtraIfNecessary() throws RollbackException, HeuristicMixedException,
HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException {

if (this.transactionalExtra != null) /* for ByteTCC */ {
if (this.participantList.isEmpty() == false && this.participant == null) /* see initGetTransactionStrategy */ {
this.participantRollback();
throw new HeuristicRollbackException();
} else if (this.participantList.size() > 1) {
this.participantRollback();
throw new HeuristicRollbackException();
}
} // end-if (this.transactionalExtra != null)

}

private void participantOnePhaseCommit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
SecurityException, IllegalStateException, CommitRequiredException, SystemException {

if (this.participant == null && this.participantList.isEmpty() == false) {
this.participantRollback();
throw new HeuristicRollbackException();
} else if (this.participantList.size() > 1) {
this.participantRollback();
throw new HeuristicRollbackException();
} else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) {
this.checkForTransactionExtraIfNecessary();

if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) {
this.participantRollback();
throw new HeuristicRollbackException();
} else if (this.transactionStatus == Status.STATUS_ROLLING_BACK) {
Expand Down Expand Up @@ -722,8 +733,11 @@ public boolean enlistResource(XAResourceDescriptor descriptor)
this.nativeParticipantList.add(archive);
} else if (RemoteResourceDescriptor.class.isInstance(descriptor)) {
this.remoteParticipantList.add(archive);
} else if (this.participant == null) {
// this.participant = this.participant == null ? archive : this.participant;
this.participant = archive;
} else {
this.participant = this.participant == null ? archive : this.participant;
throw new SystemException("There already has a local-resource exists!");
}

this.participantList.add(archive);
Expand Down

0 comments on commit d065b1d

Please sign in to comment.