    All Packages  Class Hierarchy  This Package  Previous  Next  Index

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

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

public class MICPFilter
extends Thread
implements PropRequestFilter, PropertyMonitoring, MICP

##

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

##

MICPFilter()

##

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

##

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.

DEBUG_P

     public static final String DEBUG_P

  Properties - Our debug flag.

ADDRESS_P

     public static final String ADDRESS_P

  Properties - Our multicast group address.

PORT_P

     public static final String PORT_P

  Properties - Our own UDP port number.

TIMEOUT_P

     public static final String TIMEOUT_P

  Properties - Our default timeout value.

DISABLE_CACHE_P

     public static final String DISABLE_CACHE_P

  Properties - disable caching when fetching from a neighbour proxy.

PROXY_P

     public static final String PROXY_P

  Properties - location of proxy to redirect to (if success)

props

     protected ObservableProperties props

  The properties we are initialized from.

cache

     protected CacheFilter cache

  The CacheFilter we are working for.

timeoutValue

     protected long timeoutValue

  Our default timeout value for waiting for replies (in ms).

debug

     protected boolean debug

  Our we in debug mode ?

disableCache

     protected boolean disableCache

  Should we disablecaching when fetching through a proxy ?

waiters

     protected Vector waiters

  Queue of threads waiting for some replies.

addr

     protected InetAddress addr

  Our multicast group address.

localproxy

     protected byte localproxy[]

  Our local proxy address, in a byte array.

localsrc

     protected long localsrc

  Our local internet address, as a long.

localaddr

     protected byte localaddr[]

  Our local internet address as a byte array.

socket

     protected MulticastSocket socket

  Our socket to the group.

ttl

     protected int ttl

  Our TTL for writing packets.

##

MICPFilter

     public MICPFilter()

##

lookupWaiter

     protected final synchronized ReplyWaiter lookupWaiter(int id)

removeWaiter

     protected final synchronized void removeWaiter(ReplyWaiter w)

addWaiter

     protected final synchronized ReplyWaiter addWaiter(int id)

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.

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.

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.

propertyChanged

     public boolean propertyChanged(String name)

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.

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.

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.

sync

     public void sync()

  This filter doesn't maintain dynamic state.

run

     public void run()

  Overrides:
    run in class Thread

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: PropRequestFilterException
    If the filter cannot launch its server part (listening for incomming ICP requests)

    All Packages  Class Hierarchy  This Package  Previous  Next  Index