Skip to content

Commit

Permalink
* 修复suspend/resume时delisted状态不准确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyangming committed Mar 7, 2017
1 parent 5ea46e1 commit 770526c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1055,14 +1055,17 @@ public boolean delistResource(XAResourceDescriptor descriptor, int flag) throws
private boolean delistResource(XAResourceArchive archive, int flag) throws SystemException, RollbackRequiredException {
try {
Xid branchXid = archive.getXid();
archive.end(branchXid, flag);

switch (flag) {
case XAResource.TMSUCCESS:
case XAResource.TMFAIL:
archive.end(branchXid, flag);
archive.setDelisted(true);
break;
case XAResource.TMSUSPEND:
archive.end(branchXid, flag);
archive.setDelisted(true);
archive.setSuspended(true);
break;
default:
throw new SystemException();
Expand Down Expand Up @@ -1156,6 +1159,8 @@ private boolean enlistResource(XAResourceArchive archive, int flag) throws Syste
break;
case XAResource.TMRESUME:
archive.start(branchXid, flag);
archive.setDelisted(false);
archive.setSuspended(false);
break;
default:
throw new SystemException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class XAResourceArchive implements XAResource {
static final Logger logger = LoggerFactory.getLogger(XAResourceArchive.class);
public static final int DEFAULT_VOTE = -1;

private boolean suspended;
private boolean delisted;
private boolean completed;
private boolean readonly;
Expand Down Expand Up @@ -157,6 +158,14 @@ public void setDescriptor(XAResourceDescriptor descriptor) {
this.descriptor = descriptor;
}

public boolean isSuspended() {
return suspended;
}

public void setSuspended(boolean suspended) {
this.suspended = suspended;
}

public boolean isDelisted() {
return delisted;
}
Expand Down

0 comments on commit 770526c

Please sign in to comment.