org.apache.jcs.auxiliary.lateral.socket.tcp
Class LateralTCPSender

java.lang.Object
  extended byorg.apache.jcs.auxiliary.lateral.socket.tcp.LateralTCPSender

public class LateralTCPSender
extends java.lang.Object

This class is based on the log4j SocketAppender class. I'm using a differnet repair structure, so it is significant;y different.

Version:
$Id: LateralTCPSender.java,v 1.6 2003/08/22 11:57:18 mpoeschl Exp $
Author:
Aaron Smuts

Field Summary
private  java.net.InetAddress address
           
(package private)  int counter
           
private  ILateralCacheAttributes ilca
           
private static org.apache.commons.logging.Log log
           
private  java.io.ObjectOutputStream oos
           
private static int openTimeOut
          Only block for 5 seconds before timing out on startup.
(package private)  int port
           
private  java.lang.String remoteHost
           
private static int RESET_FREQUENCY
           
private  java.net.Socket socket
           
private static int timeOut
          Only block for 10 seconds before timing out on a read.
 
Constructor Summary
LateralTCPSender(ILateralCacheAttributes lca)
          Constructor for the LateralTCPSender object
 
Method Summary
 void dispose(java.lang.String cache)
          Closes connection used by all LateralTCPSenders for this lateral conneciton.
private  java.net.InetAddress getAddressByName(java.lang.String host)
          Gets the addressByName attribute of the LateralTCPSender object
protected  void init(java.lang.String host, int port)
          Description of the Method
static void main(java.lang.String[] args)
          Description of the Method
 void release()
          Description of the Method
 void remove(java.lang.String cacheName, java.io.Serializable key)
          Description of the Method
 void remove(java.lang.String cacheName, java.io.Serializable key, byte requesterId)
          Description of the Method
 void removeAll(java.lang.String cacheName)
          Description of the Method
 void removeAll(java.lang.String cacheName, byte requesterId)
          Description of the Method
 void send(LateralElementDescriptor led)
          Sends commands to the lateral cache listener.
 ICacheElement sendAndReceive(LateralElementDescriptor led)
          Sends commands to the lateral cache listener and gets a response.
 void update(ICacheElement item, byte requesterId)
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

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

ilca

private ILateralCacheAttributes ilca

remoteHost

private java.lang.String remoteHost

address

private java.net.InetAddress address

port

int port

oos

private java.io.ObjectOutputStream oos

socket

private java.net.Socket socket

counter

int counter

RESET_FREQUENCY

private static final int RESET_FREQUENCY
See Also:
Constant Field Values

timeOut

private static final int timeOut
Only block for 10 seconds before timing out on a read. TODO: make configurable. The default 10 it way too long.

See Also:
Constant Field Values

openTimeOut

private static final int openTimeOut
Only block for 5 seconds before timing out on startup.

See Also:
Constant Field Values
Constructor Detail

LateralTCPSender

public LateralTCPSender(ILateralCacheAttributes lca)
                 throws java.io.IOException
Constructor for the LateralTCPSender object

Parameters:
lca -
Throws:
java.io.IOException
Method Detail

init

protected void init(java.lang.String host,
                    int port)
             throws java.io.IOException
Description of the Method

Throws:
java.io.IOException

getAddressByName

private java.net.InetAddress getAddressByName(java.lang.String host)
                                       throws java.io.IOException
Gets the addressByName attribute of the LateralTCPSender object

Returns:
The addressByName value
Throws:
java.io.IOException

send

public void send(LateralElementDescriptor led)
          throws java.io.IOException
Sends commands to the lateral cache listener.

Throws:
java.io.IOException

sendAndReceive

public ICacheElement sendAndReceive(LateralElementDescriptor led)
                             throws java.io.IOException
Sends commands to the lateral cache listener and gets a response. I'm afraid that we could get into a pretty bad blocking situation here. This needs work. I just wanted to get some form of get working. Will need some sort of timeout.

Throws:
java.io.IOException

update

public void update(ICacheElement item,
                   byte requesterId)
            throws java.io.IOException
Description of the Method

Throws:
java.io.IOException

remove

public void remove(java.lang.String cacheName,
                   java.io.Serializable key)
            throws java.io.IOException
Description of the Method

Throws:
java.io.IOException

remove

public void remove(java.lang.String cacheName,
                   java.io.Serializable key,
                   byte requesterId)
            throws java.io.IOException
Description of the Method

Throws:
java.io.IOException

release

public void release()
             throws java.io.IOException
Description of the Method

Throws:
java.io.IOException

dispose

public void dispose(java.lang.String cache)
             throws java.io.IOException
Closes connection used by all LateralTCPSenders for this lateral conneciton. Dispose request should come into the facade and be sent to all lateral cache sevices. The lateral cache service will then call this method.

Throws:
java.io.IOException

removeAll

public void removeAll(java.lang.String cacheName)
               throws java.io.IOException
Description of the Method

Throws:
java.io.IOException

removeAll

public void removeAll(java.lang.String cacheName,
                      byte requesterId)
               throws java.io.IOException
Description of the Method

Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
Description of the Method