keith-turner commented on code in PR #5732:
URL: https://github.com/apache/accumulo/pull/5732#discussion_r2198517434
##########
server/base/src/main/java/org/apache/accumulo/server/manager/LiveTServerSet.java:
##########
@@ -211,10 +213,23 @@ static class TServerInfo {
// The set of entries in zookeeper without locks, and the first time each
was noticed
private final Map<ServiceLockPath,Long> locklessServers = new HashMap<>();
- public LiveTServerSet(ServerContext context, Listener cback) {
- this.cback = cback;
+ public LiveTServerSet(ServerContext context) {
+ this.cback = new AtomicReference<>(null);
this.context = context;
- this.context.getZooCache().addZooCacheWatcher(this);
+ }
+
+ public void setCback(Listener cback) {
Review Comment:
Instead of adding this new method, wonder if we could change the existing
method `startListeningForTabletServerChanges(Listener cback)` to accept a
listener. That existing method is used in a very similar way to this new
method, it is called once after the object is constructed to start doing stuff.
##########
server/manager/src/main/java/org/apache/accumulo/manager/ManagerTime.java:
##########
@@ -85,20 +85,38 @@ public class ManagerTime {
* start.</li>
* </ul>
*/
- private final AtomicReference<Duration> skewAmount;
+ private AtomicReference<Duration> skewAmount;
- public ManagerTime(Manager manager, AccumuloConfiguration conf) throws
IOException {
- this.zk = manager.getContext().getZooSession().asReaderWriter();
- this.manager = manager;
+ ManagerTime() {
+ this.manager = new AtomicReference<>(null);
+ }
+
+ // Once it's set call constructor
+ public void setManager(Manager manager) throws IOException {
Review Comment:
Its important this class is non functional before this method is called.
Would be good to add a unit test like the following for this class. This will
ensure that code that uses this before setManager is called does not get an
incorrect time.
```java
var mt = new ManagerTime();
assertThrows(???, ()->mt.getTime());
```
Seems like the current code may throw an NPE which is good.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]