예제 #1
0
 /// <summary>
 /// Gets an active session id using the supplementary session id
 /// </summary>
 /// <param name="sessionId"></param>
 /// <returns></returns>
 internal Option <SessionId> GetSessionId(SupplementarySessionId sessionId) =>
 (from ses in sessions
  from vector in ses.Value.Data.Find(SupplementarySessionId.Key)
  from v in vector.Vector
      where v is SupplementarySessionId &&
  ((SupplementarySessionId)v).Value == sessionId.Value
  select ses.Key).HeadOrNone();
예제 #2
0
            /// <summary>
            /// update session id or supplementary sessionId
            /// </summary>
            /// <param name="sessionId"></param>
            /// <param name="suppSessionId"></param>
            /// <returns></returns>
            internal LanguageExt.Unit Update(SessionId sessionId, SupplementarySessionId suppSessionId)
            {
                //remove old supp-sessions:
                Remove(sessionId);
                lock (sync)
                {
                    suppToSession = suppToSession.AddOrUpdate(suppSessionId, sessionId);
                    sessionToSupp = sessionToSupp.AddOrUpdate(sessionId, suppSessionId);
                }

                return(unit);
            }
예제 #3
0
 internal static Option <SessionId> getSessionIdFromSuppMap(ICluster cluster, SupplementarySessionId sessionId) =>
 cluster.GetHashField <string>(suppToSessionKey, sessionId.Value).Map(v => new SessionId(v));
예제 #4
0
        internal static LanguageExt.Unit setSuppSessionInSuppMap(ICluster cluster, SessionId sessionId, SupplementarySessionId suppSessionId)
        {
            //delete any old supp-sessions to keep in sync
            removeSessionIdFromSuppMap(cluster, sessionId);

            cluster.HashFieldAddOrUpdate(sessionToSuppKey, sessionId.Value, suppSessionId.Value);
            cluster.HashFieldAddOrUpdate(suppToSessionKey, suppSessionId.Value, sessionId.Value);
            return(unit);
        }
예제 #5
0
 /// <summary>
 /// Attempts to get a SessionId by supplementary session ID.
 /// </summary>
 /// <param name="supplementarySessionId"></param>
 /// <returns></returns>
 public Option <SessionId> GetSessionId(SupplementarySessionId supplementarySessionId) =>
 Sync.GetSessionId(supplementarySessionId) || getSessionIdFromCluster(supplementarySessionId);
예제 #6
0
 Option <SessionId> getSessionIdFromCluster(SupplementarySessionId suppSessionId) =>
 from c  in cluster
 from s  in SupplementarySessionManager.getSessionIdFromSuppMap(c, suppSessionId)
 from to in c.GetHashField <int>(SessionKey(s), TimeoutKey)
 let _ = Sync.UpdateSupplementarySessionId(s, suppSessionId)
         select Sync.Start(s, to);
예제 #7
0
 /// <summary>
 /// Attempts to get a SessionId by supplementary session ID.  Only checked locally.
 /// </summary>
 /// <param name="supplementarySessionId"></param>
 /// <returns></returns>
 public Option <SessionId> GetSessionId(SupplementarySessionId supplementarySessionId) =>
 Sync.GetSessionId(supplementarySessionId);
예제 #8
0
 /// <summary>
 /// Gets session id from supplementary sessionId
 /// </summary>
 /// <param name="sessionId"></param>
 /// <returns></returns>
 internal Option <SessionId> GetSessionId(SupplementarySessionId sessionId) => suppToSession.Find(sessionId);