test_class.file: bigdata-intro/zk-intro/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
test_class.identifier: DistributedQueueTest
test_class.superclass: extends ClientBase
test_case.body: @Test
      public void testRemove1() throws Exception{
          String dir = "/testRemove1";
          String testString = "Hello World";
          final int num_clients = 1;
          ZooKeeper clients[] = new ZooKeeper[num_clients];
          DistributedQueue queueHandles[] = new DistributedQueue[num_clients];
          for(int i=0; i < clients.length; i++){
              clients[i] = createClient();
              queueHandles[i] = new DistributedQueue(clients[i], dir, null);
          }
  
          try{
              queueHandles[0].remove();
          }catch(NoSuchElementException e){
              return;
          }
          Assert.assertTrue(false);
      }
test_case.class_method_signature: DistributedQueueTest.testRemove1()
test_case.full_signature: @Test public void testRemove1()
test_case.identifier: testRemove1
test_case.invocations: createClient remove assertTrue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRemove1()
focal_class.declarator: LOG = LoggerFactory.getLogger(DistributedQueue.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(DistributedQueue.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: dir
focal_class.modifier: private final
focal_class.original_string: private final String dir;
focal_class.type: String
focal_class.var_name: dir
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: acl = ZooDefs.Ids.OPEN_ACL_UNSAFE
focal_class.modifier: private
focal_class.original_string: private List<ACL> acl = ZooDefs.Ids.OPEN_ACL_UNSAFE;
focal_class.type: List<ACL>
focal_class.var_name: acl
focal_class.declarator: prefix = "qn-"
focal_class.modifier: private final
focal_class.original_string: private final String prefix = "qn-";
focal_class.type: String
focal_class.var_name: prefix
focal_class.file: bigdata-intro/zk-intro/src/main/java/org/apache/zookeeper/recipes/queue/DistributedQueue.java
focal_class.identifier: DistributedQueue
focal_class.class_method_signature: DistributedQueue.DistributedQueue(ZooKeeper zookeeper, String dir, List<ACL> acl)
focal_class.full_signature: public  DistributedQueue(ZooKeeper zookeeper, String dir, List<ACL> acl)
focal_class.identifier: DistributedQueue
focal_class.modifiers: public
focal_class.parameters: (ZooKeeper zookeeper, String dir, List<ACL> acl)
focal_class.signature:  DistributedQueue(ZooKeeper zookeeper, String dir, List<ACL> acl)
focal_class.class_method_signature: DistributedQueue.orderedChildren(Watcher watcher)
focal_class.full_signature: private TreeMap<Long,String> orderedChildren(Watcher watcher)
focal_class.identifier: orderedChildren
focal_class.modifiers: private
focal_class.parameters: (Watcher watcher)
focal_class.return: TreeMap<Long,String>
focal_class.signature: TreeMap<Long,String> orderedChildren(Watcher watcher)
focal_class.class_method_signature: DistributedQueue.smallestChildName()
focal_class.full_signature: private String smallestChildName()
focal_class.identifier: smallestChildName
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String smallestChildName()
focal_class.class_method_signature: DistributedQueue.element()
focal_class.full_signature: public byte[] element()
focal_class.identifier: element
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: byte[]
focal_class.signature: byte[] element()
focal_class.class_method_signature: DistributedQueue.remove()
focal_class.full_signature: public byte[] remove()
focal_class.identifier: remove
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: byte[]
focal_class.signature: byte[] remove()
focal_class.class_method_signature: DistributedQueue.take()
focal_class.full_signature: public byte[] take()
focal_class.identifier: take
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: byte[]
focal_class.signature: byte[] take()
focal_class.class_method_signature: DistributedQueue.offer(byte[] data)
focal_class.full_signature: public boolean offer(byte[] data)
focal_class.identifier: offer
focal_class.modifiers: public
focal_class.parameters: (byte[] data)
focal_class.return: boolean
focal_class.signature: boolean offer(byte[] data)
focal_class.class_method_signature: DistributedQueue.peek()
focal_class.full_signature: public byte[] peek()
focal_class.identifier: peek
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: byte[]
focal_class.signature: byte[] peek()
focal_class.class_method_signature: DistributedQueue.poll()
focal_class.full_signature: public byte[] poll()
focal_class.identifier: poll
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: byte[]
focal_class.signature: byte[] poll()
focal_method.body: public byte[] remove() throws NoSuchElementException, KeeperException, InterruptedException {
          TreeMap<Long,String> orderedChildren;
          // Same as for element.  Should refactor this.
          while(true){
              try{
                  orderedChildren = orderedChildren(null);
              }catch(KeeperException.NoNodeException e){
                  throw new NoSuchElementException();
              }
              if(orderedChildren.size() == 0) throw new NoSuchElementException();
  
              for(String headNode : orderedChildren.values()){
                  String path = dir +"/"+headNode;
                  try{
                      byte[] data = zookeeper.getData(path, false, null);
                      zookeeper.delete(path, -1);
                      return data;
                  }catch(KeeperException.NoNodeException e){
                      // Another client deleted the node first.
                  }
              }
  
          }
      }
focal_method.class_method_signature: DistributedQueue.remove()
focal_method.full_signature: public byte[] remove()
focal_method.identifier: remove
focal_method.invocations: orderedChildren size values getData delete
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: byte[]
focal_method.signature: byte[] remove()