JSPservletPkg
Class ICPhandler

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--JSPservletPkg.ICPhandler

class ICPhandler
extends java.lang.Thread

Multicast support through ICP-like messages.

Copyright (c) 2000-2001

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; version 2
 of the License.
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 

Version:
1, 0
Author:
Alexis Grandemange
See Also:
JSPhandler.ClassEntry

Inner Class Summary
(package private)  class ICPhandler.DisklessCltHandler
          Class handling diskless IDs.
(package private)  class ICPhandler.IcpHeader
          ICP header.
(package private)  class ICPhandler.Log
          Class wraping diskless logging.
(package private)  class ICPhandler.LogPrivilegedAction
          Wraps a log.
 
Field Summary
(package private)  ICPhandler.DisklessCltHandler dch
          Object handling diskless IDs.
private  java.net.DatagramSocket ds
          UDP point to point socket
private  java.net.InetAddress group
          Multicast group or point to point interface.
private  JSPhandler handler
          Invoking JSPhandler.
(package private) static byte ICP_OP_ARCHIVE_STATUS
          PageBox archive RESP.
(package private) static byte ICP_OP_ARCHIVE_UPDATE
          PageBox update request issued by client.
(package private) static byte ICP_OP_DECHO
          Similar to ICP_OP_QUERY, but for use in simulating a query to a cache which does not use ICP.
(package private) static byte ICP_OP_DENIED
          An ICP_OP_DENIED response indicates that the querying site is not allowed to retrieve the named object from this cache.
(package private) static byte ICP_OP_ERR
          An ICP_OP_ERR response indicates some kind of error in parsing or handling the query message (e.g.
(package private) static byte ICP_OP_FIN
          PageBox termination message.
(package private) static byte ICP_OP_HIT
          An ICP_OP_HIT response indicates that the requested URL exists in this cache and that the requester is allowed to retrieve it.
(package private) static byte ICP_OP_HIT_OBJ
          Just like an ICP_OP_HIT response, but the actual object data has been included in this reply message.
(package private) static byte ICP_OP_INI
          PageBox initialization message issued by client.
(package private) static byte ICP_OP_INVALID
          A place holder to detect zero-filled or malformed messages.
(package private) static byte ICP_OP_LOG
          PageBox log message.
(package private) static byte ICP_OP_MISS
          An ICP_OP_MISS response indicates that the requested URL does not exist in this cache.
(package private) static byte ICP_OP_MISS_NOFETCH
          An ICP_OP_MISS_NOFETCH response indicates that this cache is up, but is in a state where it does not want to handle cache misses.
(package private) static byte ICP_OP_QUERY
          A query message.
(package private) static byte ICP_OP_SECHO
          Similar to ICP_OP_QUERY, but for use in simulating a query to an origin server.
(package private) static byte ICP_OP_STAT_QUERY
          PageBox stats query issued by client.
(package private) static byte ICP_OP_STAT_STATUS
          PageBox stats response issued by server.
(package private) static byte ICP_OP_STAT_UPDATE
          PageBox update request issued by client.
private  java.util.HashMap logs
          Map of diskless logs.
(package private) static int maxMsgSize
          Maximum size of the ICP messages ICPhandler processes.
private  java.net.MulticastSocket mcs
          Multicast socket.
private  byte[] myAddress
          AS host address.
(package private) static int nextreq
          req number.
(package private)  java.net.InetAddress[] remAddrs
           
(package private)  java.util.HashMap stats
          Map of found archive stats on diskless client side.
private  boolean toContinue
          Loop while true.
 
Fields inherited from class java.lang.Thread
contextClassLoader, daemon, eetop, group, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadQ, values
 
Constructor Summary
(package private) ICPhandler(JSPhandler jh)
          Constructor.
 
Method Summary
(package private)  void close()
          Termination: Terminates the thread Close log files Clear logs
private  void disklessClientCheck()
          Handles multicast messages targeting client.
 void disklessClientInit()
          On client side - not use handler.log.
private  void disklessServerCheck()
          Handle multicast messages targeting server.
(package private) static void dump(byte[] buf, int length)
           
private  void endLoop()
          Stop the loop. Set toContinue at false to ask thread termination.
protected  void finalize()
          to avoid loitering
(package private)  ICPhandler.Log getLog(java.lang.String ID)
          Log retrieve method.
(package private)  void log(java.lang.String msg)
          Log method - used by diskless client.
 void run()
          Loops to read multicast messages.
(package private)  void statUpdate(java.lang.String jarName, java.util.Properties prop)
          Stat update method - used by diskless client.
private  boolean toBeContinued()
          Check if loop must be continued.
(package private) static int toInt(byte b)
          Converts a byte in positive integer.
(package private)  void update()
          Update method - used by diskless client.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxMsgSize

static final int maxMsgSize
Maximum size of the ICP messages ICPhandler processes. Size needed for properties.

ICP_OP_INVALID

static final byte ICP_OP_INVALID
A place holder to detect zero-filled or malformed messages. A cache must never intentionally send an ICP_OP_INVALID message. ICP_OP_ERR should be used instead.

ICP_OP_QUERY

static final byte ICP_OP_QUERY
A query message. NOTE this opcode has a different payload format than most of the others. First is the requester's IPv4 address, followed by a URL. The Requester Host Address is not that of the cache generating the ICP message, but rather the address of the caches's client that originated the request. The Requester Host Address is often zero filled. An ICP message with an all-zero Requester Host Address address should be taken as one where the requester address is not specified; it does not indicate a valid IPv4 address. In response to an ICP_OP_QUERY, the recipient must return one of: ICP_OP_HIT, ICP_OP_MISS, ICP_OP_ERR, ICP_OP_MISS_NOFETCH, ICP_OP_DENIED, or ICP_OP_HIT_OBJ.

ICP_OP_HIT

static final byte ICP_OP_HIT
An ICP_OP_HIT response indicates that the requested URL exists in this cache and that the requester is allowed to retrieve it.

ICP_OP_MISS

static final byte ICP_OP_MISS
An ICP_OP_MISS response indicates that the requested URL does not exist in this cache. The querying cache may still choose to fetch the URL from the replying cache.

ICP_OP_ERR

static final byte ICP_OP_ERR
An ICP_OP_ERR response indicates some kind of error in parsing or handling the query message (e.g. invalid URL).

ICP_OP_INI

static final byte ICP_OP_INI
PageBox initialization message issued by client. Prompts for stats and archive names.

ICP_OP_ARCHIVE_STATUS

static final byte ICP_OP_ARCHIVE_STATUS
PageBox archive RESP. Returned by server when it receives a ICP_OP_INI. In this case, the payload is a serialized property file.

ICP_OP_STAT_QUERY

static final byte ICP_OP_STAT_QUERY
PageBox stats query issued by client.

ICP_OP_LOG

static final byte ICP_OP_LOG
PageBox log message.

ICP_OP_FIN

static final byte ICP_OP_FIN
PageBox termination message.

ICP_OP_SECHO

static final byte ICP_OP_SECHO
Similar to ICP_OP_QUERY, but for use in simulating a query to an origin server. When ICP is used to select the closest neighbor, the origin server can be included in the algorithm by bouncing an ICP_OP_SECHO message off it's echo port. The payload is simply the null-terminated URL.

ICP_OP_DECHO

static final byte ICP_OP_DECHO
Similar to ICP_OP_QUERY, but for use in simulating a query to a cache which does not use ICP. When ICP is used to choose the closest neighbor, a non-ICP cache can be included in the algorithm by bouncing an ICP_OP_DECHO message off it's echo port. The payload is simply the null-terminated URL.

ICP_OP_STAT_STATUS

static final byte ICP_OP_STAT_STATUS
PageBox stats response issued by server. In this case, the payload is a serialized property file.

ICP_OP_ARCHIVE_UPDATE

static final byte ICP_OP_ARCHIVE_UPDATE
PageBox update request issued by client. In this case, the payload is a serialized property file.

ICP_OP_STAT_UPDATE

static final byte ICP_OP_STAT_UPDATE
PageBox update request issued by client. In this case, the payload is a serialized property file.

ICP_OP_MISS_NOFETCH

static final byte ICP_OP_MISS_NOFETCH
An ICP_OP_MISS_NOFETCH response indicates that this cache is up, but is in a state where it does not want to handle cache misses. An example of such a state is during a startup phase where a cache might be rebuilding its object store. A cache in such a mode may wish to return ICP_OP_HIT for cache hits, but not ICP_OP_MISS for misses. ICP_OP_MISS_NOFETCH essentially means "I am up and running, but please don't fetch this URL from me now."

ICP_OP_DENIED

static final byte ICP_OP_DENIED
An ICP_OP_DENIED response indicates that the querying site is not allowed to retrieve the named object from this cache. Caches and proxies may implement complex access controls. This reply must be be interpreted to mean "you are not allowed to request this particular URL from me at this particular time."

ICP_OP_HIT_OBJ

static final byte ICP_OP_HIT_OBJ
Just like an ICP_OP_HIT response, but the actual object data has been included in this reply message. Many requested objects are small enough that it is possible to include them in the query response and avoid the need to make a subsequent HTTP request for the object.

nextreq

static int nextreq
req number.

mcs

private java.net.MulticastSocket mcs
Multicast socket.

group

private java.net.InetAddress group
Multicast group or point to point interface.

ds

private java.net.DatagramSocket ds
UDP point to point socket

myAddress

private byte[] myAddress
AS host address.

handler

private JSPhandler handler
Invoking JSPhandler.

toContinue

private boolean toContinue
Loop while true.

remAddrs

java.net.InetAddress[] remAddrs

stats

java.util.HashMap stats
Map of found archive stats on diskless client side. Used by ClassEntry.Stat. Key: archive name. Value: stat properties.

dch

ICPhandler.DisklessCltHandler dch
Object handling diskless IDs. Instantiated on diskless server side.

logs

private java.util.HashMap logs
Map of diskless logs. Used on diskless server side. key: diskless ID value: Log
Constructor Detail

ICPhandler

ICPhandler(JSPhandler jh)
     throws org.osgi.framework.BundleException
Constructor. Log is created after ICPhandler. Do not use handler.log.
Parameters:
jh - calling JSPhandler.
Method Detail

toBeContinued

private boolean toBeContinued()
Check if loop must be continued.

toInt

static final int toInt(byte b)
Converts a byte in positive integer.
Parameters:
b - byte to convert.

dump

static void dump(byte[] buf,
                 int length)

endLoop

private void endLoop()
Stop the loop.
  1. Set toContinue at false to ask thread termination.
  2. sends a message. On client side, triggers the termination. On server size, triggers log close.

disklessClientInit

public void disklessClientInit()
                        throws org.osgi.framework.BundleException
On client side - not use handler.log. Diskless client handshaking - synchronous.
Suppose two server answer whose one was stopped during last client session.
 Client must give a chance to all up servers - though it doesn't know how
 many are up and select the most up to date answer.

run

public void run()
Loops to read multicast messages.
Overrides:
run in class java.lang.Thread

disklessClientCheck

private void disklessClientCheck()
Handles multicast messages targeting client.

getLog

ICPhandler.Log getLog(java.lang.String ID)
Log retrieve method. Called by disklessServerCheck and DisklessLog.
Parameters:
ID - logs key.

disklessServerCheck

private void disklessServerCheck()
Handle multicast messages targeting server.

log

void log(java.lang.String msg)
Log method - used by diskless client. In case of exceptions, sends messages on console.
Parameters:
msg - message to log.

update

void update()
Update method - used by diskless client. In case of exceptions, sends messages on console.

statUpdate

void statUpdate(java.lang.String jarName,
                java.util.Properties prop)
Stat update method - used by diskless client. In case of exceptions, sends messages on console.
Parameters:
jarName - archive whose stats will be recorded.
prop - stats to record.

close

void close()
Termination:
  1. Terminates the thread
  2. Close log files
  3. Clear logs

finalize

protected void finalize()
to avoid loitering
Overrides:
finalize in class java.lang.Object