private void connectChronosServer ( ) throws IOException { LOG . info ( "Try to connect chronos server" ) ; byte [ ] hostPortBytes = getData ( this , masterZnode ) ; if ( hostPortBytes != null ) { String hostPort = new String ( hostPortBytes ) ; // e.g. 127.0.0.0_2181 LOG . info ( "Find the active chronos server in " + hostPort ) ; try { transport = new TSocket ( hostPort . split ( "_" ) [ 0 ] , Integer . parseInt ( hostPort . split ( "_" ) [ 1 ] ) ) ; transport . open ( ) ; protocol = new TBinaryProtocol ( transport ) ; client = new ChronosService . Client ( protocol ) ; } catch ( TException e ) { new IOException ( "Exception to connect chronos server in " + hostPort ) ; } } else { throw new IOException ( "The data of " + masterZnode + " is null" ) ; } }
Access ZooKeeper to get current master ChronosServer and connect with it .