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
Method Summary |
void | accept(MsgContext ep) |
void | addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) |
void | close(MsgContext ep) |
void | destroy() |
int | flush(Msg msg, MsgContext ep) |
String | getAddress() |
int | getBufferSize() |
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 | getPacketSize() |
int | getPort() |
long | getRequestCount() |
int | getServerTimeout() |
int | getSoLinger() |
int | getSoTimeout() |
boolean | getTcpNoDelay() |
ThreadPool | getThreadPool() |
void | init()
jmx:managed-operation |
int | invoke(Msg msg, MsgContext ep) |
boolean | isSameAddress(MsgContext ep) |
static boolean | isSameAddress(InetAddress server, InetAddress client)
Return true if the specified client and server addresses
are the same. |
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)
jmx:managed-attribute description="Bind on a specified address" access="READ_WRITE" |
void | setBacklog(int i) |
void | setBufferSize(int bs) |
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(MBeanNotificationInfo[] info) |
void | setPacketSize(int ps) |
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() |
protected boolean running
public ChannelSocket()
jmx:managed-constructor description="default constructor"
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
public void destroy()
public String getAddress()
public int getBufferSize()
public String getChannelName()
public boolean getDaemon()
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 ).
public int getMaxPort()
public int getMaxSpareThreads()
public int getMaxThreads()
public int getMinSpareThreads()
public MBeanNotificationInfo[] getNotificationInfo()
public int getPacketSize()
public int getPort()
public long getRequestCount()
public int getServerTimeout()
public int getSoLinger()
public int getSoTimeout()
public boolean getTcpNoDelay()
public void init()
jmx:managed-operation
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
public void pause()
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.
public void reinit()
Called after you change some fields at runtime using jmx.
Experimental for now.
public void removeNotificationListener(NotificationListener listener)
public void resetCounters()
public void resume()
public void sendNewMessageNotification(Notification notification)
public void setAddress(InetAddress inet)
public void setAddress(String inet)
jmx:managed-attribute description="Bind on a specified address" access="READ_WRITE"
public void setBacklog(int i)
public void setBufferSize(int bs)
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
public void setMaxPort(int i)
public void setMaxSpareThreads(int i)
public void setMaxThreads(int i)
public void setMinSpareThreads(int i)
public void setNotificationInfo(MBeanNotificationInfo[] info)
public void setPacketSize(int ps)
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"
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.
public void setSoLinger(int i)
public void setSoTimeout(int i)
public void setTcpNoDelay(boolean b)
public void start()
public void stop()
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.