zhangmeng916 commented on a change in pull request #1409:
URL: https://github.com/apache/helix/pull/1409#discussion_r497074334
##########
File path:
helix-lock/src/main/java/org/apache/helix/lock/helix/ZKDistributedNonblockingLock.java
##########
@@ -143,11 +147,65 @@ public ZNRecord update(ZNRecord current) {
if (!(System.currentTimeMillis() < curLockInfo.getTimeout()) ||
isCurrentOwner()) {
return _record;
}
- // For users who are not the lock owner and try to do an update on a
lock that is held by someone else, exception thrown is to be caught by data
accessor, and return false for the update
+ // For users who are not the lock owner and try to do an update on a
lock that is held by
+ // someone else, exception thrown is to be caught by data accessor, and
return false for
+ // the update
LOG.error(
"User " + _userId + " tried to update the lock at " + new
Date(System.currentTimeMillis())
+ ". Lock path: " + _lockPath);
throw new HelixException("User is not authorized to perform this
operation.");
}
}
+
+ /**
+ * Builder class to use with ZKDistributedNonblockingLock.
+ */
+ public static class Builder extends GenericZkHelixApiBuilder<Builder> {
+ private LockScope _lockScope;
+ private String _userId;
+ private long _timeout;
+ private String _lockMsg;
+
+ public Builder() {
+ }
+
+ public Builder setLockScope(LockScope lockScope) {
+ _lockScope = lockScope;
+ return this;
+ }
+
+ public Builder setUserId(String userId) {
+ _userId = userId;
+ return this;
+ }
+
+ public Builder setTimeout(long timeout) {
+ _timeout = timeout;
+ return this;
+ }
+
+ public Builder setLockMsg(String lockMsg) {
+ _lockMsg = lockMsg;
+ return this;
+ }
+
+ public ZKDistributedNonblockingLock build() {
+ // Resolve which way we want to create BaseDataAccessor instance
Review comment:
This line can be put together with the following comments.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]