/// <summary>
        /// Returns a .NET IEnumerator interface so that a client should be able
        /// to iterate over the elements of the cache store.
        /// </summary>
        /// <returns>IDictionaryEnumerator enumerator.</returns>
        protected IDictionaryEnumerator Clustered_GetEnumerator(ArrayList dests, IDictionaryEnumerator local)
        {
            IDictionaryEnumerator retVal = null;

            try
            {
                Function func    = new Function((int)OpCodes.KeyList, null);
                RspList  results = Cluster.BroadcastToMultiple(dests,
                                                               func,
                                                               GroupRequest.GET_ALL,
                                                               Cluster.Timeout * 10,
                                                               false);
                if (results == null)
                {
                    return(retVal);
                }

                ClusterHelper.ValidateResponses(results, typeof(object[]), Name);

                Rsp       rsp       = null;
                ArrayList validRsps = new ArrayList();
                for (int i = 0; i < results.size(); i++)
                {
                    rsp = (Rsp)results.elementAt(i);

                    if (rsp.Value != null)
                    {
                        validRsps.Add(rsp);
                    }
                }

                int index      = (local == null ? 0 : 1);
                int totalEnums = validRsps.Count + index;
                IDictionaryEnumerator[] enums = new IDictionaryEnumerator[totalEnums];
                if (local != null)
                {
                    enums[0] = local;
                }
                for (int i = 0; i < validRsps.Count; i++)
                {
                    rsp            = (Rsp)validRsps[i];
                    enums[index++] = new LazyPartitionedKeysetEnumerator(this,
                                                                         rsp.Value as object[],
                                                                         rsp.Sender as Address,
                                                                         false);
                }
                retVal = new AggregateEnumerator(enums);
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
            return(retVal);
        }
        /// <summary>
        /// Returns a .NET IEnumerator interface so that a client should be able
        /// to iterate over the elements of the cache store.
        /// </summary>
        /// <returns>IDictionaryEnumerator enumerator.</returns>
        public override IDictionaryEnumerator GetEnumerator()
        {
            /// Wait until the object enters the running status
            _statusLatch.WaitForAny(NodeStatus.Running);

            if (_internalCache == null)
                throw new InvalidOperationException();

            IDictionaryEnumerator localEnumerator = new LazyPartitionedKeysetEnumerator(this, (object[]) handleKeyList(),
                Cluster.LocalAddress, true);

            if (Cluster.Servers.Count == 1)
                return localEnumerator;


            return Clustered_GetEnumerator(Cluster.Servers, localEnumerator);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a .NET IEnumerator interface so that a client should be able
        /// to iterate over the elements of the cache store.
        /// </summary>
        /// <returns>IDictionaryEnumerator enumerator.</returns>
        protected IDictionaryEnumerator Clustered_GetEnumerator(ArrayList dests, IDictionaryEnumerator local)
        {
            IDictionaryEnumerator retVal = null;
            try
            {
                Function func = new Function((int)OpCodes.KeyList, null);
                RspList results = Cluster.BroadcastToMultiple(dests,
                    func,
                    GroupRequest.GET_ALL,
                    Cluster.Timeout * 10,
                    false);
                if (results == null)
                {
                    return retVal;
                }

                ClusterHelper.ValidateResponses(results, typeof(object[]), Name);

                Rsp rsp = null;
                ArrayList validRsps = new ArrayList();
                for (int i = 0; i < results.size(); i++)
                {
                    rsp = (Rsp)results.elementAt(i);

                    if (rsp.Value != null)
                    {
                        validRsps.Add(rsp);
                    }
                }

                int index = (local == null ? 0 : 1);
                int totalEnums = validRsps.Count + index;
                IDictionaryEnumerator[] enums = new IDictionaryEnumerator[totalEnums];
                if (local != null)
                {
                    enums[0] = local;
                }
                for (int i = 0; i < validRsps.Count; i++)
                {
                    rsp = (Rsp)validRsps[i];
                    enums[index++] = new LazyPartitionedKeysetEnumerator(this,
                        rsp.Value as object[],
                        rsp.Sender as Address, 
                        false);
                }
                retVal = new AggregateEnumerator(enums);
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
            return retVal;
        }