コード例 #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();
 }
コード例 #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();
       }
     }
   }
 }
コード例 #3
0
 public void close() {
   handler.close();
 }
コード例 #4
0
 protected void selectForWrite() {
   handler.selectForWrite();
 }