Ejemplo n.º 1
0
 protected boolean writeBatch() {
   try {
     if (handler.getChannel().write(buffer) < 0) {
       if (log.isTraceEnabled()) {
         log.trace("Closing channel");
       }
       inError = true;
       return false;
     } else if (buffer.hasRemaining()) {
       if (handler.getChannel().write(buffer) < 0) {
         if (log.isTraceEnabled()) {
           log.trace("Closing channel");
         }
         inError = true;
         return false;
       }
     }
   } catch (IOException e) {
     if (Utils.isClose(e)) {
       log.info(String.format("closing acknowledger %s ", fsm.getName()));
     } else {
       log.warn(
           String.format("Unable to write batch commit acknowledgement %s", fsm.getName()), e);
     }
     error();
     return false;
   }
   return !buffer.hasRemaining();
 }
Ejemplo n.º 2
0
 protected void nextBatch() {
   buffer.clear();
   pending.drainTo(drain, MAX_BATCH_SIZE - 1);
   for (BatchIdentity bid : drain) {
     bid.serializeOn(buffer);
   }
   drain.clear();
   buffer.flip();
   if (writeBatch()) {
     fsm.payloadWritten();
   } else {
     if (inError) {
       fsm.close();
     } else {
       if (inError) {
         fsm.close();
       } else {
         handler.selectForWrite();
       }
     }
   }
 }
Ejemplo n.º 3
0
 public void close() {
   handler.close();
 }
Ejemplo n.º 4
0
 protected void selectForWrite() {
   handler.selectForWrite();
 }