Class ConnectionImpl
java.lang.Object
com.sun.corba.ee.impl.transport.EventHandlerBase
com.sun.corba.ee.impl.transport.ConnectionImpl
- All Implemented Interfaces:
Connection, Work, Connection, EventHandler
- Direct Known Subclasses:
SocketFactoryConnectionImpl
- Author:
- Harold Carr Note: this is the version WITHOUT the purgeCalls changes. The changes are in the 1.106 version, which is saved as SocketOrChannelConnectionImpl.1.106.sjava.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Acceptorprotected ByteBufferprotected CachedCodeBaseprotected MessageMediatorprotected IORprotected CodeSetComponentInfo.CodeSetContextprotected ConnectionCacheprotected ContactInfoprotected com.sun.corba.ee.impl.transport.ConnectionImpl.Dispatcherprotected longprotected ConcurrentHashMap<RequestId, Queue<MessageMediator>> protected booleanprotected booleanprotected AtomicIntegerprotected ResponseWaitingRoomprotected MessageMediatorprotected intprotected Socketprotected SocketChannelprotected final Objectprotected TcpTimeoutsprotected longprotected TemporarySelectorprotected final Objectprotected static final ORBUtilSystemExceptionprotected final Objectprotected booleanFields inherited from class EventHandlerBase
orb, selectionKey, useSelectThreadToWait, useWorkerThreadForEvent, workFields inherited from interface Connection
ABORT, CLOSE_RECVD, CLOSE_SENT, ESTABLISHED, OPENING -
Constructor Summary
ConstructorsModifierConstructorDescriptionConnectionImpl(ORB orb) protectedConnectionImpl(ORB orb, boolean useSelectThreadToWait, boolean useWorkerThread) ConnectionImpl(ORB orb, Acceptor acceptor, Socket socket) ConnectionImpl(ORB orb, ContactInfo contactInfo, String socketType, String hostname, int port) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidvoidclientRequestMapGet(int requestId) voidclose()Note:it is possible for this to be called more than oncevoidClean up all connection resources.protected voidprotected voidprotected final voiddefineSocket(boolean useSelectThreadToWait, Socket socket) protected voidvoiddoWork()This method denotes the actual work that is done by the work item.extractAndProcessMessages(ByteBuffer byteBuffer) final CodeBasefinal IORlongThis methods gets the time in millis in the work item, when this work item was enqueued in the work queue.getFragmentList(RequestId corbaRequestId) intgetName()/////////////////////////////////////////////////int/////////////////////////////////////////////////protected intgetState()protected StringgetStateString(int state) protected TemporarySelectorlongTimestamps are used for connection management, in particular, for reclaiming idleConnections.booleanbooleanisBusy()Indicates if theConnectionis in the process of sending or receiving a message.booleanisClosed()Indicates if theConnectionis closed.booleanbooleanisServer()Indicates whether a CorbaContactInfo or CorbaAcceptor created theConnection.protected intvoidpurgeCalls(SystemException systemException, boolean die, boolean lockHeld) Wake up the outstanding requests on the connection, and hand them COMM_FAILURE exception with a given minor code.booleanread()Called to read incoming messages.voidregisterWaiter(MessageMediator messageMediator) Register an invocation's CorbaMessageMediator with theConnection.voidremoveFragmentList(RequestId corbaRequestId) voidsendCancelRequest(GIOPVersion giopVersion, int requestId) Send a CancelRequest message.voidsendCancelRequestWithLock(GIOPVersion giopVersion, int requestId) voidsendCloseConnection(GIOPVersion giopVersion) ********************************************************************** The following methods are for dealing with Connection cleaning for better scalability of servers in high network load conditionsprotected voidsendHelper(GIOPVersion giopVersion, Message msg) voidsendMessageError(GIOPVersion giopVersion) voidsendWithoutLock(CDROutputObject outputObject) voidvoidserverRequestMapGet(int reqId) voidserverRequestMapPut(int reqId, MessageMediator messageMediator) voidserverRequestMapRemove(int reqId) voidIt is possible for a Close Connection to have been * sent here, but we will not check for this.voidfinal voidsetCodeBaseIOR(IOR ior) voidvoidsetConnectionCache(ConnectionCache connectionCache) voidsetEnqueueTime(long timeInMillis) This methods sets the time in millis in the work item, when this work item was enqueued in the work queue.voidprotected voidsetState(int state) voidThe "state" of theConnection.protected voidsetTcpTimeouts(TcpTimeouts tcpTimeouts) voidsetTimeStamp(long time) Timestamps are used for connection management, in particular, for reclaiming idleConnections.voidsetUseSelectThreadToWait(boolean x) /////////////////////////////////////////////////boolean/////////////////////////////////////////////////booleanUsed to determine if theConnectionshould register with the CorbaTransportManager Selector to handle read events.toString()voidunregisterWaiter(MessageMediator messageMediator) Unregister an invocation's * CorbaMessageMediator with theConnection.waitForResponse(MessageMediator messageMediator) If a message expect's a response then this method is called.voidwrite(ByteBuffer byteBuffer) voidSets the writeLock for this connection.voidRelease a write lock on theConnection.Methods inherited from class EventHandlerBase
getSelectionKey, getWork, handleEvent, setSelectionKey, setUseWorkerThreadForEvent, setWork, shouldUseSelectThreadToWait, shouldUseWorkerThreadForEvent
-
Field Details
-
wrapper
-
socketChannel
-
byteBuffer
-
enqueueTime
protected long enqueueTime -
contactInfo
-
acceptor
-
connectionCache
-
socket
-
timeStamp
protected long timeStamp -
isServer
protected boolean isServer -
requestId
-
responseWaitingRoom
-
stateEvent
-
writeEvent
-
writeLocked
protected boolean writeLocked -
serverRequestCount
protected int serverRequestCount -
postInitialContexts
protected boolean postInitialContexts -
codeBaseServerIOR
-
cachedCodeBase
-
tcpTimeouts
-
tmpReadSelector
-
tmpReadSelectorLock
-
dispatcher
protected com.sun.corba.ee.impl.transport.ConnectionImpl.Dispatcher dispatcher -
fragmentMap
-
codeSetContext
-
clientReply_1_1
-
serverRequest_1_1
-
-
Constructor Details
-
ConnectionImpl
-
ConnectionImpl
-
ConnectionImpl
public ConnectionImpl(ORB orb, ContactInfo contactInfo, String socketType, String hostname, int port) -
ConnectionImpl
-
-
Method Details
-
getSocketChannel
- Specified by:
getSocketChannelin interfaceConnection
-
defineSocket
- Throws:
IOException
-
shouldRegisterReadEvent
public boolean shouldRegisterReadEvent()/////////////////////////////////////////////////- Specified by:
shouldRegisterReadEventin interfaceConnection- Returns:
trueif it should be registered.
-
shouldRegisterServerReadEvent
public boolean shouldRegisterServerReadEvent()Description copied from interface:ConnectionUsed to determine if theConnectionshould register with the CorbaTransportManager Selector to handle read events. For example, an HTTP transport would not register since the requesting thread would just block on read when waiting for the reply.- Specified by:
shouldRegisterServerReadEventin interfaceConnection- Returns:
trueif it should be registered.
-
read
public boolean read()Description copied from interface:ConnectionCalled to read incoming messages.- Specified by:
readin interfaceConnection- Returns:
trueif the thread calling read can be released.
-
hasSocketChannel
public boolean hasSocketChannel()- Specified by:
hasSocketChannelin interfaceConnection
-
write
- Specified by:
writein interfaceConnection- Throws:
IOException
-
close
public void close()Note:it is possible for this to be called more than once- Specified by:
closein interfaceConnection
-
closeConnectionResources
public void closeConnectionResources()Description copied from interface:ConnectionClean up all connection resources. Used when shutting down an ORB.- Specified by:
closeConnectionResourcesin interfaceConnection
-
closeSocketAndTemporarySelectors
protected void closeSocketAndTemporarySelectors() -
getAcceptor
- Specified by:
getAcceptorin interfaceConnection- Specified by:
getAcceptorin interfaceEventHandler
-
getContactInfo
- Specified by:
getContactInfoin interfaceConnection
-
getEventHandler
- Specified by:
getEventHandlerin interfaceConnection
-
isServer
public boolean isServer()Description copied from interface:ConnectionIndicates whether a CorbaContactInfo or CorbaAcceptor created theConnection.- Specified by:
isServerin interfaceConnection- Returns:
trueif a CorbaAcceptor created theConnection.
-
isClosed
public boolean isClosed()Description copied from interface:ConnectionIndicates if theConnectionis closed.- Specified by:
isClosedin interfaceConnection- Returns:
trueif theConnectionis closed.
-
isBusy
public boolean isBusy()Description copied from interface:ConnectionIndicates if theConnectionis in the process of sending or receiving a message.- Specified by:
isBusyin interfaceConnection- Returns:
trueif theConnectionis busy.
-
getTimeStamp
public long getTimeStamp()Description copied from interface:ConnectionTimestamps are used for connection management, in particular, for reclaiming idleConnections.- Specified by:
getTimeStampin interfaceConnection- Returns:
- the "time" the
Connectionwas last used.
-
setTimeStamp
public void setTimeStamp(long time) Description copied from interface:ConnectionTimestamps are used for connection management, in particular, for reclaiming idleConnections.- Specified by:
setTimeStampin interfaceConnection- Parameters:
time- - the "time" theConnectionwas last used.
-
getState
protected int getState() -
setState
protected void setState(int state) -
setState
Description copied from interface:ConnectionThe "state" of theConnection.- Specified by:
setStatein interfaceConnection- Parameters:
stateString- state to set
-
writeLock
public void writeLock()Sets the writeLock for this connection. If the writeLock is already set by someone else, block till the writeLock is released and can set by us. IMPORTANT: this connection's lock must be acquired before setting the writeLock and must be unlocked after setting the writeLock.- Specified by:
writeLockin interfaceConnection
-
writeUnlock
public void writeUnlock()Description copied from interface:ConnectionRelease a write lock on theConnection.- Specified by:
writeUnlockin interfaceConnection
-
sendWithoutLock
- Specified by:
sendWithoutLockin interfaceConnection
-
registerWaiter
Description copied from interface:ConnectionRegister an invocation's CorbaMessageMediator with theConnection. This is useful in protocols which support fragmentation.- Specified by:
registerWaiterin interfaceConnection- Parameters:
messageMediator- mediator to register
-
unregisterWaiter
Description copied from interface:ConnectionUnregister an invocation's * CorbaMessageMediator with theConnection.- Specified by:
unregisterWaiterin interfaceConnection- Parameters:
messageMediator- mediator to unregister
-
waitForResponse
Description copied from interface:ConnectionIf a message expect's a response then this method is called. This method might block on a read (e.g., HTTP), put the calling thread to sleep while another thread read's the response (e.g., GIOP), or it may use the calling thread to perform the server-side work (e.g., Solaris Doors).- Specified by:
waitForResponsein interfaceConnection- Parameters:
messageMediator- mediator to process- Returns:
- stream
-
setConnectionCache
- Specified by:
setConnectionCachein interfaceConnection
-
getConnectionCache
- Specified by:
getConnectionCachein interfaceConnection
-
setUseSelectThreadToWait
public void setUseSelectThreadToWait(boolean x) /////////////////////////////////////////////////- Specified by:
setUseSelectThreadToWaitin interfaceEventHandler- Overrides:
setUseSelectThreadToWaitin classEventHandlerBase
-
getChannel
- Specified by:
getChannelin interfaceEventHandler
-
getInterestOps
public int getInterestOps()- Specified by:
getInterestOpsin interfaceEventHandler
-
getConnection
- Specified by:
getConnectionin interfaceEventHandler
-
getName
-
doWork
-
setEnqueueTime
public void setEnqueueTime(long timeInMillis) Description copied from interface:WorkThis methods sets the time in millis in the work item, when this work item was enqueued in the work queue.- Specified by:
setEnqueueTimein interfaceWork
-
getEnqueueTime
public long getEnqueueTime()Description copied from interface:WorkThis methods gets the time in millis in the work item, when this work item was enqueued in the work queue.- Specified by:
getEnqueueTimein interfaceWork
-
getResponseWaitingRoom
/////////////////////////////////////////////////- Specified by:
getResponseWaitingRoomin interfaceConnection
-
serverRequestMapPut
- Specified by:
serverRequestMapPutin interfaceConnection
-
serverRequestMapGet
- Specified by:
serverRequestMapGetin interfaceConnection
-
serverRequestMapRemove
public void serverRequestMapRemove(int reqId) - Specified by:
serverRequestMapRemovein interfaceConnection
-
getFragmentList
- Specified by:
getFragmentListin interfaceConnection
-
removeFragmentList
- Specified by:
removeFragmentListin interfaceConnection
-
getSocket
- Specified by:
getSocketin interfaceConnection
-
serverRequestProcessingBegins
public void serverRequestProcessingBegins()It is possible for a Close Connection to have been * sent here, but we will not check for this. A "lazy" * Exception will be thrown in the Worker thread after the * incoming request has been processed even though the connection * is closed before the request is processed. This is o.k because * it is a boundary condition. To prevent it we would have to add * more locks which would reduce performance in the normal case.- Specified by:
serverRequestProcessingBeginsin interfaceConnection
-
serverRequestProcessingEnds
public void serverRequestProcessingEnds()- Specified by:
serverRequestProcessingEndsin interfaceConnection
-
getNextRequestId
public int getNextRequestId()- Specified by:
getNextRequestIdin interfaceConnection
-
getBroker
- Specified by:
getBrokerin interfaceConnection
-
getCodeSetContext
- Specified by:
getCodeSetContextin interfaceConnection
-
setCodeSetContext
- Specified by:
setCodeSetContextin interfaceConnection
-
clientRequestMapGet
- Specified by:
clientRequestMapGetin interfaceConnection
-
clientReply_1_1_Put
- Specified by:
clientReply_1_1_Putin interfaceConnection
-
clientReply_1_1_Get
- Specified by:
clientReply_1_1_Getin interfaceConnection
-
clientReply_1_1_Remove
public void clientReply_1_1_Remove()- Specified by:
clientReply_1_1_Removein interfaceConnection
-
serverRequest_1_1_Put
- Specified by:
serverRequest_1_1_Putin interfaceConnection
-
serverRequest_1_1_Get
- Specified by:
serverRequest_1_1_Getin interfaceConnection
-
serverRequest_1_1_Remove
public void serverRequest_1_1_Remove()- Specified by:
serverRequest_1_1_Removein interfaceConnection
-
getStateString
-
isPostInitialContexts
public boolean isPostInitialContexts()- Specified by:
isPostInitialContextsin interfaceConnection
-
setPostInitialContexts
public void setPostInitialContexts()- Specified by:
setPostInitialContextsin interfaceConnection
-
purgeCalls
Wake up the outstanding requests on the connection, and hand them COMM_FAILURE exception with a given minor code.Also, delete connection from connection table and stop the reader thread.
Note that this should only ever be called by the Reader thread for this connection.- Specified by:
purgeCallsin interfaceConnection- Parameters:
die- Kill the reader thread (this thread) before exiting.lockHeld- true if the calling thread holds the lock on the connection
-
sendCloseConnection
********************************************************************** The following methods are for dealing with Connection cleaning for better scalability of servers in high network load conditions. ************************************************************************- Specified by:
sendCloseConnectionin interfaceConnection- Throws:
IOException
-
sendMessageError
- Specified by:
sendMessageErrorin interfaceConnection- Throws:
IOException
-
sendCancelRequest
Send a CancelRequest message. This does not lock the connection, so the caller needs to ensure this method is called appropriately.- Specified by:
sendCancelRequestin interfaceConnection- Throws:
IOException- - could be due to abortive connection closure.
-
sendHelper
- Throws:
IOException
-
sendCancelRequestWithLock
- Specified by:
sendCancelRequestWithLockin interfaceConnection- Throws:
IOException
-
setCodeBaseIOR
- Specified by:
setCodeBaseIORin interfaceConnection
-
getCodeBaseIOR
- Specified by:
getCodeBaseIORin interfaceConnection
-
getCodeBase
- Specified by:
getCodeBasein interfaceConnection
-
setTcpTimeouts
-
doOptimizedReadStrategy
protected void doOptimizedReadStrategy() -
extractAndProcessMessages
-
blockingRead
protected void blockingRead() -
nonBlockingRead
protected int nonBlockingRead() -
getTemporaryReadSelector
- Throws:
IOException
-
closeTemporarySelectors
- Throws:
IOException
-
toString
-