Exemple #1
0
        /// <summary>
        /// Retrieve the list of keys fron the cache for the given group or sub group.
        /// </summary>
        protected HashVector Clustered_GetData(string group, string subGroup, OperationContext operationContext)
        {
            HashVector table = new HashVector();

            try
            {
                Function func = new Function((int)OpCodes.GetData, new object[] { group, subGroup, operationContext }, true);
                func.Cancellable = true;
                RspList results = Cluster.BroadcastToServers(func, GroupRequest.GET_ALL, false);
                if (results == null)
                {
                    return(null);
                }

                ClusterHelper.ValidateResponses(results, typeof(HashVector), Name);
                IList rspList = ClusterHelper.GetAllNonNullRsp(results, typeof(HashVector));

                if (rspList.Count <= 0)
                {
                    return(null);
                }
                else
                {
                    IEnumerator im = rspList.GetEnumerator();
                    while (im.MoveNext())
                    {
                        Rsp        rsp    = (Rsp)im.Current;
                        HashVector cTable = (HashVector)rsp.Value;
                        if (cTable != null)
                        {
                            IDictionaryEnumerator ide = cTable.GetEnumerator();
                            while (ide.MoveNext())
                            {
                                table[ide.Key] = ide.Value;
                            }
                        }
                    }
                }
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }

            return(table);
        }
Exemple #2
0
        /// <summary>
        /// Remove the objects from the cluster.
        /// </summary>
        /// <param name="keys">keys of the entries.</param>
        /// <returns>list of failed keys</returns>
        /// <remarks>
        /// This method invokes <see cref="handleRemove"/> on every server node in the cluster.
        /// </remarks>
        protected Hashtable Clustered_RemoveGroup(string group, string subGroup, bool notify, OperationContext operationContext)
        {
            Hashtable removedEntries = new Hashtable();

            try
            {
                Function func = new Function((int)OpCodes.RemoveGroup, new object[] { group, subGroup, notify, operationContext }, false);
                func.Cancellable = true;
                RspList results = Cluster.BroadcastToServers(func, GroupRequest.GET_ALL, false);

                if (results == null)
                {
                    return(removedEntries);
                }

                ClusterHelper.ValidateResponses(results, typeof(Hashtable), Name);
                IList rspList = ClusterHelper.GetAllNonNullRsp(results, typeof(Hashtable));

                if (rspList.Count <= 0)
                {
                    return(removedEntries);
                }

                IEnumerator ia = rspList.GetEnumerator();
                while (ia.MoveNext())
                {
                    Rsp       rsp     = (Rsp)ia.Current;
                    Hashtable removed = (Hashtable)rsp.Value;

                    IDictionaryEnumerator ide = removed.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        removedEntries.Add(ide.Key, ide.Value);
                    }
                }
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }

            return(removedEntries);
        }
Exemple #3
0
        /// <summary>
        /// Retrieve the list of keys fron the cache for the given group or sub group.
        /// </summary>
        protected ArrayList Clustered_GetKeys(ArrayList dests, string group, string subGroup)
        {
            ArrayList list = new ArrayList();

            try
            {
                Function func = new Function((int)OpCodes.GetKeys, new object[] { group, subGroup }, true);
                func.Cancellable = true;
                RspList results = Cluster.Multicast(dests, func, GroupRequest.GET_ALL, false);
                if (results == null)
                {
                    return(null);
                }

                ClusterHelper.ValidateResponses(results, typeof(ArrayList), Name);
                IList rspList = ClusterHelper.GetAllNonNullRsp(results, typeof(ClusteredArrayList));

                if (rspList.Count <= 0)
                {
                    return(null);
                }
                else
                {
                    IEnumerator im = rspList.GetEnumerator();
                    while (im.MoveNext())
                    {
                        Rsp       rsp   = (Rsp)im.Current;
                        ArrayList cList = (ArrayList)rsp.Value;
                        if (cList != null)
                        {
                            list.AddRange(cList);
                        }
                    }
                }
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
            return(list);
        }
        protected QueryResultSet Clustered_Search(ArrayList dests, string queryText, IDictionary values, bool excludeSelf, OperationContext operationContext)
        {
            QueryResultSet resultSet = new QueryResultSet();

            try
            {
                Function func    = new Function((int)OpCodes.Search, new object[] { queryText, values, operationContext }, excludeSelf);
                RspList  results = Cluster.BroadcastToMultiple(dests, func, GroupRequest.GET_ALL, false);

                if (results == null)
                {
                    return(null);
                }

                ClusterHelper.ValidateResponses(results, typeof(QueryResultSet), Name);
                ArrayList rspList = ClusterHelper.GetAllNonNullRsp(results, typeof(QueryResultSet));

                if (rspList.Count <= 0)
                {
                    return(null);
                }
                else
                {
                    IEnumerator im = rspList.GetEnumerator();
                    while (im.MoveNext())
                    {
                        Rsp            rsp         = (Rsp)im.Current;
                        QueryResultSet cRestultSet = (QueryResultSet)rsp.Value;
                        resultSet.Compile(cRestultSet);
                    }
                }

                return(resultSet);
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
        }
Exemple #5
0
        /// <summary>
        /// Remove the objects from the cluster.
        /// </summary>
        /// <param name="keys">keys of the entries.</param>
        /// <returns>list of failed keys</returns>
        /// <remarks>
        /// This method invokes <see cref="handleRemove"/> on every server node in the cluster.
        /// </remarks>
        protected Hashtable Clustered_Remove(Address dest, object[] keys, ItemRemoveReason ir, Caching.Notifications notification, string taskId, string providerName, bool notify, OperationContext operationContext)
        {
            if (ServerMonitor.MonitorActivity)
            {
                ServerMonitor.LogClientActivity("PartCacheBase.RemoveBlk", "");
            }

            Hashtable removedEntries = new Hashtable();
            ArrayList dests          = new ArrayList();

            dests.Add(dest);
            try
            {
                Function func = new Function((int)OpCodes.Remove, new object[] { keys, ir, notify, notification, taskId, providerName, operationContext }, false);
                func.Cancellable = true;
                RspList results = Cluster.Multicast(dests, func, GetFirstResponse, false);

                if (results == null)
                {
                    return(removedEntries);
                }

                if (results.SuspectedMembers.Count == dests.Count)
                {
                    //All the members of this group has gone down.
                    //we must try this operation on some other group.
                    throw new Runtime.Exceptions.SuspectedException("operation failed because the group member was suspected");
                }

                ClusterHelper.ValidateResponses(results, typeof(Hashtable), Name);
                IList rspList = ClusterHelper.GetAllNonNullRsp(results, typeof(Hashtable));

                if (rspList.Count <= 0)
                {
                    return(removedEntries);
                }

                IEnumerator ia = rspList.GetEnumerator();
                while (ia.MoveNext())
                {
                    if (operationContext.CancellationToken != null && operationContext.CancellationToken.IsCancellationRequested)
                    {
                        throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                    }

                    Rsp       rsp     = (Rsp)ia.Current;
                    Hashtable removed = (Hashtable)rsp.Value;

                    IDictionaryEnumerator ide = removed.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        if (!removedEntries.ContainsKey(ide.Key))
                        {
                            removedEntries.Add(ide.Key, ide.Value);
                        }
                    }
                }
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
            return(removedEntries);
        }