Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

juju.reattore.server.http
Class HttpClientHandler  view HttpClientHandler download HttpClientHandler.java

java.lang.Object
  extended byjuju.reattore.server.http.HttpClientHandler
All Implemented Interfaces:
juju.reattore.core.reactor.ClientSocketHandler, juju.reattore.core.reactor.Handler

public class HttpClientHandler
extends java.lang.Object
implements juju.reattore.core.reactor.ClientSocketHandler

Handler that knows about the HTTP protocol.


Field Summary
private  juju.reattore.io.ByteSource body
           
private  java.nio.ByteBuffer bodyPart
           
private  java.nio.channels.SocketChannel ch
           
private static juju.reattore.util.GaugeStat concurrentStat
           
private static int DEFAULT_IN_CAPACITY
           
private static int DEFAULT_OUT_CAPACITY
           
private static juju.reattore.util.RateStat errorRateStat
           
private  java.nio.ByteBuffer headers
           
private  java.nio.ByteBuffer in
           
private static org.apache.commons.logging.Log log
           
private  HttpMediator mediator
           
private  juju.reattore.protocol.http.HttpParser parser
           
private static juju.reattore.util.DurationStat parseStat
           
private  java.util.List pending
          List of HttpRequests not yet processed
private static juju.reattore.util.DurationStat processStat
           
private static juju.reattore.util.DurationStat readStat
           
private  int reqsLeft
           
private static juju.reattore.util.RateStat serveRateStat
           
private  boolean shouldClose
           
private static int STATE_WRITE_NEXT
           
private static int STATE_WRITE_START
           
private static juju.reattore.util.RateStat writeRateStat
           
private static juju.reattore.util.DurationStat writeStat
           
private  int writeState
           
 
Constructor Summary
HttpClientHandler(java.nio.channels.SocketChannel ch, HttpMediator mediator)
          Create a new HTTP handler.
 
Method Summary
private  void done()
           
private  byte[] getBytes(java.lang.StringBuffer in)
           
 int getInterestOps()
          Returns the set of operations this handler is currently interested in.
 boolean handleConnected()
          Called when the socket is initially connected.
 void handleError()
          Called when any error occurs on the attached socket.
 boolean handleReadable()
          Called when the attached socket has data available.
 boolean handleWritable()
          Called when the attached socket is ready to be written to.
private  boolean processNext()
           
private  boolean write()
           
private  boolean writeBody()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

DEFAULT_IN_CAPACITY

private static final int DEFAULT_IN_CAPACITY
See Also:
Constant Field Values

DEFAULT_OUT_CAPACITY

private static final int DEFAULT_OUT_CAPACITY
See Also:
Constant Field Values

STATE_WRITE_START

private static final int STATE_WRITE_START
See Also:
Constant Field Values

STATE_WRITE_NEXT

private static final int STATE_WRITE_NEXT
See Also:
Constant Field Values

writeState

private int writeState

mediator

private HttpMediator mediator

ch

private java.nio.channels.SocketChannel ch

in

private java.nio.ByteBuffer in

headers

private java.nio.ByteBuffer headers

body

private juju.reattore.io.ByteSource body

bodyPart

private java.nio.ByteBuffer bodyPart

shouldClose

private boolean shouldClose

pending

private java.util.List pending
List of HttpRequests not yet processed


parser

private juju.reattore.protocol.http.HttpParser parser

readStat

private static juju.reattore.util.DurationStat readStat

parseStat

private static juju.reattore.util.DurationStat parseStat

processStat

private static juju.reattore.util.DurationStat processStat

writeStat

private static juju.reattore.util.DurationStat writeStat

writeRateStat

private static juju.reattore.util.RateStat writeRateStat

serveRateStat

private static juju.reattore.util.RateStat serveRateStat

errorRateStat

private static juju.reattore.util.RateStat errorRateStat

concurrentStat

private static juju.reattore.util.GaugeStat concurrentStat

reqsLeft

private int reqsLeft
Constructor Detail

HttpClientHandler

public HttpClientHandler(java.nio.channels.SocketChannel ch,
                         HttpMediator mediator)
Create a new HTTP handler.

Method Detail

getInterestOps

public int getInterestOps()
Description copied from interface: juju.reattore.core.reactor.Handler
Returns the set of operations this handler is currently interested in. See SelectorKey for more informration.

Specified by:
getInterestOps in interface juju.reattore.core.reactor.Handler

done

private void done()

handleConnected

public boolean handleConnected()
                        throws java.io.IOException
Description copied from interface: juju.reattore.core.reactor.ClientSocketHandler
Called when the socket is initially connected. This does not imply that the channel is readable or writable.

Specified by:
handleConnected in interface juju.reattore.core.reactor.ClientSocketHandler

handleReadable

public boolean handleReadable()
                       throws java.io.IOException
Description copied from interface: juju.reattore.core.reactor.ClientSocketHandler
Called when the attached socket has data available.

Specified by:
handleReadable in interface juju.reattore.core.reactor.ClientSocketHandler

getBytes

private byte[] getBytes(java.lang.StringBuffer in)

processNext

private boolean processNext()
                     throws java.io.IOException

write

private boolean write()
               throws java.io.IOException

writeBody

private boolean writeBody()
                   throws java.io.IOException

handleWritable

public boolean handleWritable()
                       throws java.io.IOException
Description copied from interface: juju.reattore.core.reactor.ClientSocketHandler
Called when the attached socket is ready to be written to.

Specified by:
handleWritable in interface juju.reattore.core.reactor.ClientSocketHandler

handleError

public void handleError()
Description copied from interface: juju.reattore.core.reactor.ClientSocketHandler
Called when any error occurs on the attached socket. Does not distinguish between connection, transient, or fatal errors. The socket may not be usable.

Specified by:
handleError in interface juju.reattore.core.reactor.ClientSocketHandler