1 package org.openslx.imagemaster.serversession;
3 import java.util.Iterator;
4 import java.util.LinkedHashMap;
7 import java.util.concurrent.TimeUnit;
9 import org.
openslx.bwlp.thrift.iface.ServerSessionData;
20 private static final Map<String, ServerSession>
serverSessions =
new LinkedHashMap<String, ServerSession>();
24 final String sessionId =
Hash.
sha256( UUID.randomUUID().toString() );
27 serverSessions.put( sessionId, serverSession );
29 return new ServerSessionData( sessionId );
36 serverSession = serverSessions.get( sessionId );
38 if ( serverSession == null || serverSession.
timedOut() ) {
46 QuickTimer.scheduleAtFixedDelay(
new Task() {
51 Iterator<ServerSession> it = serverSessions.values().iterator();
52 while ( it.hasNext() ) {
60 }, 911, TimeUnit.MINUTES.toMillis( 14 ) );
static ServerSessionData addSession(ServerSession serverSession)
Manages all server sessions and kicks timed out sessions.
static ServerSession getSession(String sessionId)
synchronized boolean timedOut()
static String sha256(final byte[] bytes)
Compute sha256 hash of given binary data.
static final Map< String, ServerSession > serverSessions
synchronized void refresh()
Holds the session id of the server and manages the timeout.