/// <summary> /// Removes the objects from the <see cref="Cache"/>. /// </summary> /// <param name="keys">The cache keys used to reference the item.</param> /// <param name="flagMap"></param> /// <returns>The items removed from the Cache. If the value in the keys parameter /// is not found, returns a null reference (Nothing in Visual Basic).</returns> /// <exception cref="ArgumentNullException"><paramref name="keys"/> contains a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentException"><paramref name="keys"/> is not serializable.</exception> /// <remarks> /// <para><b>Note:</b> If exceptions are enabled through the <see cref="NCache.ExceptionsEnabled"/> /// setting, this property throws exception incase of failure.</para> /// </remarks> /// <example>The following example demonstrates how you can remove an item from your application's /// <see cref="Cache"/> object. /// <code> /// /// NCache.Cache.Remove(keys); /// /// </code> /// Or simply in a class deriving from <see cref="Alachisoft.NCache.Web.UI.NPage"/> or <see cref="Alachisoft.NCache.Web.UI.NUserControl"/>. /// <code> /// /// Cache.Remove(keys); /// /// </code> /// </example> public override IDictionary Remove(string[] keys, BitSet flagMap) { Dictionary<Address, KeyValuePair<string[], CacheItem[]>> keysDistributionMap = new Dictionary<Address, KeyValuePair<string[], CacheItem[]>>(); Request request; if (_broker.ImportHashmap) { if (!_broker.PoolFullyConnected) { BulkRemoveCommand command = new BulkRemoveCommand(keys, flagMap); request = _broker.CreateDedicatedRequest(command); } else { request = new Request(true, _broker.OperationTimeOut); _broker.GetKeysDistributionMap(keys, null, ref keysDistributionMap); foreach (Address serverAddress in keysDistributionMap.Keys) { KeyValuePair<string[], CacheItem[]> keysAndItems = keysDistributionMap[serverAddress]; BulkRemoveCommand command = new BulkRemoveCommand(keysAndItems.Key, flagMap); command.ClientLastViewId = _broker.ClientLastViewId; request.AddCommand(serverAddress, command); } } } else { BulkRemoveCommand command = new BulkRemoveCommand(keys, flagMap); request = _broker.CreateRequest(command); } _broker.ExecuteRequest(request); CommandResponse res = request.Response; res.ParseResponse(); return res.KeyValueDic; }
public override List<EnumerationDataChunk> GetNextChunk(List<EnumerationPointer> pointers) { List<EnumerationDataChunk> nextChunk = null; Request request; CommandBase command = null; if (pointers.Count > 0 && pointers[0].NodeIpAddress!=null) { if (_broker.ImportHashmap) request = new Request(true, _broker.OperationTimeOut); else request = new Request(false, _broker.OperationTimeOut); for (int i = 0; i < pointers.Count; i++) { EnumerationPointer pointer = pointers[i]; command = new GetNextChunkCommand(pointer); request.AddCommand(pointer.NodeIpAddress, command); } } else { if (!_broker.PoolHasAllServers || !_broker.ImportHashmap) { EnumerationPointer pointer = pointers[0]; command = new GetNextChunkCommand(pointer); request = _broker.CreateRequest(command); } else { request = new Request(true, _broker.OperationTimeOut); EnumerationPointer pointer = pointers[0]; for (int i = 0; i < _broker.ClientServerList.Count; i++) { command = new GetNextChunkCommand(pointer); command.clientLastViewId = -1; RemoteServer server = (RemoteServer)_broker.ClientServerList[i]; command.intendedRecipient = server.IP.ToString().ToString(); request.AddCommand(new Address(server.IP.ToString(),server.Port), command); } } } _broker.ExecuteRequest(request); CommandResponse response = request.Response; response.ParseResponse(); nextChunk = response.NextChunk; return nextChunk; }
private void RegisterNotifications(NotificationsType notifMask, Connection connection) { RegisterNotificationCommand command = new RegisterNotificationCommand(notifMask,-1); Request request = new Request(false, _broker.OperationTimeOut); Address ipAddress = connection.ServerAddress; request.AddCommand(ipAddress, command); _broker.ExecuteRequest(request, connection, true, true); CommandResponse res = (CommandResponse)request.Response; res.ParseResponse(); }
/// <summary> /// Removes the objects from the <see cref="Cache"/>. /// </summary> /// <param name="keys">The cache keys used to reference the item.</param> /// <param name="flagMap"></param> /// <returns>The items removed from the Cache. If the value in the keys parameter /// is not found, returns a null reference (Nothing in Visual Basic).</returns> /// <exception cref="ArgumentNullException"><paramref name="keys"/> contains a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentException"><paramref name="keys"/> is not serializable.</exception> /// <remarks> /// <para><b>Note:</b> If exceptions are enabled through the <see cref="NCache.ExceptionsEnabled"/> /// setting, this property throws exception incase of failure.</para> /// </remarks> /// <example>The following example demonstrates how you can remove an item from your application's /// <see cref="Cache"/> object. /// <code> /// /// NCache.Cache.Remove(keys); /// /// </code> /// Or simply in a class deriving from <see cref="Alachisoft.NCache.Web.UI.NPage"/> or <see cref="Alachisoft.NCache.Web.UI.NUserControl"/>. /// <code> /// /// Cache.Remove(keys); /// /// </code> /// </example> public override void Delete(string[] keys, BitSet flagMap) { Dictionary<Address, KeyValuePair<string[], CacheItem[]>> keysDistributionMap = new Dictionary<Address, KeyValuePair<string[], CacheItem[]>>(); Request request; if (_broker.ImportHashmap) { request = new Request(true, _broker.OperationTimeOut); if (!_broker.PoolFullyConnected) { BulkDeleteCommand command = new BulkDeleteCommand(keys, flagMap); command.ClientLastViewId = _broker.ForcedViewId; Connection conn = _broker.GetAnyConnection(); if (conn != null) { request.AddCommand(conn.ServerAddress, command); } else { throw new OperationFailedException("No server is available to process the request"); } } else { _broker.GetKeysDistributionMap(keys, null, ref keysDistributionMap); foreach (Address serverAddress in keysDistributionMap.Keys) { KeyValuePair<string[], CacheItem[]> keysAndItems = keysDistributionMap[serverAddress]; BulkDeleteCommand command = new BulkDeleteCommand(keysAndItems.Key, flagMap); command.ClientLastViewId = _broker.ClientLastViewId; request.AddCommand(serverAddress, command); } } } else { BulkDeleteCommand command = new BulkDeleteCommand(keys, flagMap); request = _broker.CreateRequest(command); } _broker.ExecuteRequest(request); CommandResponse res = request.Response; res.ParseResponse(); }
internal void GetTypeInfoMap(Connection connection) { GetTypeInfoMapCommand command = new GetTypeInfoMapCommand(false); Request request = new Request(false, _broker.OperationTimeOut); Address ipAddress = connection.ServerAddress; request.AddCommand(ipAddress, command); _broker.ExecuteRequest(request, connection, true, true); CommandResponse res = request.Response; res.ParseResponse(); this.TypeMap = res.TypeMap; }