@Override
  public void put(SchedulerQueryContext query)
      throws OutOfCapacityException {
    Preconditions.checkNotNull(query);
    _queueLock.lock();
    String groupName = _groupSelector.getSchedulerGroupName(query);
    try {
      SchedulerGroup groupContext = getOrCreateGroupContext(groupName);
      checkGroupHasCapacity(groupContext);
      query.setSchedulerGroupContext(groupContext);
      groupContext.addLast(query);
      _queryReaderCondition.signal();
    } finally {
      _queueLock.unlock();
    }
  }
@Test
  public void testPutForBlockedReader()
      throws Exception {
    // test adding a query immediately makes blocked take() to return
    final MultiLevelPriorityQueue queue = createQueue();
    QueueReader reader = new QueueReader(queue);
    // we know thread has started. Sleep for the wakeup duration and check again
    reader.startAndWaitForQueueWakeup();
    assertTrue(reader._reader.isAlive());
    assertEquals(reader._readQueries.size(), 0);
    sleepForQueueWakeup(queue);
    // add a request. We should get it back in atleast wakupTimeDuration (possibly sooner)
    queue.put(createQueryRequest(GROUP_ONE, METRICS));
    sleepForQueueWakeup(queue);
    assertEquals(reader._readQueries.size(), 1);
  }