org.apache.jk.common

Class ChannelSocket

public class ChannelSocket extends JkHandler implements NotificationBroadcaster, JkChannel

Accept ( and send ) TCP messages.

Author: Costin Manolache Bill Barker jmx:mbean name="jk:service=ChannelNioSocket" description="Accept socket connections" jmx:notification name="org.apache.coyote.INVOKE jmx:notification-handler name="org.apache.jk.JK_SEND_PACKET jmx:notification-handler name="org.apache.jk.JK_RECEIVE_PACKET jmx:notification-handler name="org.apache.jk.JK_FLUSH Jk can use multiple protocols/transports. Various container adapters should load this object ( as a bean ), set configurations and use it. Note that the connector will handle all incoming protocols - it's not specific to ajp1x. The protocol is abstracted by MsgContext/Message/Channel. A lot of the 'original' behavior is hardcoded - this uses Ajp13 wire protocol, TCP, Ajp14 API etc. As we add other protocols/transports/APIs this will change, the current goal is to get the same level of functionality as in the original jk connector. XXX Make the 'message type' pluggable

Field Summary
protected booleanrunning
Constructor Summary
ChannelSocket()
jmx:managed-constructor description="default constructor"
Method Summary
voidaccept(MsgContext ep)
voidaddNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
voidclose(MsgContext ep)
voiddestroy()
intflush(Msg msg, MsgContext ep)
StringgetAddress()
intgetBufferSize()
StringgetChannelName()
booleangetDaemon()
intgetInstanceId()
At startup we'll look for the first free port in the range.
intgetMaxPort()
intgetMaxSpareThreads()
intgetMaxThreads()
intgetMinSpareThreads()
MBeanNotificationInfo[]getNotificationInfo()
intgetPacketSize()
intgetPort()
longgetRequestCount()
intgetServerTimeout()
intgetSoLinger()
intgetSoTimeout()
booleangetTcpNoDelay()
ThreadPoolgetThreadPool()
voidinit()
jmx:managed-operation
intinvoke(Msg msg, MsgContext ep)
booleanisSameAddress(MsgContext ep)
static booleanisSameAddress(InetAddress server, InetAddress client)
Return true if the specified client and server addresses are the same.
voidopen(MsgContext ep)
voidpause()
intread(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.
intreceive(Msg msg, MsgContext ep)
voidregisterRequest(Request req, MsgContext ep, int count)
voidreinit()
Called after you change some fields at runtime using jmx.
voidremoveNotificationListener(NotificationListener listener)
voidresetCounters()
voidresume()
intsend(Msg msg, MsgContext ep)
voidsendNewMessageNotification(Notification notification)
voidsetAddress(InetAddress inet)
voidsetAddress(String inet)
jmx:managed-attribute description="Bind on a specified address" access="READ_WRITE"
voidsetBacklog(int i)
voidsetBufferSize(int bs)
voidsetDaemon(boolean b)
If set to false, the thread pool will be created in non-daemon mode, and will prevent main from exiting
voidsetMaxPort(int i)
voidsetMaxSpareThreads(int i)
voidsetMaxThreads(int i)
voidsetMinSpareThreads(int i)
voidsetNotificationInfo(MBeanNotificationInfo[] info)
voidsetPacketSize(int ps)
voidsetPort(int port)
Set the port for the ajp13 channel.
voidsetServerTimeout(int timeout)
Sets the timeout in ms of the server sockets created by this server.
voidsetSoLinger(int i)
voidsetSoTimeout(int i)
voidsetTcpNoDelay(boolean b)
voidstart()
voidstop()

Field Detail

running

protected boolean running

Constructor Detail

ChannelSocket

public ChannelSocket()
jmx:managed-constructor description="default constructor"

Method Detail

accept

public void accept(MsgContext ep)

addNotificationListener

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

close

public void close(MsgContext ep)

destroy

public void destroy()

flush

public int flush(Msg msg, MsgContext ep)

getAddress

public String getAddress()

getBufferSize

public int getBufferSize()

getChannelName

public String getChannelName()

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()

getPacketSize

public int getPacketSize()

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()
jmx:managed-operation

invoke

public int invoke(Msg msg, MsgContext ep)

isSameAddress

public boolean isSameAddress(MsgContext ep)

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

open

public void open(MsgContext ep)

pause

public void pause()

read

public 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. 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)

registerRequest

public void registerRequest(Request req, MsgContext ep, int count)

reinit

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

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)

resetCounters

public void resetCounters()

resume

public void resume()

send

public int send(Msg msg, MsgContext ep)

sendNewMessageNotification

public void sendNewMessageNotification(Notification notification)

setAddress

public void setAddress(InetAddress inet)

setAddress

public void setAddress(String inet)
jmx:managed-attribute description="Bind on a specified address" access="READ_WRITE"

setBacklog

public void setBacklog(int i)

setBufferSize

public void setBufferSize(int bs)

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(MBeanNotificationInfo[] info)

setPacketSize

public void setPacketSize(int ps)

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. jmx:managed-attribute description="Port to listen" access="READ_WRITE"

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()

stop

public void stop()
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.