Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from caskdata/feature/tephra-47_service-abort
Browse files Browse the repository at this point in the history
TEPHRA-47 Pass along cause of TransactionManager abort
  • Loading branch information
ghelmling committed Dec 4, 2014
2 parents 2d457d6 + 73de7a3 commit 1d8021f
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void leader() {
@Override
public void failed(State from, Throwable failure) {
LOG.error("Transaction manager aborted, stopping transaction service");
stopAndWait();
TransactionService.this.abort(failure);
}
}, MoreExecutors.sameThreadExecutor());

Expand Down Expand Up @@ -109,6 +109,17 @@ public void follower() {

@Override
protected void doStop() {
internalStop();
notifyStopped();
}

protected void abort(Throwable cause) {
// try to clear leader status and shutdown RPC
internalStop();
notifyFailed(cause);
}

protected void internalStop() {
if (leaderElection != null) {
// NOTE: if was a leader this will cause loosing of leadership which in callback above will
// de-register service in discovery service and stop the service if needed
Expand All @@ -120,7 +131,5 @@ protected void doStop() {
LOG.error("Exception when cancelling leader election.", e);
}
}

notifyStopped();
}
}

0 comments on commit 1d8021f

Please sign in to comment.