private void queueDrain(IBigQueue queue, long count) throws IOException {
   long queueSize = queue.size();
   count = queueSize < count ? queueSize : count;
   for (int i = 0; i < count; i++) {
     queue.dequeue();
   }
 }
Beispiel #2
0
 @Override
 public void doWork(final Handler h) {
   System.out.println("doing work round " + round);
   boolean hasErr = false;
   while (true) {
     try {
       byte[] e = queue.dequeue();
       if (e == null) {
         break;
       }
       h.process(fromBytes(e));
     } catch (IOException e) {
       logger.warn("failed to deQueue", e);
       hasErr = true;
       break;
     }
   }
   if (hasErr) {
     backOff += waitOnEmtpyInMs;
   } else {
     backOff = waitOnEmtpyInMs;
   }
   System.out.println("done-doing work " + round);
   round++;
   reSchedule(h);
 }
Beispiel #3
0
 @Override
 public void put(List<Event> events) throws IOException {
   Preconditions.checkNotNull(events);
   for (Event e : events) {
     if (e != null) {
       queue.enqueue(toBytes(e));
     }
   }
 }
Beispiel #4
0
 @Override
 public void put(Event event) throws IOException {
   Preconditions.checkNotNull(event);
   queue.enqueue(toBytes(event));
 }