keith-turner commented on code in PR #5732:
URL: https://github.com/apache/accumulo/pull/5732#discussion_r2201759182
##########
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:
The `find()` method in `LiveTserverSet` can be made static. Then the
mocking can be removed from the test and that will look like
```java
@Test
public void testSessionIds() {
Map<String,TServerInfo> servers = new HashMap<>();
TServerConnection mockConn =
EasyMock.createMock(TServerConnection.class);
TServerInfo server1 =
new TServerInfo(new
TServerInstance(HostAndPort.fromParts("localhost", 1234), "5555"),
mockConn, Constants.DEFAULT_RESOURCE_GROUP_NAME);
servers.put("server1", server1);
assertEquals(server1.instance, LiveTServerSet.find(servers,
"localhost:1234"));
assertNull(LiveTServerSet.find(servers, "localhost:4321"));
assertEquals(server1.instance, LiveTServerSet.find(servers,
"localhost:1234[5555]"));
assertNull(LiveTServerSet.find(servers, "localhost:1234[55755]"));
}
```
--
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]