OpenSslClientSessionCache Class — netty Architecture
Architecture documentation for the OpenSslClientSessionCache class in OpenSslClientSessionCache.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d994a42d_c2fd_7695_2456_467a8b045cb7["OpenSslClientSessionCache"] 8932cd5d_eee0_412c_f52c_ecf04a164041["OpenSslClientSessionCache.java"] d994a42d_c2fd_7695_2456_467a8b045cb7 -->|defined in| 8932cd5d_eee0_412c_f52c_ecf04a164041 efffd4fe_1bf4_dc02_d15c_f60c3d7cd0e2["OpenSslClientSessionCache()"] d994a42d_c2fd_7695_2456_467a8b045cb7 -->|method| efffd4fe_1bf4_dc02_d15c_f60c3d7cd0e2 e5efcea3_4707_d7c8_c03d_e3b5c5dd8922["sessionCreated()"] d994a42d_c2fd_7695_2456_467a8b045cb7 -->|method| e5efcea3_4707_d7c8_c03d_e3b5c5dd8922 bb76346f_317a_10d5_828f_ebff45fb3718["sessionRemoved()"] d994a42d_c2fd_7695_2456_467a8b045cb7 -->|method| bb76346f_317a_10d5_828f_ebff45fb3718 3464953c_f03e_be1f_7bcc_18c2f7cfc2aa["setSession()"] d994a42d_c2fd_7695_2456_467a8b045cb7 -->|method| 3464953c_f03e_be1f_7bcc_18c2f7cfc2aa cfd374c6_6ec8_24d4_a667_0f3e52f345c9["HostPort()"] d994a42d_c2fd_7695_2456_467a8b045cb7 -->|method| cfd374c6_6ec8_24d4_a667_0f3e52f345c9 b92a055a_4c37_f5f8_c997_68bbd4cead73["clear()"] d994a42d_c2fd_7695_2456_467a8b045cb7 -->|method| b92a055a_4c37_f5f8_c997_68bbd4cead73
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/ssl/OpenSslClientSessionCache.java lines 31–188
final class OpenSslClientSessionCache extends OpenSslSessionCache {
private final Map<HostPort, Set<NativeSslSession>> sessions = new HashMap<>();
OpenSslClientSessionCache(Map<Long, ReferenceCountedOpenSslEngine> engines) {
super(engines);
}
@Override
protected boolean sessionCreated(NativeSslSession session) {
assert Thread.holdsLock(this);
HostPort hostPort = keyFor(session.getPeerHost(), session.getPeerPort());
if (hostPort == null) {
return false;
}
Set<NativeSslSession> sessionsForHost = sessions.get(hostPort);
if (sessionsForHost == null) {
// Let's start with something small as usually the server does not provide too many of these per hostPort
// mapping.
sessionsForHost = new HashSet<>(4);
sessions.put(hostPort, sessionsForHost);
}
sessionsForHost.add(session);
return true;
}
@Override
protected void sessionRemoved(NativeSslSession session) {
assert Thread.holdsLock(this);
HostPort hostPort = keyFor(session.getPeerHost(), session.getPeerPort());
if (hostPort == null) {
return;
}
Set<NativeSslSession> sessionsForHost = sessions.get(hostPort);
if (sessionsForHost != null) {
sessionsForHost.remove(session);
if (sessionsForHost.isEmpty()) {
sessions.remove(hostPort);
}
}
}
@Override
boolean setSession(long ssl, OpenSslInternalSession session, String host, int port) {
HostPort hostPort = keyFor(host, port);
if (hostPort == null) {
return false;
}
NativeSslSession nativeSslSession = null;
final boolean reused;
boolean singleUsed = false;
synchronized (this) {
Set<NativeSslSession> sessionsForHost = sessions.get(hostPort);
if (sessionsForHost == null) {
return false;
}
if (sessionsForHost.isEmpty()) {
sessions.remove(hostPort);
// There is no session that we can use.
return false;
}
List<NativeSslSession> toBeRemoved = null;
// Loop through all the sessions that might be usable and check if we can use one of these.
for (NativeSslSession sslSession : sessionsForHost) {
if (sslSession.isValid()) {
nativeSslSession = sslSession;
break;
} else {
if (toBeRemoved == null) {
toBeRemoved = new ArrayList<>(2);
}
toBeRemoved.add(sslSession);
}
}
// Remove everything that is not valid anymore
if (toBeRemoved != null) {
for (NativeSslSession sslSession : toBeRemoved) {
removeSessionWithId(sslSession.sessionId());
}
}
Source
Frequently Asked Questions
What is the OpenSslClientSessionCache class?
OpenSslClientSessionCache is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/OpenSslClientSessionCache.java.
Where is OpenSslClientSessionCache defined?
OpenSslClientSessionCache is defined in handler/src/main/java/io/netty/handler/ssl/OpenSslClientSessionCache.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free