Esempio n. 1
0
        /// <summary>
        /// Remove the objects from the cluster. For efficiency multiple objects are sent as one.
        /// </summary>
        /// <param name="keys">list of keys to remove.</param>
        /// <returns>true if succeded, false otherwise.</returns>
        /// <remarks>
        /// This method invokes <see cref="handleRemoveRange"/> on every server node in the cluster.
        /// </remarks>
        protected bool Clustered_Remove(object[] keys, ItemRemoveReason reason, OperationContext operationContext)
        {
            try
            {
                Function func    = new Function((int)OpCodes.RemoveRange, new object[] { keys, reason, operationContext }, false);
                RspList  results = Cluster.BroadcastToServers(func, GroupRequest.GET_ALL, true);

                if (results != null)
                {
                    for (int i = 0; i < results.size(); i++)
                    {
                        Rsp rsp1 = (Rsp)results.elementAt(i);

                        if (!rsp1.wasReceived())
                        {
                            Context.NCacheLog.Error("ReplicatedBase.Remove[]", "timeout_failure :" + rsp1.Sender + " Keys :" + keys.Length);
                            continue;
                        }
                    }
                }
                Rsp rsp = ClusterHelper.FindAtomicRemoveStatusReplicated(results, Context.NCacheLog);

                return(true);
            }
            catch (Runtime.Exceptions.TimeoutException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Remove the object from the cluster.
        /// </summary>
        /// <param name="key">key of the entry.</param>
        /// <returns>cache entry.</returns>
        /// <remarks>
        /// This method invokes <see cref="handleRemove"/> on every server node in the cluster.
        /// </remarks>
        protected CacheEntry Clustered_Remove(object key, ItemRemoveReason ir, CallbackEntry cbEntry, bool notify, object lockId, LockAccessType accessType, OperationContext operationContext)
        {
            CacheEntry retVal = null;

            try
            {
                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("RepCacheBase.Remove", "enter");
                }
                Function func    = new Function((int)OpCodes.Remove, new object[] { key, ir, notify, cbEntry, lockId, accessType, operationContext }, false, key);
                RspList  results = Cluster.BroadcastToServers(func, GroupRequest.GET_ALL, _asyncOperation);
                if (results == null)
                {
                    return(retVal);
                }

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

                Rsp rsp = ClusterHelper.FindAtomicRemoveStatusReplicated(results);
                if (rsp == null)
                {
                    return(retVal);
                }

                OperationResponse opRes = rsp.Value as OperationResponse;
                if (opRes != null)
                {
                    CacheEntry entry = opRes.SerializablePayload as CacheEntry;
                    if (entry != null)
                    {
                        entry.Value = opRes.UserPayload;
                    }
                    return(entry);
                }
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
            finally
            {
                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("RepCacheBase.Remove", "exit");
                }
            }
            return(retVal);
        }