-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moved getLock() to AbstractServer, added ServiceLock verification thread #5145
Conversation
Moved getLock() from TabletHostingServer to AbstractServer. Added method to ServiceLock to verfify the lock is being held in ZooKeeper versus relying on the Watcher. Added method to start verification thread in AbstractServer, which is called from the Manager and TabletServer. Closes apache#5132
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java
Outdated
Show resolved
Hide resolved
test/src/main/java/org/apache/accumulo/test/functional/HalfDeadServerWatcherIT.java
Outdated
Show resolved
Hide resolved
test/src/main/java/org/apache/accumulo/test/functional/HalfDeadServerWatcherIT.java
Show resolved
Hide resolved
test/src/main/java/org/apache/accumulo/test/functional/HalfDeadServerWatcherIT.java
Outdated
Show resolved
Hide resolved
server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java
Outdated
Show resolved
Hide resolved
server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java
Show resolved
Hide resolved
server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall seems like a good approach
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java
Outdated
Show resolved
Hide resolved
private volatile Thread serverThread; | ||
private volatile Thread verificationThread; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these need to be volatile? I'm not sure what that's getting us here. Should these be final and the Thread created in the constructor, and only run in the runServer method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming so, but honestly not 100% sure. serverThread.isAlive
is being called from the verificationThread
and verificationThread
is checked for a null reference in the main thread when stopping.
* | ||
* @return lock ServiceLock or null | ||
*/ | ||
public abstract ServiceLock getLock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could avoid making this abstract and needing to implement it in the child classes if each child class called the super constructor and provided a Supplier<ServiceLock>
, then this impl would just be:
public abstract ServiceLock getLock(); | |
public ServiceLock getLock() { | |
serviceLockSupplier.get(); | |
} |
That might also avoid issues with handling null here, because the supplier would likely be blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But wouldn't that require an AtomicReference or something so that the Supplier can just call AtomicReference.get() and the server call AtomicReference.set(). I'm not sure that's any cleaner.
server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java
Outdated
Show resolved
Hide resolved
…viceLock.java Co-authored-by: Keith Turner <kturner@apache.org>
…accumulo into 5132-service-lock-verification
server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java
Outdated
Show resolved
Hide resolved
test/src/main/java/org/apache/accumulo/test/functional/HalfDeadServerWatcherIT.java
Outdated
Show resolved
Hide resolved
Merged up to main. Changed property default value to 2m in 3.1 branch. |
Moved getLock() from TabletHostingServer to AbstractServer. Added method
to ServiceLock to verify the lock is being held in ZooKeeper versus
relying on the Watcher. Added method to start verification thread in
AbstractServer, which is called from the Manager and TabletServer.
Closes #5132