@Test public void testQualifySessionId() { ZooCache zc = EasyMock.createMock(ZooCache.class); String root = "/accumulo/id/tservers"; String server = "localhost:12345"; final long session = 123456789L; String serverPath = root + "/" + server; EasyMock.expect(zc.getChildren(serverPath)).andReturn(Collections.singletonList("child")); EasyMock.expect(zc.get(EasyMock.eq(serverPath + "/child"), EasyMock.anyObject(ZcStat.class))) .andAnswer(() -> { ZcStat stat = (ZcStat) EasyMock.getCurrentArguments()[1]; stat.setEphemeralOwner(session); return new byte[0]; }); EasyMock.replay(zc); assertEquals(server + "[" + Long.toHexString(session) + "]", Admin.qualifyWithZooKeeperSessionId(root, zc, server)); EasyMock.verify(zc); }
static String qualifyWithZooKeeperSessionId(String zTServerRoot, ZooCache zooCache, String hostAndPort) { long sessionId = ZooLock.getSessionId(zooCache, zTServerRoot + "/" + hostAndPort); if (sessionId == 0) { return hostAndPort; } return hostAndPort + "[" + Long.toHexString(sessionId) + "]"; }
Admin implements KeywordExecutable { static String qualifyWithZooKeeperSessionId(String zTServerRoot, ZooCache zooCache, String hostAndPort) { long sessionId = ZooLock.getSessionId(zooCache, zTServerRoot + "/" + hostAndPort); if (sessionId == 0) { return hostAndPort; } return hostAndPort + "[" + Long.toHexString(sessionId) + "]"; } }
Admin implements KeywordExecutable { static String qualifyWithZooKeeperSessionId(String zTServerRoot, ZooCache zooCache, String hostAndPort) { long sessionId = ZooLock.getSessionId(zooCache, zTServerRoot + "/" + hostAndPort); if (sessionId == 0) { return hostAndPort; } return hostAndPort + "[" + Long.toHexString(sessionId) + "]"; }  }
Admin implements KeywordExecutable { static String qualifyWithZooKeeperSessionId(String zTServerRoot, ZooCache zooCache, String hostAndPort) { long sessionId = ZooLock.getSessionId(zooCache, zTServerRoot + "/" + hostAndPort); if (sessionId == 0) { return hostAndPort; } return hostAndPort + "[" + Long.toHexString(sessionId) + "]"; }  static void main(String[] args); @Override String keyword(); @Override UsageGroup usageGroup(); @Override String description(); @SuppressFBWarnings(value = "DM_EXIT", justification = "System.exit okay for CLI tool") @Override void execute(final String[] args); @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who provided input") void printConfig(ClientContext context, DumpConfigCommand opts); }
Admin implements KeywordExecutable { static String qualifyWithZooKeeperSessionId(String zTServerRoot, ZooCache zooCache, String hostAndPort) { long sessionId = ZooLock.getSessionId(zooCache, zTServerRoot + "/" + hostAndPort); if (sessionId == 0) { return hostAndPort; } return hostAndPort + "[" + Long.toHexString(sessionId) + "]"; }  static void main(String[] args); @Override String keyword(); @Override UsageGroup usageGroup(); @Override String description(); @SuppressFBWarnings(value = "DM_EXIT", justification = "System.exit okay for CLI tool") @Override void execute(final String[] args); @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who provided input") void printConfig(ClientContext context, DumpConfigCommand opts);  }