Пример #1
0
        /// <summary>
        /// Add an expiration hint to the hints
        /// </summary>
        /// <param name="eh"></param>
        public void Add(ExpirationHint eh)
        {
            lock (this)
            {
                if (!eh.IsRoutable)
                {
                    this.SetBit(NON_ROUTABLE);
                }
                if (eh.IsVariant)
                {
                    this.SetBit(IS_VARIANT);
                }
                eh.SetExpirationEventSink(this);

                AggregateExpirationHint aggregate = eh as AggregateExpirationHint;
                if (aggregate != null)
                {
                    foreach (ExpirationHint expirationHint in aggregate._hints)
                    {
                        _hints.Add(expirationHint);
                    }
                }
                else
                {
                    _hints.Add(eh);
                }

                bool isFixed = false;
                for (int i = _hints.Count - 1; i >= 0; i--)
                {
                    if (isFixed && _hints[i] is FixedExpiration)
                    {
                        var previousFixedExpiration = _hints[i];
                        _hints.RemoveAt(i);
                        previousFixedExpiration.ReturnLeasableToPool();

                        break;
                    }
                    if (!isFixed && _hints[i] is FixedExpiration)
                    {
                        isFixed = true;
                    }
                }
            }
        }
Пример #2
0
        public bool UnRegister(string serverUniqueId, string clientUniqueId, string clientId)
        {
            lock (this)
            {
                if (clientRefs.ContainsKey(serverUniqueId))
                {
                    HashVector cRefs = (HashVector)clientRefs[serverUniqueId];
                    if (cRefs.ContainsKey(clientId))
                    {
                        ClusteredList <string> refs = (ClusteredList <string>)cRefs[clientId];
                        if (refs.Count > 0)
                        {
                            refs.Remove(clientUniqueId);

                            UnRegisterNotifications(serverUniqueId, clientUniqueId, clientId, addNotifications, maxAddDFAgainstCID, addDFAgainstCUniqueID);
                            UnRegisterNotifications(serverUniqueId, clientUniqueId, clientId, updateNotifications, maxUpdateDFAgainstCID, updateDFAgainstCUniqueID);
                            UnRegisterNotifications(serverUniqueId, clientUniqueId, clientId, removeNotifications, maxRemoveDFAgainstCID, removeDFAgainstCUniqueID);

                            if (refs.Count == 0)
                            {
                                cRefs.Remove(clientId);
                            }
                        }
                        if (cRefs.Count == 0)
                        {
                            int qIndex = -1;
                            foreach (ContinuousQuery query in registeredQueries)
                            {
                                if (query.UniqueId.Equals(serverUniqueId))
                                {
                                    qIndex = registeredQueries.IndexOf(query);
                                    break;
                                }
                            }
                            if (qIndex != -1)
                            {
                                registeredQueries.RemoveAt(qIndex);
                            }
                            return(true);
                        }
                    }
                }
                return(false);
            }
        }