@Override
 public void run() {
   try {
     while (moreDocumentsExist()) {
       index(inputPipeline.take());
     }
   } catch (Throwable e) {
     throw new RuntimeException(e);
   } finally {
     cleanIndex();
   }
 }
 protected int countQueue() {
   return inputPipeline.count();
 }
 protected boolean moreDocumentsExist() {
   return !inputPipeline.isDone();
 }