com.sun.faban.harness.logging
Class RequestProxy

java.lang.Object
  extended by com.sun.faban.harness.logging.RequestProxy
All Implemented Interfaces:
Runnable

public class RequestProxy
extends Object
implements Runnable

The request proxy represents the request for both the selector end and the service thread end. The selector will set the proxy to ready state and if the request is not already processed by a service thread, it will also schedule the request to be processed by the thread pool. Otherwise it will use the request proxy to notify the processing thread that the channel is ready to perform I/O.

The service thread side will process the request and wait for notification if more I/O is needed and the channel is not ready.

Author:
Akara Sucharitakul

Constructor Summary
RequestProxy(LogConfig config, SelectionKey key)
          Constructs a request proxy.
 
Method Summary
 boolean channelReady()
          Tells the proxy that the channel is ready for IO.
 void run()
          Run is called from the thread pool to process the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestProxy

public RequestProxy(LogConfig config,
                    SelectionKey key)
Constructs a request proxy.

Parameters:
config - The log configuration
key - The nio selection key identifying the socket channel
Method Detail

channelReady

public boolean channelReady()
Tells the proxy that the channel is ready for IO.

Returns:
true if read was already ready, false otherwise

run

public void run()
Run is called from the thread pool to process the request. With the non-blocking I/O, we might not have all the data when run gets called. Subsequent reads/writes after the initial one will not go to the thread pool but will notify a waiting run method directly.

Specified by:
run in interface Runnable