Example #1
0
        /// <summary>
        /// Add the object to the cluster. Does load balancing as well.
        /// </summary>
        /// <param name="key">key of the entry.</param>
        /// <returns>cache entry.</returns>
        /// <remarks>
        /// This method either invokes <see cref="handleAdd"/> on one of the server nodes in the cluster,
        /// or invokes <see cref="Local_Add"/> locally.
        /// </remarks>
        protected bool Clustered_Add(ArrayList dests, object key, ExpirationHint eh, OperationContext operationContext)
        {
            bool result = false;

            try
            {
                /// Ask every server to add the object, except myself.
                Function func    = new Function((int)OpCodes.AddHint, new object[] { key, eh, operationContext }, false, key);
                RspList  results = Cluster.BroadcastToMultiple(dests,
                                                               func,
                                                               GroupRequest.GET_ALL, _asyncOperation);

                ClusterHelper.ValidateResponses(results, typeof(bool), Name);

                /// Check if the operation failed on any node.
                result = ClusterHelper.FindAtomicAddHintReplicated(results);
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
            return(result);
        }