|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.remoting.transport.multiplex.MultiplexingManager
public class MultiplexingManager
MultiplexingManager
is the heart of the Multiplex system. It is the implementation
of the virtual socket group concept. See the Multiplex documentation on the
labs.jboss.org website for more information about virtual socket groups.
MultiplexingManager
wraps a single real java.net.Socket
.
It creates the socket when it is running on the client side, and it is passed a
socket by MasterServerSocket
when it is running on the server side.
MultiplexingManager
creates the infrastructure
which supports multiplexing, including an OutputMultiplexor
output thread and one
or more InputMultiplexor
input threads. When the last member leaves the socket
group, a MultiplexingManager
is responsible for negotiating with its remote peer
for permission to shut down, and for tearing down the multiplexing infrastructure when
the negotiations succeed.
MultiplexingManager
also provides the mechanism by which a virtual socket joins
a virtual socket group, identifying the new socket to the InputMultiplexor
input
thread.
Copyright (c) 2005
Nested Class Summary | |
---|---|
protected static class |
MultiplexingManager.PendingActionThread
|
protected class |
MultiplexingManager.ShutdownManager
The motivation behind this class is to prevent the following problem. |
protected class |
MultiplexingManager.ShutdownThread
|
Constructor Summary | |
---|---|
protected |
MultiplexingManager(java.net.InetSocketAddress address,
int timeout,
java.util.Map configuration)
|
protected |
MultiplexingManager(java.util.Map configuration)
|
protected |
MultiplexingManager(java.net.Socket socket,
java.util.Map configuration)
|
Method Summary | |
---|---|
protected static void |
addToPendingActions(PendingAction pendingAction)
Adds a PendingAction to the list of actions waiting to be executed. |
void |
bind(java.net.InetSocketAddress address)
Binds the wrapped socket. |
static boolean |
checkForManagerByAddressPair(java.net.InetSocketAddress localAddress,
java.net.InetSocketAddress remoteAddress)
|
static boolean |
checkForShareableManager(java.net.InetSocketAddress address)
|
static boolean |
checkForShareableManagerByAddressPair(java.net.InetSocketAddress localAddress,
java.net.InetSocketAddress remoteAddress)
|
void |
connect(java.net.InetSocketAddress address,
int timeout)
Connects the wrapped socket. |
protected java.net.Socket |
createSocket()
|
protected java.net.Socket |
createSocket(java.net.InetSocketAddress endpoint,
int timeout)
protected methods and classes |
void |
decrementReferences()
Decrement reference counter for this MultiplexingManager . |
java.util.Collection |
getAllOutputStreams()
|
static MultiplexingManager |
getaManager(java.net.Socket socket,
java.util.Map configuration)
|
static MultiplexingManager |
getaManagerByAddressPair(java.net.InetSocketAddress remoteAddress,
java.net.InetSocketAddress localAddress,
int timeout)
|
static MultiplexingManager |
getaManagerByAddressPair(java.net.InetSocketAddress remoteAddress,
java.net.InetSocketAddress localAddress,
int timeout,
java.util.Map conf)
|
static MultiplexingManager |
getaManagerByLocalAddress(java.net.InetSocketAddress address)
|
static MultiplexingManager |
getaManagerByLocalAddress(java.net.InetSocketAddress address,
java.util.Map conf)
|
static MultiplexingManager |
getaManagerByRemoteAddress(java.net.InetSocketAddress address,
int timeout)
|
static MultiplexingManager |
getaManagerByRemoteAddress(java.net.InetSocketAddress address,
int timeout,
java.util.Map conf)
|
static MultiplexingManager |
getAnExistingShareableManager(java.net.InetSocketAddress address,
java.util.Map conf)
|
static MultiplexingManager |
getAnExistingShareableManagerByAddressPair(java.net.InetSocketAddress remoteAddress,
java.net.InetSocketAddress localAddress,
java.util.Map conf)
|
MultiplexingInputStream |
getAnInputStream(SocketId socketId,
VirtualSocket socket)
Get an InputStream for a VirtualSocket . |
GrowablePipedOutputStream |
getAnOutputStream(SocketId socketId)
Get an OutputStrem for a VirtualSocket . |
MultiplexingOutputStream |
getAnOutputStream(VirtualSocket socket,
SocketId socketId)
|
static MultiplexingManager |
getaShareableManager(java.net.InetSocketAddress address,
int timeout)
|
static MultiplexingManager |
getaShareableManager(java.net.InetSocketAddress address,
int timeout,
java.util.Map conf)
|
static MultiplexingManager |
getaShareableManagerByAddressPair(java.net.InetSocketAddress remoteAddress,
java.net.InetSocketAddress localAddress,
int timeout)
|
static MultiplexingManager |
getaShareableManagerByAddressPair(java.net.InetSocketAddress remoteAddress,
java.net.InetSocketAddress localAddress,
int timeout,
java.util.Map conf)
|
java.io.OutputStream |
getBackchannelOutputStream()
|
GrowablePipedOutputStream |
getConnectedOutputStream(SocketId socketId)
Returns a GrowablePipedOutputStream that is connected to a
MultiplexingInputStream . |
java.io.OutputStream |
getDeadLetterOutputStream()
Returns OutputStream to use when corrupted InputStream gives no known "mailbox" |
javax.net.ssl.HandshakeCompletedEvent |
getHandshakeCompletedEvent()
|
java.io.InputStream |
getInputStream()
Returns InputStream of real socket |
OutputMultiplexor |
getOutputMultiplexor()
|
java.io.OutputStream |
getOutputStream()
Returns OutputStream of real socket |
java.io.OutputStream |
getOutputStreamByLocalSocket(SocketId socketId)
|
Protocol |
getProtocol()
|
java.net.ServerSocket |
getServerSocket()
|
int |
getShutdownMonitorPeriod()
|
int |
getShutdownRefusalsMaximum()
|
int |
getShutdownRequestTimeout()
|
java.net.Socket |
getSocket()
|
VirtualSocket |
getSocketByLocalPort(SocketId socketId)
|
javax.net.SocketFactory |
getSocketFactory()
|
static int |
getStaticThreadMonitorPeriod()
|
void |
handshakeCompleted(javax.net.ssl.HandshakeCompletedEvent event)
To implement HandshakeCompletedListener interface. |
void |
incrementReferences()
Increment reference counter for this MultiplexingManager . |
protected static void |
init(java.util.Map configuration)
|
protected void |
initParameters(java.util.Map configuration)
|
boolean |
isBound()
|
boolean |
isConnected()
|
boolean |
isRemoteServerSocketRegistered()
|
boolean |
isServerSocketRegistered()
|
boolean |
isShutdown()
|
boolean |
isSocketRegistered(SocketId socketId)
|
protected void |
notifySocketsOfException()
|
void |
outputFlushed()
Needed to implement OutputMultiplexor.OutputMultiplexorClient |
protected void |
registerByLocalAddress(java.net.InetSocketAddress address)
|
protected void |
registerByRemoteAddress(java.net.InetSocketAddress address)
|
void |
registerRemoteServerSocket()
Indicates that a VirtualServerSocket belongs the virtual socket group at the
remote end of the connection. |
MultiplexingInputStream |
registerServerSocket(java.net.ServerSocket serverSocket)
Identifies a VirtualServerSocket as the one associated with this virtual socket group. |
protected void |
registerShareable(java.net.InetSocketAddress address)
|
MultiplexingInputStream |
registerSocket(VirtualSocket socket)
Adds a VirtualSocket to this virtual socket group. |
protected void |
removeAnInputStream(SocketId socketId)
|
boolean |
respondToShutdownRequest()
|
void |
setCreatedForRemoteServerSocket()
|
protected void |
setEOF()
|
protected void |
setReadException(java.io.IOException e)
|
void |
setShutdownMonitorPeriod(int period)
|
void |
setShutdownRefusalsMaximum(int maximum)
|
void |
setShutdownRequestTimeout(int timeout)
|
void |
setSocketFactory(javax.net.SocketFactory socketFactory)
|
static void |
setStaticThreadsMonitorPeriod(int period)
|
protected void |
setup()
|
protected void |
setWriteException(java.io.IOException e)
|
protected void |
shutdown()
|
protected static void |
shutdownThreads()
|
java.lang.String |
toString()
|
protected void |
unregisterAllMaps()
|
protected void |
unregisterByLocalAddress()
|
protected void |
unregisterByRemoteAddress()
|
void |
unRegisterRemoteServerSocket()
Indicates there will no longer be a VirtualServeSocket at the remote end of
this connection. |
void |
unRegisterServerSocket(java.net.ServerSocket serverSocket)
Indicates a VirtualServerSocket is leaving this virtual socket group. |
protected void |
unregisterShareable()
|
void |
unRegisterSocket(VirtualSocket socket)
Indicates that a VirtualSocket is leaving a virtual socket group. |
boolean |
waitForRemoteServerSocketRegistered()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected MultiplexingManager(java.util.Map configuration) throws java.io.IOException
java.io.IOException
protected MultiplexingManager(java.net.Socket socket, java.util.Map configuration) throws java.io.IOException
socket
- configuration
-
java.io.IOException
protected MultiplexingManager(java.net.InetSocketAddress address, int timeout, java.util.Map configuration) throws java.io.IOException
address
- timeout
- configuration
-
java.io.IOException
Method Detail |
---|
protected static void init(java.util.Map configuration) throws java.io.IOException
java.io.IOException
protected void setup() throws java.io.IOException
java.io.IOException
protected void initParameters(java.util.Map configuration)
public static MultiplexingManager getaManager(java.net.Socket socket, java.util.Map configuration) throws java.io.IOException
socket
- configuration
-
java.io.IOException
- TODO: what if multiplexor already exists?public static MultiplexingManager getaManagerByLocalAddress(java.net.InetSocketAddress address) throws java.io.IOException
address
-
java.io.IOException
public static MultiplexingManager getaManagerByLocalAddress(java.net.InetSocketAddress address, java.util.Map conf) throws java.io.IOException
address
- conf
-
java.io.IOException
public static MultiplexingManager getaManagerByRemoteAddress(java.net.InetSocketAddress address, int timeout) throws java.io.IOException
address
- timeout
-
java.io.IOException
public static MultiplexingManager getaManagerByRemoteAddress(java.net.InetSocketAddress address, int timeout, java.util.Map conf) throws java.io.IOException
address
- timeout
- configuration
-
java.io.IOException
public static MultiplexingManager getaManagerByAddressPair(java.net.InetSocketAddress remoteAddress, java.net.InetSocketAddress localAddress, int timeout) throws java.io.IOException
remoteAddress
- localAddress
- timeout
-
java.io.IOException
public static MultiplexingManager getaManagerByAddressPair(java.net.InetSocketAddress remoteAddress, java.net.InetSocketAddress localAddress, int timeout, java.util.Map conf) throws java.io.IOException
remoteAddress
- localAddress
- timeout
- configuration
-
java.io.IOException
public static MultiplexingManager getaShareableManager(java.net.InetSocketAddress address, int timeout) throws java.io.IOException
address
- timeout
-
java.io.IOException
public static MultiplexingManager getaShareableManager(java.net.InetSocketAddress address, int timeout, java.util.Map conf) throws java.io.IOException
address
- timeout
- conf
-
java.io.IOException
public static MultiplexingManager getAnExistingShareableManager(java.net.InetSocketAddress address, java.util.Map conf) throws java.io.IOException
address
- timeout
- conf
-
java.io.IOException
public static MultiplexingManager getaShareableManagerByAddressPair(java.net.InetSocketAddress remoteAddress, java.net.InetSocketAddress localAddress, int timeout) throws java.io.IOException
remoteAddress
- localAddress
- timeout
-
java.io.IOException
public static MultiplexingManager getaShareableManagerByAddressPair(java.net.InetSocketAddress remoteAddress, java.net.InetSocketAddress localAddress, int timeout, java.util.Map conf) throws java.io.IOException
remoteAddress
- localAddress
- timeout
- conf
-
java.io.IOException
public static MultiplexingManager getAnExistingShareableManagerByAddressPair(java.net.InetSocketAddress remoteAddress, java.net.InetSocketAddress localAddress, java.util.Map conf) throws java.io.IOException
remoteAddress
- localAddress
- conf
-
java.io.IOException
public static boolean checkForShareableManager(java.net.InetSocketAddress address) throws java.io.IOException
address
-
java.io.IOException
public static boolean checkForManagerByAddressPair(java.net.InetSocketAddress localAddress, java.net.InetSocketAddress remoteAddress)
localAddress
- remoteAddress
-
public static boolean checkForShareableManagerByAddressPair(java.net.InetSocketAddress localAddress, java.net.InetSocketAddress remoteAddress)
localAddress
- remoteAddress
-
public static int getStaticThreadMonitorPeriod()
public static void setStaticThreadsMonitorPeriod(int period)
period
- protected static void shutdownThreads()
protected static void addToPendingActions(PendingAction pendingAction)
PendingAction
to the list of actions waiting to be executed.
pendingAction
- public void bind(java.net.InetSocketAddress address) throws java.io.IOException
address
-
java.io.IOException
public void connect(java.net.InetSocketAddress address, int timeout) throws java.io.IOException
address
- timeout
-
java.io.IOException
public MultiplexingInputStream registerServerSocket(java.net.ServerSocket serverSocket) throws java.io.IOException
VirtualServerSocket
as the one associated with this virtual socket group.
MultiplexingInputStream
for use by serverSocket.
java.io.IOException
public void unRegisterServerSocket(java.net.ServerSocket serverSocket) throws java.io.IOException
VirtualServerSocket
is leaving this virtual socket group.
serverSocket
-
java.io.IOException
public MultiplexingInputStream registerSocket(VirtualSocket socket) throws java.io.IOException
VirtualSocket
to this virtual socket group.
socket
-
MultiplexingInputStream
for use by socket
java.io.IOException
public void unRegisterSocket(VirtualSocket socket) throws java.io.IOException
VirtualSocket
is leaving a virtual socket group.
socket
-
java.io.IOException
public void registerRemoteServerSocket() throws java.io.IOException
VirtualServerSocket
belongs the virtual socket group at the
remote end of the connection. This virtual socket groupD becomes "joinable", in the
sense that a new VirtualSocket
VirtualServerSocket
at the other end of the connection to create a remote peer for
v
.
java.io.IOException
public void unRegisterRemoteServerSocket()
VirtualServeSocket
at the remote end of
this connection. This virtual socket group will no longer be "joinable".
(See registerRemoteServerSocket().)
public void setCreatedForRemoteServerSocket()
public boolean isRemoteServerSocketRegistered()
public boolean waitForRemoteServerSocketRegistered()
public void incrementReferences() throws java.io.IOException
MultiplexingManager
.
java.io.IOException
public void decrementReferences() throws java.io.IOException
MultiplexingManager
.
java.io.IOException
public java.util.Collection getAllOutputStreams()
public java.io.OutputStream getDeadLetterOutputStream()
OutputStream
to use when corrupted InputStream gives no known "mailbox"
public java.io.InputStream getInputStream()
InputStream
of real socket
public java.io.OutputStream getOutputStream()
OutputStream
of real socket
public MultiplexingInputStream getAnInputStream(SocketId socketId, VirtualSocket socket) throws java.io.IOException
InputStream
for a VirtualSocket
.
socketId
- socket
-
java.io.IOException
public GrowablePipedOutputStream getAnOutputStream(SocketId socketId)
OutputStrem
for a VirtualSocket
.
socketId
-
public MultiplexingOutputStream getAnOutputStream(VirtualSocket socket, SocketId socketId)
socketId
-
public GrowablePipedOutputStream getConnectedOutputStream(SocketId socketId) throws java.io.IOException
GrowablePipedOutputStream
that is connected to a
MultiplexingInputStream
.
It will create the MultiplexingInputStream
if necessary. This method exists to
allow InputMultiplexor
to get a place to put bytes directed to an unrecognized
SocketId, which might be necessary if the remote socket starts writing before this
end of the connection is ready. Originally, we had a three step handshake, in which
(1) the client socket sent a "connect" message, (2) the server socket sent a "connected"
message, and (3) the client socket sent a "connect verify" message. In the interests
of performance we eliminated the final step.
socketId
-
java.io.IOException
public java.io.OutputStream getBackchannelOutputStream()
public javax.net.ssl.HandshakeCompletedEvent getHandshakeCompletedEvent()
public OutputMultiplexor getOutputMultiplexor()
public java.io.OutputStream getOutputStreamByLocalSocket(SocketId socketId)
socketId
-
public Protocol getProtocol()
public java.net.ServerSocket getServerSocket()
public java.net.Socket getSocket()
public VirtualSocket getSocketByLocalPort(SocketId socketId)
socketId
-
public javax.net.SocketFactory getSocketFactory()
public void handshakeCompleted(javax.net.ssl.HandshakeCompletedEvent event)
HandshakeCompletedListener
interface.
handshakeCompleted
in interface javax.net.ssl.HandshakeCompletedListener
public boolean isBound()
public boolean isConnected()
public boolean isServerSocketRegistered()
public boolean isShutdown()
public boolean isSocketRegistered(SocketId socketId)
socketId
-
public boolean respondToShutdownRequest()
public void setSocketFactory(javax.net.SocketFactory socketFactory)
socketFactory
- public int getShutdownMonitorPeriod()
public int getShutdownRefusalsMaximum()
public int getShutdownRequestTimeout()
public void setShutdownRequestTimeout(int timeout)
timeout
- public void setShutdownRefusalsMaximum(int maximum)
maximum
- public void setShutdownMonitorPeriod(int period)
period
- public void outputFlushed()
OutputMultiplexor.OutputMultiplexorClient
outputFlushed
in interface OutputMultiplexor.OutputMultiplexorClient
public java.lang.String toString()
toString
in class java.lang.Object
protected java.net.Socket createSocket(java.net.InetSocketAddress endpoint, int timeout) throws java.io.IOException
java.io.IOException
protected java.net.Socket createSocket() throws java.io.IOException
java.io.IOException
protected void registerByLocalAddress(java.net.InetSocketAddress address)
address
- protected void unregisterByLocalAddress()
protected void registerByRemoteAddress(java.net.InetSocketAddress address)
address
- protected void unregisterByRemoteAddress()
protected void registerShareable(java.net.InetSocketAddress address)
address
- protected void unregisterShareable()
protected void unregisterAllMaps()
protected void removeAnInputStream(SocketId socketId)
socketId
- protected void setReadException(java.io.IOException e)
protected void setWriteException(java.io.IOException e)
protected void notifySocketsOfException()
protected void setEOF()
protected void shutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |