All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.www.protocol.http.micp.MICPFilter

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----w3c.www.protocol.http.micp.MICPFilter

public class MICPFilter
extends Thread
implements PropRequestFilter, PropertyMonitoring, MICP

Variable Index

 o addr
Our multicast group address.
 o ADDRESS_P
Properties - Our multicast group address.
 o cache
The CacheFilter we are working for.
 o debug
Our we in debug mode ?
 o DEBUG_P
Properties - Our debug flag.
 o DISABLE_CACHE_P
Properties - disable caching when fetching from a neighbour proxy.
 o disableCache
Should we disablecaching when fetching through a proxy ?
 o localaddr
Our local internet address as a byte array.
 o localproxy
Our local proxy address, in a byte array.
 o localsrc
Our local internet address, as a long.
 o PORT_P
Properties - Our own UDP port number.
 o props
The properties we are initialized from.
 o PROXY_P
Properties - location of proxy to redirect to (if success)
 o socket
Our socket to the group.
 o STATE_HOW
State - To mark requests that have been redirected.
 o TIMEOUT_P
Properties - Our default timeout value.
 o timeoutValue
Our default timeout value for waiting for replies (in ms).
 o ttl
Our TTL for writing packets.
 o waiters
Queue of threads waiting for some replies.

Constructor Index

 o MICPFilter()

Method Index

 o addWaiter(int)
 o exceptionFilter(Request, HttpException)
This filter doesn't handle exceptions.
 o handle(byte[], int)
Parse and handle the given MICP packet.
 o ingoingFilter(Request)
Our ingoingFilter method.
 o initialize(HttpManager)
Initialize the ICP filter.
 o locateProxy(URL)
Locate some proxy for the given URL.
 o lookupWaiter(int)
 o outgoingFilter(Request, Reply)
Our outgoingFilter does nothing (at all).
 o propertyChanged(String)
 o removeWaiter(ReplyWaiter)
 o run()
 o sync()
This filter doesn't maintain dynamic state.
 o waitOn(int)
Wait for the reply on this reqiest identifier.

Variables

 o STATE_HOW
 public static final String STATE_HOW
State - To mark requests that have been redirected. This state is set to the URL of the proxy that has been used to run the request, if any.

 o DEBUG_P
 public static final String DEBUG_P
Properties - Our debug flag.

 o ADDRESS_P
 public static final String ADDRESS_P
Properties - Our multicast group address.

 o PORT_P
 public static final String PORT_P
Properties - Our own UDP port number.

 o TIMEOUT_P
 public static final String TIMEOUT_P
Properties - Our default timeout value.

 o DISABLE_CACHE_P
 public static final String DISABLE_CACHE_P
Properties - disable caching when fetching from a neighbour proxy.

 o PROXY_P
 public static final String PROXY_P
Properties - location of proxy to redirect to (if success)

 o props
 protected ObservableProperties props
The properties we are initialized from.

 o cache
 protected CacheFilter cache
The CacheFilter we are working for.

 o timeoutValue
 protected long timeoutValue
Our default timeout value for waiting for replies (in ms).

 o debug
 protected boolean debug
Our we in debug mode ?

 o disableCache
 protected boolean disableCache
Should we disablecaching when fetching through a proxy ?

 o waiters
 protected Vector waiters
Queue of threads waiting for some replies.

 o addr
 protected InetAddress addr
Our multicast group address.

 o localproxy
 protected byte localproxy[]
Our local proxy address, in a byte array.

 o localsrc
 protected long localsrc
Our local internet address, as a long.

 o localaddr
 protected byte localaddr[]
Our local internet address as a byte array.

 o socket
 protected MulticastSocket socket
Our socket to the group.

 o ttl
 protected int ttl
Our TTL for writing packets.

Constructors

 o MICPFilter
 public MICPFilter()

Methods

 o lookupWaiter
 protected final synchronized ReplyWaiter lookupWaiter(int id)
 o removeWaiter
 protected final synchronized void removeWaiter(ReplyWaiter w)
 o addWaiter
 protected final synchronized ReplyWaiter addWaiter(int id)
 o waitOn
 public URL waitOn(int id)
Wait for the reply on this reqiest identifier. Don't wait for more than the timeout value.

Returns:
The replied URL if any, or null.
 o handle
 protected void handle(byte buf[],
                       int len) throws IOException
Parse and handle the given MICP packet. This method does not use (currently) the reader/writer. The point is that on queries, it tries to reuse the receive buffer for output (which allows to handle queries without nearly zero allocations).

Parameters:
buf - The packet.
len - Total length of packet.
 o locateProxy
 protected int locateProxy(URL u) throws IOException
Locate some proxy for the given URL. Synchronizing this method allows to reuse the emit buffer (kind of nice), and anyway, there will be a synchronized point when writting to the network (see, I am not convinced)

Parameters:
u - The URL to locate.
Returns:
An integer reply identifier to wait on for the reply.
Throws: IOException
If the multicast group wasn't available.
 o propertyChanged
 public boolean propertyChanged(String name)
 o exceptionFilter
 public boolean exceptionFilter(Request request,
                                HttpException ex)
This filter doesn't handle exceptions.

Parameters:
request - The request that triggered the exception.
ex - The triggered exception.
Returns:
Always false.
 o ingoingFilter
 public Reply ingoingFilter(Request request)
Our ingoingFilter method. This method emits (only for GET requestst currently) an ICP query to all our neighbors, and wait for either one of them to reply with a hit, or, our timeout value to expire.

If a hit reply is received, we then use the corresponding proxy to fullfill the request.

Parameters:
request - The request that is about to be emitted.
Returns:
Always null.
 o outgoingFilter
 public Reply outgoingFilter(Request request,
                             Reply reply)
Our outgoingFilter does nothing (at all).

Parameters:
request - The request that has been processed.
reply - The original reply (from origin server)
Returns:
Always null.
 o sync
 public void sync()
This filter doesn't maintain dynamic state.

 o run
 public void run()
Overrides:
run in class Thread
 o initialize
 public void initialize(HttpManager manager) throws PropRequestFilterException
Initialize the ICP filter. This is where we parse the configuration file in order to know about our neighbors. We then register ourself to the HTTP manager.

Parameters:
manager - The HTTP manager.
Throws: FilterInitException
If the filter cannot launch its server part (listening for incomming ICP requests)

All Packages  Class Hierarchy  This Package  Previous  Next  Index