/** * This method is used to flush the contents of the buffer to * the client. This method will block until such time as all of * the data has been sent to the client. If at any point there * is an error sending the content an exception is thrown. */ public void flush() throws IOException { if(closed) { throw new TransportException("Transport is closed"); } transport.flush(); }
/** * This is used to close the writer and the underlying socket. * If a close is performed on the writer then no more bytes * can be read from or written to the writer and the client * will receive a connection close on their side. */ public void close() throws IOException { flusher.close(); writer.close(); } }
/** * This method is used to flush all of the queued buffers to * the client. This method will not block but will simply flush * any data to the underlying transport. Internally the data * will be queued for delivery to the connected entity. */ public void flush() throws IOException { boolean done = writer.flush(); // returns true only if everything is delivered if(!done) { flusher.flush(); // here we will block for an op write event if the buffer contains a reference } }
/** * This method is used to create <code>Operation</code> object to * process the next phase of the negotiation. The operations that * are created using this factory ensure the processing can be * done asynchronously, which reduces the overhead the connection * thread has when handing the pipelines over for processing. * * @param socket this is the pipeline that is to be processed * * @return this returns the operation used for processing */ public Operation getInstance(Socket socket) throws IOException { return getInstance(socket, socket.getEngine()); }
/** * Here in this method we schedule a flush when the underlying * writer is write ready. This allows the writer thread to return * without having to fully flush the content to the underlying * transport. If there are references queued this will block. */ public synchronized void flush() throws IOException { if(closed) { throw new TransportException("Flusher is closed"); } boolean block = writer.isBlocking(); if(!closed) { scheduler.schedule(block); } }
/** * This is used to flush the internal buffer to the underlying * socket. Flushing with this method is always non-blocking, so * if the socket is not write ready and the buffer can be queued * it will be queued and the calling thread will return. */ public void flush() throws IOException { if(closed) { throw new TransportException("Transport is closed"); } writer.flush(); }
/** * Constructor for the <code>SocketWriter</code> object. This is * used to create a writer that can write packets to the socket * in such a way that it write either asynchronously or block * the calling thread until such time as the packets are written. * * @param socket this is the pipeline that this writes to * @param reactor this is the writer used to scheduler writes * @param threshold this is the threshold for asynchronous buffers */ public SocketController(Socket socket, Reactor reactor, int threshold) throws IOException { this.writer = new SocketWriter(socket, threshold); this.flusher = new SocketFlusher(socket, reactor, writer); }
/** * This is used to abort the flushing process when the reactor has * been stopped. An abort to the flusher typically happens when the * server has been shutdown. It prevents threads lingering waiting * for a I/O operation which prevents the server from shutting down. */ public synchronized void abort() throws IOException { scheduler.close(); buffer.close(); }
/** * This is used to close the writer and the underlying socket. * If a close is performed on the writer then no more bytes * can be read from or written to the writer and the client * will receive a connection close on their side. */ public void close() throws IOException { flusher.close(); writer.close(); } }
/** * This is used to transfer the transport to the processor. This * will typically be executed asynchronously so that it does not * delay the thread that passes the <code>Transport</code> to the * transport processor, ensuring quicker processing. */ public void run() { try { processor.process(transport); }catch(Exception e) { cancel(); } }
/** * This method is used to flush all of the queued packets to * the client. This method will block not block but will simply * flush any data to the underlying transport. Internally the * data will be queued for delivery to the connected entity. */ public void flush() throws IOException { boolean done = writer.flush(); if(!done) { flusher.flush(); } }
/** * This is used to abort the flushing process when the reactor has * been stopped. An abort to the flusher typically happens when the * server has been shutdown. It prevents threads lingering waiting * for a I/O operation which prevents the server from shutting down. */ private synchronized void abort() throws IOException { scheduler.close(); writer.close(); }
/** * This is used to transfer the transport to the negotiator. This * will typically be executed asynchronously so that it does not * delay the thread that passes the <code>Pipeline</code> to the * transport processor, ensuring quicker processing. */ public void run() { try { negotiator.process(transport); }catch(Exception e) { cancel(); } }
/** * This method is used to flush the contents of the buffer to * the client. This method will block until such time as all of * the data has been sent to the client. If at any point there * is an error sending the content an exception is thrown. */ public void flush() throws IOException { if(closed) { throw new TransportException("Transport is closed"); } transport.flush(); }
/** * This is used to flush the internal buffer to the underlying * socket. Flushing with this method is always non-blocking, so * if the socket is not write ready and the buffer can be queued * it will be queued and the calling thread will return. */ public void flush() throws IOException { if(closed) { throw new TransportException("Transport is closed"); } writer.flush(); }
/** * This method is used to flush all of the queued buffers to * the client. This method will not block but will simply flush * any data to the underlying transport. Internally the data * will be queued for delivery to the connected entity. */ public void flush() throws IOException { boolean done = writer.flush(); // returns true only if everything is delivered if(!done) { flusher.flush(); // here we will block for an op write event if the buffer contains a reference } }
/** * This is used to abort the flushing process when the reactor has * been stopped. An abort to the flusher typically happens when the * server has been shutdown. It prevents threads lingering waiting * for a I/O operation which prevents the server from shutting down. */ public synchronized void abort() throws IOException { scheduler.close(); buffer.close(); }
/** * This is used to close the writer and the underlying socket. * If a close is performed on the writer then no more bytes * can be read from or written to the writer and the client * will receive a connection close on their side. */ public void close() throws IOException { flusher.close(); writer.close(); } }
/** * This is used to transfer the transport to the processor. This * will typically be executed asynchronously so that it does not * delay the thread that passes the <code>Transport</code> to the * transport processor, ensuring quicker processing. */ public void run() { try { processor.process(transport); }catch(Exception e) { cancel(); } }
/** * This method is used to flush the contents of the buffer to * the client. This method will block until such time as all of * the data has been sent to the client. If at any point there * is an error sending the content an exception is thrown. */ public void flush() throws IOException { if(closed) { throw new TransportException("Transport is closed"); } transport.flush(); }