From 73de7a37c1a87a678cd69b551469c3a11b9ffd25 Mon Sep 17 00:00:00 2001 From: Gary Helmling Date: Wed, 3 Dec 2014 18:19:37 -0800 Subject: [PATCH] TEPHRA-47 Pass along cause of TransactionManager abort --- .../tephra/distributed/TransactionService.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tephra-core/src/main/java/co/cask/tephra/distributed/TransactionService.java b/tephra-core/src/main/java/co/cask/tephra/distributed/TransactionService.java index fa4f35d9..92a6e365 100644 --- a/tephra-core/src/main/java/co/cask/tephra/distributed/TransactionService.java +++ b/tephra-core/src/main/java/co/cask/tephra/distributed/TransactionService.java @@ -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()); @@ -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 @@ -120,7 +131,5 @@ protected void doStop() { LOG.error("Exception when cancelling leader election.", e); } } - - notifyStopped(); } }