/// <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 CacheAddResult Clustered_Add(ArrayList dests, object key, CacheEntry cacheEntry, OperationContext operationContext) { CacheAddResult result = CacheAddResult.Failure; try { if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("RepCacheBase.Add", "enter"); } /// Ask every server to add the object, except myself. Function func = new Function((int)OpCodes.Add, new object[] { key, cacheEntry, operationContext }, false, key); Array userPayLoad = null; if (cacheEntry.Value is CallbackEntry) { CallbackEntry cbEntry = ((CallbackEntry)cacheEntry.Value); userPayLoad = cbEntry.UserData; } else { userPayLoad = cacheEntry.UserData; } func.UserPayload = userPayLoad; RspList results = Cluster.BroadcastToMultiple(dests, func, GroupRequest.GET_ALL, _asyncOperation); ClusterHelper.ValidateResponses(results, typeof(CacheAddResult), Name); /// Check if the operation failed on any node. result = ClusterHelper.FindAtomicAddStatusReplicated(results); } catch (CacheException e) { throw; } catch (Exception e) { throw new GeneralFailureException(e.Message, e); } finally { if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("RepCacheBase.Add", "exit"); } } return(result); }