private synchronized void connect() throws IOException, KeeperException, InterruptedException, TTransportException { getLeader(); while (true) { log.debug("Connecting to oracle at " + currentLeader.getId()); String[] hostAndPort = currentLeader.getId().split(":"); String host = hostAndPort[0]; int port = Integer.parseInt(hostAndPort[1]); try { transport = new TFastFramedTransport(new TSocket(host, port)); transport.open(); TProtocol protocol = new TCompactProtocol(transport); client = new OracleService.Client(protocol); log.info("Connected to oracle at " + getOracle()); break; } catch (TTransportException e) { sleepRandom(); getLeader(); } catch (Exception e) { throw new RuntimeException(e); } } }