test_class.declarator: logger = LoggerFactory
        .getLogger(LeaderElectionSupportTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory
        .getLogger(LeaderElectionSupportTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.declarator: testRootNode = "/" + System.currentTimeMillis()
        + "_"
test_class.modifier: private static final
test_class.original_string: private static final String testRootNode = "/" + System.currentTimeMillis()
        + "_";
test_class.type: String
test_class.var_name: testRootNode
test_class.declarator: zooKeeper
test_class.modifier: private
test_class.original_string: private ZooKeeper zooKeeper;
test_class.type: ZooKeeper
test_class.var_name: zooKeeper
test_class.file: bigdata-intro/zk-intro/src/test/java/org/apache/zookeeper/recipes/leader/LeaderElectionSupportTest.java
test_class.identifier: LeaderElectionSupportTest
test_class.superclass: extends ClientBase
test_case.body: @Test
    public void testGetLeaderHostName() throws KeeperException,
        InterruptedException {
  
      LeaderElectionSupport electionSupport = createLeaderElectionSupport();
  
      electionSupport.start();
  
      // Sketchy: We assume there will be a leader (probably us) in 3 seconds.
      Thread.sleep(3000);
  
      String leaderHostName = electionSupport.getLeaderHostName();
  
      Assert.assertNotNull(leaderHostName);
      Assert.assertEquals("foohost", leaderHostName);
  
      electionSupport.stop();
    }
test_case.class_method_signature: LeaderElectionSupportTest.testGetLeaderHostName()
test_case.full_signature: @Test public void testGetLeaderHostName()
test_case.identifier: testGetLeaderHostName
test_case.invocations: createLeaderElectionSupport start sleep getLeaderHostName assertNotNull assertEquals stop
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetLeaderHostName()
focal_class.declarator: logger = LoggerFactory
        .getLogger(LeaderElectionSupport.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory
        .getLogger(LeaderElectionSupport.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: zooKeeper
focal_class.modifier: private
focal_class.original_string: private ZooKeeper zooKeeper;
focal_class.type: ZooKeeper
focal_class.var_name: zooKeeper
focal_class.declarator: state
focal_class.modifier: private
focal_class.original_string: private State state;
focal_class.type: State
focal_class.var_name: state
focal_class.declarator: listeners
focal_class.modifier: private
focal_class.original_string: private Set<LeaderElectionAware> listeners;
focal_class.type: Set<LeaderElectionAware>
focal_class.var_name: listeners
focal_class.declarator: rootNodeName
focal_class.modifier: private
focal_class.original_string: private String rootNodeName;
focal_class.type: String
focal_class.var_name: rootNodeName
focal_class.declarator: leaderOffer
focal_class.modifier: private
focal_class.original_string: private LeaderOffer leaderOffer;
focal_class.type: LeaderOffer
focal_class.var_name: leaderOffer
focal_class.declarator: hostName
focal_class.modifier: private
focal_class.original_string: private String hostName;
focal_class.type: String
focal_class.var_name: hostName
focal_class.file: bigdata-intro/zk-intro/src/main/java/org/apache/zookeeper/recipes/leader/LeaderElectionSupport.java
focal_class.identifier: LeaderElectionSupport
focal_class.interfaces: implements Watcher
focal_class.class_method_signature: LeaderElectionSupport.LeaderElectionSupport()
focal_class.full_signature: public  LeaderElectionSupport()
focal_class.identifier: LeaderElectionSupport
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  LeaderElectionSupport()
focal_class.class_method_signature: LeaderElectionSupport.start()
focal_class.full_signature: public synchronized void start()
focal_class.identifier: start
focal_class.modifiers: public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void start()
focal_class.class_method_signature: LeaderElectionSupport.stop()
focal_class.full_signature: public synchronized void stop()
focal_class.identifier: stop
focal_class.modifiers: public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void stop()
focal_class.class_method_signature: LeaderElectionSupport.makeOffer()
focal_class.full_signature: private void makeOffer()
focal_class.identifier: makeOffer
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void makeOffer()
focal_class.class_method_signature: LeaderElectionSupport.determineElectionStatus()
focal_class.full_signature: private void determineElectionStatus()
focal_class.identifier: determineElectionStatus
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void determineElectionStatus()
focal_class.class_method_signature: LeaderElectionSupport.becomeReady(LeaderOffer neighborLeaderOffer)
focal_class.full_signature: private void becomeReady(LeaderOffer neighborLeaderOffer)
focal_class.identifier: becomeReady
focal_class.modifiers: private
focal_class.parameters: (LeaderOffer neighborLeaderOffer)
focal_class.return: void
focal_class.signature: void becomeReady(LeaderOffer neighborLeaderOffer)
focal_class.class_method_signature: LeaderElectionSupport.becomeLeader()
focal_class.full_signature: private void becomeLeader()
focal_class.identifier: becomeLeader
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void becomeLeader()
focal_class.class_method_signature: LeaderElectionSupport.becomeFailed(Exception e)
focal_class.full_signature: private void becomeFailed(Exception e)
focal_class.identifier: becomeFailed
focal_class.modifiers: private
focal_class.parameters: (Exception e)
focal_class.return: void
focal_class.signature: void becomeFailed(Exception e)
focal_class.class_method_signature: LeaderElectionSupport.getLeaderHostName()
focal_class.full_signature: public String getLeaderHostName()
focal_class.identifier: getLeaderHostName
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getLeaderHostName()
focal_class.class_method_signature: LeaderElectionSupport.toLeaderOffers(List<String> strings)
focal_class.full_signature: private List<LeaderOffer> toLeaderOffers(List<String> strings)
focal_class.identifier: toLeaderOffers
focal_class.modifiers: private
focal_class.parameters: (List<String> strings)
focal_class.return: List<LeaderOffer>
focal_class.signature: List<LeaderOffer> toLeaderOffers(List<String> strings)
focal_class.class_method_signature: LeaderElectionSupport.process(WatchedEvent event)
focal_class.full_signature: @Override public void process(WatchedEvent event)
focal_class.identifier: process
focal_class.modifiers: @Override public
focal_class.parameters: (WatchedEvent event)
focal_class.return: void
focal_class.signature: void process(WatchedEvent event)
focal_class.class_method_signature: LeaderElectionSupport.dispatchEvent(EventType eventType)
focal_class.full_signature: private void dispatchEvent(EventType eventType)
focal_class.identifier: dispatchEvent
focal_class.modifiers: private
focal_class.parameters: (EventType eventType)
focal_class.return: void
focal_class.signature: void dispatchEvent(EventType eventType)
focal_class.class_method_signature: LeaderElectionSupport.addListener(LeaderElectionAware listener)
focal_class.full_signature: public void addListener(LeaderElectionAware listener)
focal_class.identifier: addListener
focal_class.modifiers: public
focal_class.parameters: (LeaderElectionAware listener)
focal_class.return: void
focal_class.signature: void addListener(LeaderElectionAware listener)
focal_class.class_method_signature: LeaderElectionSupport.removeListener(LeaderElectionAware listener)
focal_class.full_signature: public void removeListener(LeaderElectionAware listener)
focal_class.identifier: removeListener
focal_class.modifiers: public
focal_class.parameters: (LeaderElectionAware listener)
focal_class.return: void
focal_class.signature: void removeListener(LeaderElectionAware listener)
focal_class.class_method_signature: LeaderElectionSupport.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.class_method_signature: LeaderElectionSupport.getRootNodeName()
focal_class.full_signature: public String getRootNodeName()
focal_class.identifier: getRootNodeName
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getRootNodeName()
focal_class.class_method_signature: LeaderElectionSupport.setRootNodeName(String rootNodeName)
focal_class.full_signature: public void setRootNodeName(String rootNodeName)
focal_class.identifier: setRootNodeName
focal_class.modifiers: public
focal_class.parameters: (String rootNodeName)
focal_class.return: void
focal_class.signature: void setRootNodeName(String rootNodeName)
focal_class.class_method_signature: LeaderElectionSupport.getZooKeeper()
focal_class.full_signature: public ZooKeeper getZooKeeper()
focal_class.identifier: getZooKeeper
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: ZooKeeper
focal_class.signature: ZooKeeper getZooKeeper()
focal_class.class_method_signature: LeaderElectionSupport.setZooKeeper(ZooKeeper zooKeeper)
focal_class.full_signature: public void setZooKeeper(ZooKeeper zooKeeper)
focal_class.identifier: setZooKeeper
focal_class.modifiers: public
focal_class.parameters: (ZooKeeper zooKeeper)
focal_class.return: void
focal_class.signature: void setZooKeeper(ZooKeeper zooKeeper)
focal_class.class_method_signature: LeaderElectionSupport.getHostName()
focal_class.full_signature: public String getHostName()
focal_class.identifier: getHostName
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getHostName()
focal_class.class_method_signature: LeaderElectionSupport.setHostName(String hostName)
focal_class.full_signature: public void setHostName(String hostName)
focal_class.identifier: setHostName
focal_class.modifiers: public
focal_class.parameters: (String hostName)
focal_class.return: void
focal_class.signature: void setHostName(String hostName)
focal_method.body: public String getLeaderHostName() throws KeeperException,
        InterruptedException {
  
      List<LeaderOffer> leaderOffers = toLeaderOffers(zooKeeper.getChildren(
          rootNodeName, false));
  
      if (leaderOffers.size() > 0) {
        return leaderOffers.get(0).getHostName();
      }
  
      return null;
    }
focal_method.class_method_signature: LeaderElectionSupport.getLeaderHostName()
focal_method.full_signature: public String getLeaderHostName()
focal_method.identifier: getLeaderHostName
focal_method.invocations: toLeaderOffers getChildren size getHostName get
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: String
focal_method.signature: String getLeaderHostName()