public class PooledSocket
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
acquired()
Stores acquisition-infos.
|
void |
auth()
Tries to authenticate at the server by sending our session-id.
|
void |
bye()
Signs off this PooledSocket cleanly at the server and closes its socket
after reading a final protocol-magic.
|
void |
checkFreeSocket()
Checks this PooledSocket's connection to the server by sending a
ping-command to the server and reading a protocol-magic afterwards
without updating the last-used date of the socket.
|
void |
close()
Closes this PooledSocket, possibly raising an IO-Exception that may have been signalled during closing.
|
void |
closeLater()
Marks this PooledSocket as to be closed.
|
void |
closeNT()
Closes this PooledSocket and eats up any IO-Exception that may have been signalled during closing.
|
java.lang.RuntimeException |
getAcquiredAt() |
java.lang.Thread |
getAcquiredFrom()
Returns the Thread this PooledSocket was acquired from, if it has not yet been garbage collected.
|
long |
getAcquiredWhen() |
java.lang.RuntimeException |
getCreatedAt() |
long |
getCreatedWhen() |
CryptoHandlerI |
getCryptoHandler()
Retrieves a
CryptoHandlerI object from the
BackendProtocolServer . |
long |
getLastUsed() |
java.lang.String |
getLogPrefix() |
int |
getPid() |
SocketPool |
getSocketPool() |
TransportI |
getTransport()
Exposes the used TransportI in this PooledSocket.
|
boolean |
isAuthenticated()
This class is needed for sorting the PooledSocket correctly
into the
de.ipcon.db.SocketPool 's PriorityBlockingQueue. |
boolean |
isClosed() |
int |
ping()
Sends a test-command to the server and waits a maximum of 10 seconds for the expected answer.
|
void |
readMagic()
Tries to read the defined protocol-magic from the input in max.
|
void |
readMagic(boolean updateLastUsed) |
void |
released()
Resets the stored acquisition-infos.
|
void |
reset() |
void |
rinse() |
void |
setAcquiredAt(java.lang.RuntimeException $15) |
void |
setAcquiredWhen(long $16) |
void |
setAuthenticated(boolean $13) |
void |
setCreatedAt(java.lang.RuntimeException $18) |
void |
setCreatedWhen(long $17) |
void |
setLastUsed(long $14) |
void |
setLogPrefix(java.lang.String $21) |
void |
setPid(int $19) |
void |
setSocketPool(SocketPool $20) |
boolean |
shouldBeClosed()
Returns true, if this PooledSocket is closed or was marked as to be closed.
|
java.lang.String |
toString() |
long |
validUntil() |
boolean |
wasRecentlyUsed()
Returns true if this PooledSocket was "recently" used (currently 150s), false otherwise.
|
public TransportI getTransport()
public java.lang.Thread getAcquiredFrom()
public void acquired()
public void released()
public void rinse()
public boolean wasRecentlyUsed()
public long validUntil()
public CryptoHandlerI getCryptoHandler() throws ServerConnectionException
CryptoHandlerI
object from the
BackendProtocolServer
.
Does not read a protocol-magic afterwards!
May signal a de.ipcon.db.FatalServerConnectionException
if anything else than a
CryptoHandlerI
was received from the server.
In case of errors the socket is closed.
Called from de.ipcon.db.SocketPool#initSession
.ServerConnectionException
de.ipcon.db.SocketPool
,
BackendProtocolServer
public void auth() throws ServerConnectionException
BackendProtocolServer
will respond with an OK-answer
and the PID of the new BackendCommandHandler-thread, that was built for this PooledSocket's
requests to the server, if the session is known and still valid and with a
NOK-answer otherwise.
Reads a protocol-magic afterwards in any case.
May signal a de.ipcon.db.FatalServerConnectionException
if authentication failed
or a de.ipcon.db.ServerConnectionException
if the conncetion timed out.
In case of errors the socket is closed.
Called from de.ipcon.db.SocketPool#getSocket
and de.ipcon.db.SocketPool#pollFreeSocket
ServerConnectionException
de.ipcon.db.SocketPool
,
BackendProtocolServer
public int ping() throws ServerConnectionException
ServerConnectionException
de.ipcon.db.SocketPool
,
de.ipcon.db.BackendConnection
,
BackendProtocolServer
public void checkFreeSocket() throws ServerConnectionException
ServerConnectionException
de.ipcon.db.SocketPool$FreeSocketChecker
public void bye()
de.ipcon.db.SocketPool
public void close() throws java.io.IOException
java.io.IOException
de.ipcon.db.SocketPool
public void closeNT()
de.ipcon.db.SocketPool
public void closeLater()
de.ipcon.db.SocketPool#recycleOldSockets
.
Called from de.ipcon.db.SocketPool#freeSocket
and de.ipcon.db.BackendQueryResults
.de.ipcon.db.SocketPool
,
de.ipcon.db.BackendQueryResults
public boolean shouldBeClosed()
de.ipcon.db.SocketPool#recycleOldSockets
.de.ipcon.db.SocketPool
public boolean isClosed()
public void reset() throws java.io.IOException
java.io.IOException
public void readMagic() throws java.io.IOException
TIMEOUT_MILLISECS_FOR_READ_MAGIC
ms.
Signals an IO-Exception if any other value was read.
Signals a de.ipcon.db.ServerConnectionException
if a timeout occurred.updateLastUsed
- a boolean defining if the last-used-timestamp
shall be updated upon reading the protocol-magic (defaults to true)java.io.IOException
de.ipcon.db.SocketPool
,
de.ipcon.db.BackendConnection
,
BackendProtocolServer
public void readMagic(boolean updateLastUsed) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isAuthenticated()
de.ipcon.db.SocketPool
's PriorityBlockingQueue.de.ipcon.db.SocketPool
public void setAuthenticated(boolean $13)
public long getLastUsed()
public void setLastUsed(long $14)
public java.lang.RuntimeException getAcquiredAt()
public void setAcquiredAt(java.lang.RuntimeException $15)
public long getAcquiredWhen()
public void setAcquiredWhen(long $16)
public long getCreatedWhen()
public void setCreatedWhen(long $17)
public java.lang.RuntimeException getCreatedAt()
public void setCreatedAt(java.lang.RuntimeException $18)
public int getPid()
public void setPid(int $19)
public SocketPool getSocketPool()
public void setSocketPool(SocketPool $20)
public java.lang.String getLogPrefix()
public void setLogPrefix(java.lang.String $21)
Copyright © 2000-2024 OAshi S.à r.l. All Rights Reserved.