org.apache.jk.common

Class ChannelSocket

Implemented Interfaces:
MBeanRegistration, NotificationBroadcaster, JkChannel, NotificationListener

public class ChannelSocket
extends JkHandler
implements NotificationBroadcaster, JkChannel

Accept ( and send ) TCP messages.

Author:
Costin Manolache

Field Summary

protected boolean
running

Fields inherited from class org.apache.jk.core.JkHandler

ERROR, HANDLE_FLUSH, HANDLE_RECEIVE_PACKET, HANDLE_SEND_PACKET, HANDLE_THREAD_END, LAST, OK, domain, id, mserver, name, next, nextName, oname, properties, wEnv

Constructor Summary

ChannelSocket()

Method Summary

void
accept(MsgContext ep)
void
addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
void
close(MsgContext ep)
void
destroy()
Clean up and stop the handler
int
flush(Msg msg, MsgContext ep)
String
getAddress()
String
getChannelName()
boolean
getDaemon()
int
getInstanceId()
At startup we'll look for the first free port in the range.
int
getMaxPort()
int
getMaxSpareThreads()
int
getMaxThreads()
int
getMinSpareThreads()
MBeanNotificationInfo[]
getNotificationInfo()
int
getPort()
long
getRequestCount()
int
getServerTimeout()
int
getSoLinger()
int
getSoTimeout()
boolean
getTcpNoDelay()
ThreadPool
getThreadPool()
void
init()
int
invoke(Msg msg, MsgContext ep)
static boolean
isSameAddress(InetAddress server, InetAddress client)
Return true if the specified client and server addresses are the same.
boolean
isSameAddress(MsgContext ep)
void
open(MsgContext ep)
void
pause()
int
read(MsgContext ep, byte[] b, int offset, int len)
Read N bytes from the InputStream, and ensure we got them all Under heavy load we could experience many fragmented packets just read Unix Network Programming to recall that a call to read didn't ensure you got all the data you want from read() Linux manual On success, the number of bytes read is returned (zero indicates end of file),and the file position is advanced by this number.
int
receive(Msg msg, MsgContext ep)
void
registerRequest(Request req, MsgContext ep, int count)
void
reinit()
Called after you change some fields at runtime using jmx.
void
removeNotificationListener(NotificationListener listener)
void
resetCounters()
void
resume()
int
send(Msg msg, MsgContext ep)
void
sendNewMessageNotification(Notification notification)
void
setAddress(InetAddress inet)
void
setAddress(String inet)
void
setBacklog(int i)
void
setDaemon(boolean b)
If set to false, the thread pool will be created in non-daemon mode, and will prevent main from exiting
void
setMaxPort(int i)
void
setMaxSpareThreads(int i)
void
setMaxThreads(int i)
void
setMinSpareThreads(int i)
void
setNotificationInfo(info[] )
void
setPort(int port)
Set the port for the ajp13 channel.
void
setServerTimeout(int timeout)
Sets the timeout in ms of the server sockets created by this server.
void
setSoLinger(int i)
void
setSoTimeout(int i)
void
setTcpNoDelay(boolean b)
void
start()
void
stop()

Methods inherited from class org.apache.jk.core.JkHandler

addHandlerCallback, createMsgContext, destroy, getDomain, getId, getName, getNext, getObjectName, getProperty, handleNotification, init, invoke, pause, postDeregister, postRegister, preDeregister, preRegister, resume, setId, setName, setNext, setNext, setProperty, setWorkerEnv

Field Details

running

protected boolean running

Constructor Details

ChannelSocket

public ChannelSocket()

Method Details

accept

public void accept(MsgContext ep)
            throws IOException


addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
            throws IllegalArgumentException


close

public void close(MsgContext ep)
            throws IOException


destroy

public void destroy()
            throws IOException
Clean up and stop the handler
Overrides:
destroy in interface JkHandler


flush

public int flush(Msg msg,
                 MsgContext ep)
            throws IOException
Specified by:
flush in interface JkChannel


getAddress

public String getAddress()


getChannelName

public String getChannelName()
Specified by:
getChannelName in interface JkChannel


getDaemon

public boolean getDaemon()


getInstanceId

public int getInstanceId()
At startup we'll look for the first free port in the range. The difference between this port and the beggining of the range is the 'id'. This is usefull for lb cases ( less config ).


getMaxPort

public int getMaxPort()


getMaxSpareThreads

public int getMaxSpareThreads()


getMaxThreads

public int getMaxThreads()


getMinSpareThreads

public int getMinSpareThreads()


getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()


getPort

public int getPort()


getRequestCount

public long getRequestCount()


getServerTimeout

public int getServerTimeout()


getSoLinger

public int getSoLinger()


getSoTimeout

public int getSoTimeout()


getTcpNoDelay

public boolean getTcpNoDelay()


getThreadPool

public ThreadPool getThreadPool()


init

public void init()
            throws IOException
Overrides:
init in interface JkHandler


invoke

public int invoke(Msg msg,
                  MsgContext ep)
            throws IOException
Specified by:
invoke in interface JkChannel
Overrides:
invoke in interface JkHandler


isSameAddress

public static boolean isSameAddress(InetAddress server,
                                    InetAddress client)
Return true if the specified client and server addresses are the same. This method works around a bug in the IBM 1.1.8 JVM on Linux, where the address bytes are returned reversed in some circumstances.

Parameters:
server - The server's InetAddress
client - The client's InetAddress


isSameAddress

public boolean isSameAddress(MsgContext ep)
Specified by:
isSameAddress in interface JkChannel


open

public void open(MsgContext ep)
            throws IOException


pause

public void pause()
            throws Exception
Overrides:
pause in interface JkHandler


read

public int read(MsgContext ep,
                byte[] b,
                int offset,
                int len)
            throws IOException
Read N bytes from the InputStream, and ensure we got them all Under heavy load we could experience many fragmented packets just read Unix Network Programming to recall that a call to read didn't ensure you got all the data you want from read() Linux manual On success, the number of bytes read is returned (zero indicates end of file),and the file position is advanced by this number. It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal. On error, -1 is returned, and errno is set appropriately. In this case it is left unspecified whether the file position (if any) changes.


receive

public int receive(Msg msg,
                   MsgContext ep)
            throws IOException
Specified by:
receive in interface JkChannel


registerRequest

public void registerRequest(Request req,
                            MsgContext ep,
                            int count)
Specified by:
registerRequest in interface JkChannel


reinit

public void reinit()
            throws IOException
Called after you change some fields at runtime using jmx. Experimental for now.


removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
            throws ListenerNotFoundException


resetCounters

public void resetCounters()


resume

public void resume()
            throws Exception
Overrides:
resume in interface JkHandler


send

public int send(Msg msg,
                MsgContext ep)
            throws IOException
Specified by:
send in interface JkChannel


sendNewMessageNotification

public void sendNewMessageNotification(Notification notification)


setAddress

public void setAddress(InetAddress inet)


setAddress

public void setAddress(String inet)


setBacklog

public void setBacklog(int i)


setDaemon

public void setDaemon(boolean b)
If set to false, the thread pool will be created in non-daemon mode, and will prevent main from exiting


setMaxPort

public void setMaxPort(int i)


setMaxSpareThreads

public void setMaxSpareThreads(int i)


setMaxThreads

public void setMaxThreads(int i)


setMinSpareThreads

public void setMinSpareThreads(int i)


setNotificationInfo

public void setNotificationInfo(info[] )


setPort

public void setPort(int port)
Set the port for the ajp13 channel. To support seemless load balancing and jni, we treat this as the 'base' port - we'll try up until we find one that is not used. We'll also provide the 'difference' to the main coyote handler - that will be our 'sessionID' and the position in the scoreboard and the suffix for the unix domain socket.


setServerTimeout

public void setServerTimeout(int timeout)
Sets the timeout in ms of the server sockets created by this server. This method allows the developer to make servers more or less responsive to having their server sockets shut down.

By default this value is 1000ms.


setSoLinger

public void setSoLinger(int i)


setSoTimeout

public void setSoTimeout(int i)


setTcpNoDelay

public void setTcpNoDelay(boolean b)


start

public void start()
            throws IOException


stop

public void stop()
            throws IOException


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.