public long getSessionId() throws KeeperException, InterruptedException { return getSessionId(getLockDataZooCache, path); }
@Override public boolean isLockHeld(String tserver, String session) { return ZooLock.getSessionId(zc, root + "/" + tserver) == Long.parseLong(session, 16); }
/** * Look up the TabletServers in ZooKeeper and try to find a sessionID for this server reference * * @param hostAndPort * The host and port for a TabletServer * @return The host and port with the session ID in square-brackets appended, or the original * value. */ 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) + "]"; }
private static TServerInstance getTServerInstance(String address, ZooLock zooLock) { while (true) { try { return new TServerInstance(address, zooLock.getSessionId()); } catch (KeeperException | InterruptedException e) { log.error("{}", e.getMessage(), e); } sleepUninterruptibly(1, TimeUnit.SECONDS); } }
public TServerInstance getTabletSession() { String address = getClientAddressString(); if (address == null) return null; try { return new TServerInstance(address, tabletServerLock.getSessionId()); } catch (Exception ex) { log.warn("Unable to read session from tablet server lock" + ex); return null; } }
TServerInstance instance = new TServerInstance(clientAddress, getLock().getSessionId()); TabletLocationState tls = null; try {
public long getSessionId() throws KeeperException, InterruptedException { return getSessionId(getLockDataZooCache, path); }
@Override public boolean isLockHeld(String tserver, String session) { try { return ZooLock.getSessionId(zc, root + "/" + tserver) == Long.parseLong(session, 16); } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** * Look up the TabletServers in ZooKeeper and try to find a sessionID for this server reference * * @param hostAndPort * The host and port for a TabletServer * @return The host and port with the session ID in square-brackets appended, or the original * value. */ static String qualifyWithZooKeeperSessionId(String zTServerRoot, ZooCache zooCache, String hostAndPort) { try { long sessionId = ZooLock.getSessionId(zooCache, zTServerRoot + "/" + hostAndPort); if (0 == sessionId) { return hostAndPort; } return hostAndPort + "[" + Long.toHexString(sessionId) + "]"; } catch (InterruptedException | KeeperException e) { log.warn("Failed to communicate with ZooKeeper to find session ID for TabletServer."); return hostAndPort; } }