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(); }
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(); } } } }
public void close() { handler.close(); }
protected void selectForWrite() { handler.selectForWrite(); }