You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "dlmarion (via GitHub)" <gi...@apache.org> on 2023/10/04 20:23:10 UTC
[PR] Modified ExternalCompactionUtil.findCompactionCoordinator to use ZooCache [accumulo]
dlmarion opened a new pull request, #3813:
URL: https://github.com/apache/accumulo/pull/3813
Closes #3783
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modified ExternalCompactionUtil.findCompactionCoordinator to use ZooCache [accumulo]
Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #3813:
URL: https://github.com/apache/accumulo/pull/3813#discussion_r1346876481
##########
core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java:
##########
@@ -98,17 +98,12 @@ public static String getHostPortString(HostAndPort address) {
*/
public static Optional<HostAndPort> findCompactionCoordinator(ClientContext context) {
final String lockPath = context.getZooKeeperRoot() + Constants.ZCOORDINATOR_LOCK;
- try {
- var zk = ZooSession.getAnonymousSession(context.getZooKeepers(),
- context.getZooKeepersSessionTimeOut());
- byte[] address = ServiceLock.getLockData(zk, ServiceLock.path(lockPath));
- if (null == address) {
- return Optional.empty();
- }
- return Optional.of(HostAndPort.fromString(new String(address)));
- } catch (KeeperException | InterruptedException e) {
- throw new RuntimeException(e);
+ byte[] address =
+ ServiceLock.getLockData(context.getZooCache(), ServiceLock.path(lockPath), new ZcStat());
+ if (null == address) {
+ return Optional.empty();
}
+ return Optional.of(HostAndPort.fromString(new String(address)));
Review Comment:
There's a couple of different variants of this that are slightly more concise, some could inline the lockPath as well. I couldn't get it more concise than 3 lines. But, there is a variant of this that would inline the lockPath and still be only 3 lines total. I'm not sure if you want to go with any of them.
But, at a minimum, the String should be interpreting the address as UTF-8, because that's how it should have been persisted.
```suggestion
Optional<byte[]> address = Optional.ofNullable(
ServiceLock.getLockData(context.getZooCache(), ServiceLock.path(lockPath), new ZcStat()));
return address.map(bytes -> new String(bytes, UTF_8)).map(HostAndPort::fromString);
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modified ExternalCompactionUtil.findCompactionCoordinator to use ZooCache [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on PR #3813:
URL: https://github.com/apache/accumulo/pull/3813#issuecomment-1747587629
Full IT build kicked off
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modified ExternalCompactionUtil.findCompactionCoordinator to use ZooCache [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion merged PR #3813:
URL: https://github.com/apache/accumulo/pull/3813
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modified ExternalCompactionUtil.findCompactionCoordinator to use ZooCache [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #3813:
URL: https://github.com/apache/accumulo/pull/3813#discussion_r1347298150
##########
core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java:
##########
@@ -98,17 +98,12 @@ public static String getHostPortString(HostAndPort address) {
*/
public static Optional<HostAndPort> findCompactionCoordinator(ClientContext context) {
final String lockPath = context.getZooKeeperRoot() + Constants.ZCOORDINATOR_LOCK;
- try {
- var zk = ZooSession.getAnonymousSession(context.getZooKeepers(),
- context.getZooKeepersSessionTimeOut());
- byte[] address = ServiceLock.getLockData(zk, ServiceLock.path(lockPath));
- if (null == address) {
- return Optional.empty();
- }
- return Optional.of(HostAndPort.fromString(new String(address)));
- } catch (KeeperException | InterruptedException e) {
- throw new RuntimeException(e);
+ byte[] address =
+ ServiceLock.getLockData(context.getZooCache(), ServiceLock.path(lockPath), new ZcStat());
+ if (null == address) {
+ return Optional.empty();
}
+ return Optional.of(HostAndPort.fromString(new String(address)));
Review Comment:
I think I'm just going to add the `UTF_8` argument to the String constructor. By modifying this to call `Optional.map` twice we are incurring 2 calls to `Objects.requireNonNull`, `Optional.isPresent`, and `Optional.empty` vs one null-check and one call to `Optional.empty`. Your suggestion may reduce the lines of code, but it's not as efficient in achieving the same result.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org