@@ -41,16 +41,23 @@ public static class HAServiceLockWatcher implements AccumuloLockWatcher {
41
41
private static final Logger LOG = LoggerFactory .getLogger (HAServiceLockWatcher .class );
42
42
43
43
private final String serviceName ;
44
+ private final Supplier <Boolean > shutdownComplete ;
44
45
private volatile boolean acquiredLock = false ;
45
46
private volatile boolean failedToAcquireLock = false ;
46
47
47
- public HAServiceLockWatcher (String serviceName ) {
48
+ public HAServiceLockWatcher (String serviceName , Supplier < Boolean > shutdownComplete ) {
48
49
this .serviceName = serviceName ;
50
+ this .shutdownComplete = shutdownComplete ;
49
51
}
50
52
51
53
@ Override
52
54
public void lostLock (LockLossReason reason ) {
53
- Halt .halt (serviceName + " lock in zookeeper lost (reason = " + reason + "), exiting!" , -1 );
55
+ if (shutdownComplete .get ()) {
56
+ LOG .warn ("{} lost lock (reason = {}), not halting because shutdown is complete." ,
57
+ serviceName , reason );
58
+ } else {
59
+ Halt .halt (serviceName + " lock in zookeeper lost (reason = " + reason + "), exiting!" , -1 );
60
+ }
54
61
}
55
62
56
63
@ Override
@@ -122,24 +129,27 @@ public static class ServiceLockWatcher implements LockWatcher {
122
129
private static final Logger LOG = LoggerFactory .getLogger (ServiceLockWatcher .class );
123
130
124
131
private final String serviceName ;
125
- private final Supplier <Boolean > shuttingDown ;
132
+ private final Supplier <Boolean > shutdownComplete ;
126
133
private final Consumer <String > lostLockAction ;
127
134
128
- public ServiceLockWatcher (String serviceName , Supplier <Boolean > shuttingDown ,
135
+ public ServiceLockWatcher (String serviceName , Supplier <Boolean > shutdownComplete ,
129
136
Consumer <String > lostLockAction ) {
130
137
this .serviceName = serviceName ;
131
- this .shuttingDown = shuttingDown ;
138
+ this .shutdownComplete = shutdownComplete ;
132
139
this .lostLockAction = lostLockAction ;
133
140
}
134
141
135
142
@ Override
136
143
public void lostLock (final LockLossReason reason ) {
137
- Halt .halt (1 , () -> {
138
- if (!shuttingDown .get ()) {
144
+ if (shutdownComplete .get ()) {
145
+ LOG .warn ("{} lost lock (reason = {}), not halting because shutdown is complete." ,
146
+ serviceName , reason );
147
+ } else {
148
+ Halt .halt (1 , () -> {
139
149
LOG .error ("{} lost lock (reason = {}), exiting." , serviceName , reason );
140
- }
141
- lostLockAction . accept ( serviceName );
142
- });
150
+ lostLockAction . accept ( serviceName );
151
+ } );
152
+ }
143
153
}
144
154
145
155
@ Override
0 commit comments