jetty-9 renamed ReadInterest to fillInterest

This commit is contained in:
Greg Wilkins 2012-08-03 12:47:33 +10:00
parent 29833f000b
commit 7df281bb16
5 changed files with 36 additions and 32 deletions

View File

@ -51,7 +51,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
protected boolean _growOutput;
private final ReadInterest _readInterest = new ReadInterest()
private final FillInterest _fillInterest = new FillInterest()
{
@Override
protected boolean needsFill() throws IOException
@ -150,7 +150,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
{
_in = in;
if (in == null || BufferUtil.hasContent(in))
_readInterest.readable();
_fillInterest.readable();
}
/* ------------------------------------------------------------ */
@ -356,7 +356,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
*/
public void reset()
{
_readInterest.close();
_fillInterest.close();
_writeFlusher.onClose();
_ishut=false;
_oshut=false;
@ -426,7 +426,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
long idleElapsed = System.currentTimeMillis() - idleTimestamp;
long idleLeft = idleTimeout - idleElapsed;
if (isOutputShutdown() || _readInterest.isInterested() || _writeFlusher.isInProgress())
if (isOutputShutdown() || _fillInterest.isInterested() || _writeFlusher.isInProgress())
{
if (idleTimestamp != 0 && idleTimeout > 0)
{
@ -435,7 +435,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
LOG.debug("{} idle timeout expired", this);
TimeoutException timeout = new TimeoutException("Idle timeout expired: " + idleElapsed + "/" + idleTimeout + " ms");
_readInterest.failed(timeout);
_fillInterest.failed(timeout);
_writeFlusher.onFail(timeout);
if (isOutputShutdown())
@ -454,7 +454,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
@Override
public <C> void fillInterested(C context, Callback<C> callback) throws IllegalStateException
{
_readInterest.register(context, callback);
_fillInterest.register(context, callback);
}
/* ------------------------------------------------------------ */

View File

@ -14,14 +14,14 @@ import org.eclipse.jetty.util.Callback;
* by keeping state and calling the context and callback objects.
*
*/
public abstract class ReadInterest
public abstract class FillInterest
{
private final AtomicBoolean _interested = new AtomicBoolean(false);
private volatile Callback<Object> _callback;
private Object _context;
/* ------------------------------------------------------------ */
protected ReadInterest()
protected FillInterest()
{
}

View File

@ -79,7 +79,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
* true if {@link ManagedSelector#destroyEndPoint(EndPoint)} has not been called
*/
private final AtomicBoolean _open = new AtomicBoolean();
private final ReadInterest _readInterest = new ReadInterest()
private final FillInterest _fillInterest = new FillInterest()
{
@Override
protected boolean needsFill()
@ -150,7 +150,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
@Override
public <C> void fillInterested(C context, Callback<C> callback) throws IllegalStateException
{
_readInterest.register(context, callback);
_fillInterest.register(context, callback);
}
@Override
@ -178,7 +178,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
setKeyInterests(oldInterestOps, newInterestOps);
updateLocalInterests(readyOps, false);
if (_key.isReadable())
_readInterest.readable();
_fillInterest.readable();
if (_key.isWritable())
_writeFlusher.completeWrite();
}
@ -194,7 +194,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
LOG.debug("{} idle timeout check, elapsed: {} ms, remaining: {} ms", this, idleElapsed, idleLeft);
if (isOutputShutdown() || _readInterest.isInterested() || _writeFlusher.isInProgress())
if (isOutputShutdown() || _fillInterest.isInterested() || _writeFlusher.isInProgress())
{
if (idleTimestamp != 0 && idleTimeout > 0)
{
@ -203,7 +203,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
LOG.debug("{} idle timeout expired", this);
TimeoutException timeout = new TimeoutException("Idle timeout expired: " + idleElapsed + "/" + idleTimeout + " ms");
_readInterest.failed(timeout);
_fillInterest.failed(timeout);
_writeFlusher.onFail(timeout);
if (isOutputShutdown())
@ -269,7 +269,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
{
super.onClose();
_writeFlusher.onClose();
_readInterest.close();
_fillInterest.close();
}
@Override
@ -292,6 +292,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
}
return String.format("SCEP@%x{l(%s)<->r(%s),open=%b,ishut=%b,oshut=%b,i=%d%s,r=%s,w=%s}-{%s}",
hashCode(), getRemoteAddress(), getLocalAddress(), isOpen(), isInputShutdown(),
isOutputShutdown(), _interestOps, keyString, _readInterest, _writeFlusher, getConnection());
isOutputShutdown(), _interestOps, keyString, _fillInterest, _writeFlusher, getConnection());
}
}

View File

@ -67,10 +67,14 @@ abstract public class WriteFlusher
// will discover the failure and call the callbacks before returning to IDLE
// Thus the possible paths for a failure are:
//
// IDLE--(fail)-->IDLE
// IDLE-->WRITING--(fail)-->FAILED-->IDLE
// IDLE-->WRITING-->PENDING--(fail)-->IDLE
// IDLE-->WRITING-->PENDING-->COMPLETING--(fail)-->FAILED-->IDLE
// IDLE--(fail)-->IDLE
// IDLE-->WRITING--(fail)-->FAILED-->IDLE
// IDLE-->WRITING-->PENDING--(fail)-->IDLE
// IDLE-->WRITING-->PENDING-->COMPLETING--(fail)-->FAILED-->IDLE
//
// So a call to fail in the PENDING state will be directly handled and the state changed to IDLE
// A call to fail in the WRITING or COMPLETING states will just set the state to FAILED and the failure will be
// handled with the write or completeWrite methods try to move the state from what they thought it was.
//
protected WriteFlusher(EndPoint endPoint)

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.io.ReadInterest;
import org.eclipse.jetty.io.FillInterest;
import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.WriteFlusher;
@ -138,8 +138,8 @@ public class SslConnection extends AbstractConnection
{
// wake up whoever is doing the fill or the flush so they can
// do all the filling, unwrapping ,wrapping and flushing
if (_decryptedEndPoint._readInterest.isInterested())
_decryptedEndPoint._readInterest.readable();
if (_decryptedEndPoint._fillInterest.isInterested())
_decryptedEndPoint._fillInterest.readable();
// If we are handshaking, then wake up any waiting write as well as it may have been blocked on the read
if ( _decryptedEndPoint._flushRequiresFillToProgress)
@ -164,8 +164,8 @@ public class SslConnection extends AbstractConnection
synchronized(_decryptedEndPoint)
{
if (_decryptedEndPoint._readInterest.isInterested())
_decryptedEndPoint._readInterest.failed(cause);
if (_decryptedEndPoint._fillInterest.isInterested())
_decryptedEndPoint._fillInterest.failed(cause);
if (_decryptedEndPoint._flushRequiresFillToProgress)
{
@ -182,12 +182,12 @@ public class SslConnection extends AbstractConnection
return String.format("SslConnection@%x{%s,%s%s}",
hashCode(),
_sslEngine.getHandshakeStatus(),
_decryptedEndPoint._readInterest.isInterested() ? "R" : "",
_decryptedEndPoint._fillInterest.isInterested() ? "R" : "",
_decryptedEndPoint._writeFlusher.isInProgress() ? "W" : "");
}
/* ------------------------------------------------------------ */
public class DecryptedEndPoint extends AbstractEndPoint implements EndPoint
public class DecryptedEndPoint extends AbstractEndPoint
{
private boolean _fillRequiresFlushToProgress;
private boolean _flushRequiresFillToProgress;
@ -215,7 +215,7 @@ public class SslConnection extends AbstractConnection
if (_fillRequiresFlushToProgress)
{
_fillRequiresFlushToProgress = false;
_readInterest.readable();
_fillInterest.readable();
}
if (_writeFlusher.isInProgress())
@ -241,7 +241,7 @@ public class SslConnection extends AbstractConnection
if (_fillRequiresFlushToProgress)
{
_fillRequiresFlushToProgress = false;
_readInterest.failed(x);
_fillInterest.failed(x);
}
if (_writeFlusher.isInProgress())
@ -252,7 +252,7 @@ public class SslConnection extends AbstractConnection
}
};
private final ReadInterest _readInterest = new ReadInterest()
private final FillInterest _fillInterest = new FillInterest()
{
@Override
protected boolean needsFill() throws IOException
@ -350,7 +350,7 @@ public class SslConnection extends AbstractConnection
@Override
public <C> void fillInterested(C context, Callback<C> callback) throws IllegalStateException
{
_readInterest.register(context, callback);
_fillInterest.register(context, callback);
}
@Override
@ -619,7 +619,7 @@ public class SslConnection extends AbstractConnection
case NEED_UNWRAP:
// Ah we need to fill some data so we can write.
// So if we were not called from fill and the app is not reading anyway
if (!_fillRequiresFlushToProgress && !_readInterest.isInterested())
if (!_fillRequiresFlushToProgress && !_fillInterest.isInterested())
{
// Tell the onFillable method that there might be a write to complete
// TODO move this to the writeFlusher?
@ -706,7 +706,7 @@ public class SslConnection extends AbstractConnection
@Override
public String toString()
{
return String.format("%s{%s%s%s}", super.toString(), _readInterest.isInterested() ? "R" : "", _writeFlusher.isInProgress() ? "W" : "", _cannotAcceptMoreAppDataToFlush ? "w" : "");
return String.format("%s{%s%s%s}", super.toString(), _fillInterest.isInterested() ? "R" : "", _writeFlusher.isInProgress() ? "W" : "", _cannotAcceptMoreAppDataToFlush ? "w" : "");
}
}