Top Description Inners Fields Constructors Methods
sun.rmi.transport.tcp

public Class TCPTransport

extends Transport
Class Inheritance
Annotations
@SuppressWarnings:deprecation
Imports
java.lang.ref.Reference, .SoftReference, .WeakReference, java.lang.reflect.InvocationTargetException, .UndeclaredThrowableException, java.io.DataInputStream, .DataOutputStream, .IOException, .InputStream, .OutputStream, .BufferedInputStream, .BufferedOutputStream, java.net.InetAddress, .ServerSocket, .Socket, java.rmi.RemoteException, java.rmi.server.ExportException, .LogStream, .RMIFailureHandler, .RMISocketFactory, .RemoteCall, .ServerNotActiveException, .UID, java.security.AccessControlContext, .AccessController, .Permissions, .PrivilegedAction, .ProtectionDomain, java.util.ArrayList, .LinkedList, .List, .Map, .WeakHashMap, java.util.logging.Level, java.util.concurrent.ExecutorService, .RejectedExecutionException, .SynchronousQueue, .ThreadFactory, .ThreadPoolExecutor, .TimeUnit, java.util.concurrent.atomic.AtomicInteger, sun.rmi.runtime.Log, .NewThreadAction, sun.rmi.transport.Channel, .Connection, .DGCAckHandler, .Endpoint, .StreamRemoteCall, .Target, .Transport, .TransportConstants

TCPTransport is the socket-based implementation of the RMI Transport abstraction.
Authors
Ann Wollrath, Peter Jones

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
TCPTransport.AcceptLoop

Worker for accepting connections from a server socket.

private class
TCPTransport.ConnectionHandler

Services messages on accepted connection

Field Summary

Modifier and TypeField and Description
private final Map<TCPEndpoint, Reference<TCPChannel>>
channelTable

table mapping endpoints to channels

private static final AtomicInteger
connectionCount

total connections handled

private static final int
connectionReadTimeout

number of milliseconds in accepted-connection timeout.

private static final ExecutorService
connectionThreadPool

thread pool for connection handlers

pack-priv static final RMISocketFactory
private final LinkedList<TCPEndpoint>
epList

endpoints for this transport

private int
exportCount

number of objects exported on this transport

private static final int
maxConnectionThreads

maximum number of connection handler threads

private static final AccessControlContext
NOPERMS_ACC

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
an AccessControlContext with no permissions
private ServerSocket
server

server socket for this transport

pack-priv static final Log
private static final ThreadLocal<TCPTransport.ConnectionHandler>
threadConnectionHandler

client host for the current thread's connection

private static final long
threadKeepAliveTime

keep alive time for idle connection handler threads

Constructor Summary

AccessConstructor and Description
pack-priv
TCPTransport(LinkedList<TCPEndpoint> epList)

Constructs a TCPTransport.

Method Summary

Modifier and TypeMethod and Description
protected void
checkAcceptPermission(AccessControlContext acc)

Implements abstract sun.rmi.transport.Transport.checkAcceptPermission.

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

Verify that the current access control context has permission to accept the connection being dispatched by the current thread.

private static void
closeSocket(Socket sock)

close socket and eat exception

private static AccessControlContext
createNopermsAcc()
References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

private void
decrementExportCount()

Decrements the count of exported objects, closing the current server socket if the count reaches zero.

public void
exportObject(Target target)

Overrides sun.rmi.transport.Transport.exportObject.

Export the object so that it can accept incoming calls.

public void
free(Endpoint ep)

Implements abstract sun.rmi.transport.Transport.free.

Removes the Channel that generates connections to the endpoint ep.

public TCPChannel

Returns:

the channel or null if the transport cannot generate connections to this endpoint
getChannel
(Endpoint
the endpoint to which connections will be generated.
ep
)

Implements abstract sun.rmi.transport.Transport.getChannel.

Returns a Channel that generates connections to the endpoint ep.

public static String
getClientHost()

Returns the client host for the current thread's connection.

private TCPEndpoint
pack-priv void
handleMessages(Connection conn, boolean persistent)

handleMessages decodes transport operations and handles messages appropriately.

private void
listen()

Listen on transport's endpoint.

public void
shedConnectionCaches()

Closes all cached connections in every channel subordinated to this transport.

protected synchronized void
targetUnexported()

Overrides sun.rmi.transport.Transport.targetUnexported.

Invoked when an object that was exported on this transport has become unexported, either by being garbage collected or by being explicitly unexported.

Inherited from sun.rmi.transport.Transport:
serviceCall

Field Detail

channelTableback to summary
private final Map<TCPEndpoint, Reference<TCPChannel>> channelTable

table mapping endpoints to channels

connectionCountback to summary
private static final AtomicInteger connectionCount

total connections handled

connectionReadTimeoutback to summary
private static final int connectionReadTimeout

number of milliseconds in accepted-connection timeout.

Warning

this should be greater than 15 seconds (the client-side timeout), and defaults to 2 hours. The maximum representable value is slightly more than 24 days and 20 hours.

Annotations
@SuppressWarnings:removal
connectionThreadPoolback to summary
private static final ExecutorService connectionThreadPool

thread pool for connection handlers

defaultSocketFactoryback to summary
pack-priv static final RMISocketFactory defaultSocketFactory
epListback to summary
private final LinkedList<TCPEndpoint> epList

endpoints for this transport

exportCountback to summary
private int exportCount

number of objects exported on this transport

maxConnectionThreadsback to summary
private static final int maxConnectionThreads

maximum number of connection handler threads

Annotations
@SuppressWarnings:removal
NOPERMS_ACCback to summary
private static final AccessControlContext NOPERMS_ACC

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

an AccessControlContext with no permissions

Annotations
@SuppressWarnings:removal
serverback to summary
private ServerSocket server

server socket for this transport

tcpLogback to summary
pack-priv static final Log tcpLog
Annotations
@SuppressWarnings:removal
threadConnectionHandlerback to summary
private static final ThreadLocal<TCPTransport.ConnectionHandler> threadConnectionHandler

client host for the current thread's connection

threadKeepAliveTimeback to summary
private static final long threadKeepAliveTime

keep alive time for idle connection handler threads

Annotations
@SuppressWarnings:removal

Constructor Detail

TCPTransportback to summary
pack-priv TCPTransport(LinkedList<TCPEndpoint> epList)

Constructs a TCPTransport.

Method Detail

checkAcceptPermissionback to summary
protected void checkAcceptPermission(AccessControlContext acc)

Implements abstract sun.rmi.transport.Transport.checkAcceptPermission.

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Verify that the current access control context has permission to accept the connection being dispatched by the current thread.

closeSocketback to summary
private static void closeSocket(Socket sock)

close socket and eat exception

createNopermsAccback to summary
private static AccessControlContext createNopermsAcc()

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@SuppressWarnings:removal
decrementExportCountback to summary
private void decrementExportCount()

Decrements the count of exported objects, closing the current server socket if the count reaches zero.

exportObjectback to summary
public void exportObject(Target target) throws RemoteException

Overrides sun.rmi.transport.Transport.exportObject.

Export the object so that it can accept incoming calls.

freeback to summary
public void free(Endpoint ep)

Implements abstract sun.rmi.transport.Transport.free.

Removes the Channel that generates connections to the endpoint ep.

getChannelback to summary
public TCPChannel getChannel(Endpoint ep)

Implements abstract sun.rmi.transport.Transport.getChannel.

Returns a Channel that generates connections to the endpoint ep. A Channel is an object that creates and manages connections of a particular type to some particular address space.

Parameters
ep:Endpoint

the endpoint to which connections will be generated.

Returns:TCPChannel

the channel or null if the transport cannot generate connections to this endpoint

getClientHostback to summary
public static String getClientHost() throws ServerNotActiveException

Returns the client host for the current thread's connection. Throws ServerNotActiveException if no connection is active for this thread.

getEndpointback to summary
private TCPEndpoint getEndpoint()
handleMessagesback to summary
pack-priv void handleMessages(Connection conn, boolean persistent)

handleMessages decodes transport operations and handles messages appropriately. If an exception occurs during message handling, the socket is closed.

listenback to summary
private void listen() throws RemoteException

Listen on transport's endpoint.

shedConnectionCachesback to summary
public void shedConnectionCaches()

Closes all cached connections in every channel subordinated to this transport. Currently, this only closes outgoing connections.

targetUnexportedback to summary
protected synchronized void targetUnexported()

Overrides sun.rmi.transport.Transport.targetUnexported.

Doc from sun.rmi.transport.Transport.targetUnexported.

Invoked when an object that was exported on this transport has become unexported, either by being garbage collected or by being explicitly unexported.

sun.rmi.transport.tcp back to summary

private Class TCPTransport.AcceptLoop

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Worker for accepting connections from a server socket.

Field Summary

Modifier and TypeField and Description
private long
private int
private final ServerSocket

Constructor Summary

AccessConstructor and Description
pack-priv
AcceptLoop(ServerSocket serverSocket)

Method Summary

Modifier and TypeMethod and Description
private boolean
continueAfterAcceptFailure(Throwable t)

Returns true if the accept loop should continue after the specified exception has been caught, or false if the accept loop should terminate (closing the server socket).

private void
executeAcceptLoop()

Accepts connections from the server socket and executes handlers for them in the thread pool.

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

private void
throttleLoopOnException()

Throttles the accept loop after an exception has been caught: if a burst of 10 exceptions in 5 seconds occurs, then wait for 10 seconds to curb busy CPU usage.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lastExceptionTimeback to summary
private long lastExceptionTime
recentExceptionCountback to summary
private int recentExceptionCount
serverSocketback to summary
private final ServerSocket serverSocket

Constructor Detail

AcceptLoopback to summary
pack-priv AcceptLoop(ServerSocket serverSocket)

Method Detail

continueAfterAcceptFailureback to summary
private boolean continueAfterAcceptFailure(Throwable t)

Returns true if the accept loop should continue after the specified exception has been caught, or false if the accept loop should terminate (closing the server socket). If there is an RMIFailureHandler, this method returns the result of passing the specified exception to it; otherwise, this method always returns true, after sleeping to throttle the accept loop if necessary.

executeAcceptLoopback to summary
private void executeAcceptLoop()

Accepts connections from the server socket and executes handlers for them in the thread pool.

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

throttleLoopOnExceptionback to summary
private void throttleLoopOnException()

Throttles the accept loop after an exception has been caught: if a burst of 10 exceptions in 5 seconds occurs, then wait for 10 seconds to curb busy CPU usage.

sun.rmi.transport.tcp back to summary

private Class TCPTransport.ConnectionHandler

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Services messages on accepted connection

Field Summary

Modifier and TypeField and Description
private Map<AccessControlContext, Reference<AccessControlContext>>
authCache

cache of accept-authorized AccessControlContexts

private SecurityManager
cacheSecurityManager

References Deprecated SecurityManager is deprecated or references (maybe indirectly) at least one deprecated element.
security manager which authorized contexts in authCache
private AccessControlContext
okContext

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
most recently accept-authorized AccessControlContext
private static final int
POST

int value of "POST" in ASCII (Java's specified data formats make this once-reviled tactic again socially acceptable)

private String
private Socket

Constructor Summary

AccessConstructor and Description
pack-priv
ConnectionHandler(Socket socket, String remoteHost)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
checkAcceptPermission(SecurityManager sm, AccessControlContext acc)
References Deprecated SecurityManager and AccessControlContext are deprecated or reference (maybe indirectly) at least one deprecated element.

Verify that the given AccessControlContext has permission to accept this connection.

pack-priv String
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

private void
run0()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

authCacheback to summary
private Map<AccessControlContext, Reference<AccessControlContext>> authCache

cache of accept-authorized AccessControlContexts

Annotations
@SuppressWarnings:removal
cacheSecurityManagerback to summary
private SecurityManager cacheSecurityManager

References Deprecated

SecurityManager is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

security manager which authorized contexts in authCache

Annotations
@SuppressWarnings:removal
okContextback to summary
private AccessControlContext okContext

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

most recently accept-authorized AccessControlContext

Annotations
@SuppressWarnings:removal
POSTback to summary
private static final int POST

int value of "POST" in ASCII (Java's specified data formats make this once-reviled tactic again socially acceptable)

remoteHostback to summary
private String remoteHost
socketback to summary
private Socket socket

Constructor Detail

ConnectionHandlerback to summary
pack-priv ConnectionHandler(Socket socket, String remoteHost)

Method Detail

checkAcceptPermissionback to summary
pack-priv void checkAcceptPermission(SecurityManager sm, AccessControlContext acc)

References Deprecated

SecurityManager and AccessControlContext are deprecated or reference (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Verify that the given AccessControlContext has permission to accept this connection.

Annotations
@SuppressWarnings:removal
getClientHostback to summary
pack-priv String getClientHost()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@SuppressWarnings:removal
run0back to summary
private void run0()
Annotations
@SuppressWarnings:fallthrough