protected BioReplicationTask getReplicationThread() { BioReplicationTask result = new BioReplicationTask(this); result.setOptions(getWorkerThreadOptions()); result.setUseBufferPool(this.getUseBufferPool()); return result; }
public synchronized void run() { if ( socket == null ) return; try { drainSocket(); } catch ( Exception x ) { log.error("Unable to service bio socket"); }finally { try {socket.close();}catch ( Exception ignore){} try {reader.close();}catch ( Exception ignore){} reader = null; socket = null; } // done, ready for more, return to pool if ( getTaskPool() != null ) getTaskPool().returnWorker (this); }
/** * The actual code which drains the channel associated with * the given key. This method assumes the key has been * modified prior to invocation to turn off selection * interest in OP_READ. When this method completes it * re-enables OP_READ and calls wakeup() on the selector * so the selector will resume watching this channel. */ protected void drainSocket () throws Exception { InputStream in = socket.getInputStream(); // loop while data available, channel is non-blocking byte[] buf = new byte[1024]; int length = in.read(buf); while ( length >= 0 ) { int count = reader.append(buf,0,length,true); if ( count > 0 ) execute(reader); length = in.read(buf); } }
if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND); try { getCallback().messageDataReceived(msgs[i]); if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND); }catch ( Exception x ) { if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.FAIL_ACK_COMMAND); log.error("Error thrown from messageDataReceived.",x); if ( getUseBufferPool() ) { BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage()); msgs[i].setMessage(null);
task.setDoRun(false); task.serviceSocket(null,null); getExecutor().execute(task); break; //regular shutdown socket.setSoTimeout(getTimeout()); ObjectReader reader = new ObjectReader(socket); task.serviceSocket(socket,reader); getExecutor().execute(task);
task.serviceSocket(null,null); getExecutor().execute(task); task.close(); break; //regular shutdown socket.setSoTimeout(getTimeout()); ObjectReader reader = new ObjectReader(socket); task.serviceSocket(socket,reader); getExecutor().execute(task);
if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND); try { getCallback().messageDataReceived(msgs[i]); if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND); }catch ( Exception x ) { if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.FAIL_ACK_COMMAND); log.error("Error thrown from messageDataReceived.",x); if ( getUseBufferPool() ) { BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage()); msgs[i].setMessage(null);
task.setDoRun(false); task.serviceSocket(null,null); getExecutor().execute(task); break; //regular shutdown socket.setSoTimeout(getTimeout()); ObjectReader reader = new ObjectReader(socket); task.serviceSocket(socket,reader); getExecutor().execute(task);
protected BioReplicationTask getReplicationThread() { BioReplicationTask result = new BioReplicationTask(this); result.setOptions(getWorkerThreadOptions()); result.setUseBufferPool(this.getUseBufferPool()); return result; }
if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND); try { getCallback().messageDataReceived(msgs[i]); if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND); }catch ( Exception x ) { if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.FAIL_ACK_COMMAND); log.error("Error thrown from messageDataReceived.",x); if ( getUseBufferPool() ) { BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage()); msgs[i].setMessage(null);
@Override public synchronized void run() { if ( socket == null ) return; try { drainSocket(); } catch ( Exception x ) { log.error("Unable to service bio socket", x); }finally { try { socket.close(); }catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed to close socket", e); } } try { reader.close(); }catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed to close reader", e); } } reader = null; socket = null; } // done, ready for more, return to pool if ( getTaskPool() != null ) getTaskPool().returnWorker (this); }
task.setDoRun(false); task.serviceSocket(null,null); getExecutor().execute(task); break; //regular shutdown socket.setSoTimeout(getTimeout()); ObjectReader reader = new ObjectReader(socket); task.serviceSocket(socket,reader);
/** * The actual code which drains the channel associated with * the given key. This method assumes the key has been * modified prior to invocation to turn off selection * interest in OP_READ. When this method completes it * re-enables OP_READ and calls wakeup() on the selector * so the selector will resume watching this channel. */ protected void drainSocket () throws Exception { InputStream in = socket.getInputStream(); // loop while data available, channel is non-blocking byte[] buf = new byte[1024]; int length = in.read(buf); while ( length >= 0 ) { int count = reader.append(buf,0,length,true); if ( count > 0 ) execute(reader); length = in.read(buf); } }
protected BioReplicationTask getReplicationThread() { BioReplicationTask result = new BioReplicationTask(this); result.setOptions(getWorkerThreadOptions()); result.setUseBufferPool(this.getUseBufferPool()); return result; }
if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND); try { getCallback().messageDataReceived(msgs[i]); if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND); }catch ( Exception x ) { if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.FAIL_ACK_COMMAND); log.error(sm.getString("bioReplicationTask.messageDataReceived.error"),x); if ( getUseBufferPool() ) { BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage()); msgs[i].setMessage(null);
@Override public synchronized void run() { if ( socket == null ) return; try { drainSocket(); } catch ( Exception x ) { log.error("Unable to service bio socket", x); }finally { try { socket.close(); }catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed to close socket", e); } } try { reader.close(); }catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed to close reader", e); } } reader = null; socket = null; } // done, ready for more, return to pool if ( getTaskPool() != null ) getTaskPool().returnWorker (this); }
/** * The actual code which drains the channel associated with * the given key. This method assumes the key has been * modified prior to invocation to turn off selection * interest in OP_READ. When this method completes it * re-enables OP_READ and calls wakeup() on the selector * so the selector will resume watching this channel. * @throws Exception IO exception or execute exception */ protected void drainSocket() throws Exception { InputStream in = socket.getInputStream(); // loop while data available, channel is non-blocking byte[] buf = new byte[1024]; int length = in.read(buf); while ( length >= 0 ) { int count = reader.append(buf,0,length,true); if ( count > 0 ) execute(reader); length = in.read(buf); } }
protected BioReplicationTask getReplicationThread() { BioReplicationTask result = new BioReplicationTask(this); result.setOptions(getWorkerThreadOptions()); result.setUseBufferPool(this.getUseBufferPool()); return result; }
@Override public synchronized void run() { if ( socket == null ) return; try { drainSocket(); } catch ( Exception x ) { log.error(sm.getString("bioReplicationTask.unable.service"), x); }finally { try { socket.close(); }catch (Exception e) { if (log.isDebugEnabled()) { log.debug(sm.getString("bioReplicationTask.socket.closeFailed"), e); } } try { reader.close(); }catch (Exception e) { if (log.isDebugEnabled()) { log.debug(sm.getString("bioReplicationTask.reader.closeFailed"), e); } } reader = null; socket = null; } // done, ready for more, return to pool if ( getTaskPool() != null ) getTaskPool().returnWorker (this); }
/** * The actual code which drains the channel associated with * the given key. This method assumes the key has been * modified prior to invocation to turn off selection * interest in OP_READ. When this method completes it * re-enables OP_READ and calls wakeup() on the selector * so the selector will resume watching this channel. */ protected void drainSocket () throws Exception { InputStream in = socket.getInputStream(); // loop while data available, channel is non-blocking byte[] buf = new byte[1024]; int length = in.read(buf); while ( length >= 0 ) { int count = reader.append(buf,0,length,true); if ( count > 0 ) execute(reader); length = in.read(buf); } }