public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //_commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; OperationContext context = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); context.Add(OperationContextFieldName.ClientId, clientManager.ClientID); CommandsUtil.PopulateClientIdInContext(ref context, clientManager.ClientAddress); nCache.Cache.RegisterPollingNotification(cmdInfo.PollingCallbackId, context); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.RegisterPollNotifResponse registerNotifResponse = new Alachisoft.NCache.Common.Protobuf.RegisterPollNotifResponse(); if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(registerNotifResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(registerNotifResponse, Common.Protobuf.Response.Type.REGISTER_POLL_NOTIF)); } else { Common.Protobuf.Response response = new Common.Protobuf.Response(); response.registerPollNotifResponse = registerNotifResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.REGISTER_POLL_NOTIF); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } }
private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager) { CommandInfo cmdInfo = new CommandInfo(); Alachisoft.NCache.Common.Protobuf.GetGroupNextChunkCommand getNextChunkCommand = command.getGroupNextChunkCommand; cmdInfo.RequestId = getNextChunkCommand.requestId.ToString(); cmdInfo.Pointer = EnumerationPointerConversionUtil.GetFromProtobufGroupEnumerationPointer(getNextChunkCommand.groupEnumerationPointer); string intendedRecepient = command.intendedRecipient; long lastViewId = command.clientLastViewId; cmdInfo.OperationContext = new OperationContext(); cmdInfo.OperationContext.Add(OperationContextFieldName.IntendedRecipient, intendedRecepient); cmdInfo.OperationContext.Add(OperationContextFieldName.ClientLastViewId, lastViewId); CommandsUtil.PopulateClientIdInContext(ref cmdInfo.OperationContext, clientManager.ClientAddress); return(cmdInfo); }
public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { string exception = null; int overload; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); nCache.Cache.Touch(cmdInfo.Keys, operationContext); stopWatch.Stop(); Common.Protobuf.TouchResponse touchResponse = new Common.Protobuf.TouchResponse(); if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(touchResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(touchResponse, Common.Protobuf.Response.Type.TOUCH)); } else { Common.Protobuf.Response response = new Common.Protobuf.Response(); response.touchResponse = touchResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.TOUCH); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { exception = exc.ToString(); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Management.APILogging.APILogManager.APILogManger != null && Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.Touch.ToLower()); log.GenerateTouchCommandAPILogItem(cmdInfo.Keys.Count, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { ClientId = clientManager.ClientID; NCache nCache = clientManager.CmdExecuter as NCache; int overload; Hashtable queryInfo = null; ExpirationHint expHint = null; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; serailizationContext = nCache.CacheId; cmdInfo = base.ParseCommand(command, clientManager, serailizationContext); } catch (System.Exception exc) { _addBulkResult = OperationResult.Failure; { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { //PROTOBUF:RESPONSE OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); operationContext.Add(OperationContextFieldName.WriteThru, cmdInfo.Flag.IsBitSet(BitSetConstants.WriteThru)); operationContext.Add(OperationContextFieldName.WriteBehind, cmdInfo.Flag.IsBitSet(BitSetConstants.WriteBehind)); operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout); operationContext.CancellationToken = CancellationToken; if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient)) { operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient); } queryInfo = cmdInfo.Entries[0].QueryInfo; expHint = cmdInfo.Entries[0].ExpirationHint; IDictionary itemVersions = null; Hashtable addResult = (Hashtable)nCache.Cache.Add(cmdInfo.Keys, cmdInfo.Entries, cmdInfo.Flag, cmdInfo.ProviderName, out itemVersions, operationContext); stopWatch.Stop(); BulkAddResponse addResponse = new BulkAddResponse(); addResponse.keyExceptionPackage = new Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse(); addResponse.keyVersionPackage = new Alachisoft.NCache.Common.Protobuf.KeyVersionPackageResponse(); Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysExceptions(addResult, addResponse.keyExceptionPackage); if (cmdInfo.returnVersion) { Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysVersion(itemVersions, addResponse.keyVersionPackage); } if (clientManager.ClientVersion >= 5000) { addResponse.intendedRecipient = cmdInfo.IntendedRecipient; ResponseHelper.SetResponse(addResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(addResponse, Response.Type.ADD_BULK)); } else { //PROTOBUF:RESPONSE Response response = new Response(); response.intendedRecipient = cmdInfo.IntendedRecipient; response.bulkAdd = addResponse; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.ADD_BULK); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (OperationCanceledException ex) { exception = ex.ToString(); Dispose(); } catch (System.Exception exc) { _addBulkResult = OperationResult.Failure; exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.ADDBULK.ToLower()); Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(expHint, queryInfo); log.GenerateADDInsertBulkAPILogItem(cmdInfo.Keys.Length, cmdInfo.Entries.Length, expirationHint["dependency"] != null ? expirationHint["dependency"] as ArrayList : null, expirationHint["absolute-expiration"] != null ? (long)expirationHint["absolute-expiration"] : -1, expirationHint["sliding-expiration"] != null ? (long)expirationHint["sliding-expiration"] : -1, cmdInfo.Entries[0].Priority, expirationHint["tag-info"] != null ? expirationHint["tag-info"] as Hashtable : null, expirationHint["named-tags"] != null ? expirationHint["named-tags"] as Hashtable : null, cmdInfo.Group != null ? cmdInfo.Group : null, cmdInfo.SubGroup != null ? cmdInfo.SubGroup : null, cmdInfo.Entries[0].Flag, cmdInfo.Entries[0].ProviderName, cmdInfo.Entries[0].ResyncProviderName, false, cmdInfo.Entries[0].HasQueryInfo, (long)cmdInfo.Entries[0].Version, cmdInfo.onUpdateCallbackId, cmdInfo.OnDsItemsAddedCallback, false, false, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString()); } } catch { } if (cmdInfo.Entries != null) { foreach (var entry in cmdInfo.Entries) { entry.Flag?.MarkFree(NCModulesConstants.SocketServer); } } if (cmdInfo.Entries != null) { cmdInfo.Entries.MarkFree(NCModulesConstants.SocketServer); MiscUtil.ReturnEntriesToPool(cmdInfo.Entries, clientManager.CacheTransactionalPool); } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); } return; } //TODO byte[] data = null; try { NCache nCache = clientManager.CmdExecuter as NCache; Notifications cbEnrty = null; if (cmdInfo.DsItemsRemovedId != -1) { cbEnrty = new Notifications(clientManager.ClientID, -1, -1, -1, -1, cmdInfo.DsItemsRemovedId, Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None); //DataFilter not required } OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient)) { operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient); } operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout); operationContext.CancellationToken = CancellationToken; nCache.Cache.Delete(cmdInfo.Keys, cmdInfo.FlagMap, cbEnrty, cmdInfo.ProviderName, operationContext); stopWatch.Stop(); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkDeleteResponse bulkDeleteResponse = new Alachisoft.NCache.Common.Protobuf.BulkDeleteResponse(); //response.requestId = Convert.ToInt64(cmdInfo.RequestId); //response.commandID = command.commandID; //response.intendedRecipient = cmdInfo.IntendedRecipient; //response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.DELETE_BULK; //response.bulkDeleteResponse = bulkDeleteResponse; //_serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response,Common.Protobuf.Response.Type.DELETE_BULK)); if (clientManager.ClientVersion >= 5000) { bulkDeleteResponse.intendedRecipient = cmdInfo.IntendedRecipient; Common.Util.ResponseHelper.SetResponse(bulkDeleteResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(bulkDeleteResponse, Common.Protobuf.Response.Type.DELETE_BULK)); } else { //PROTOBUF:RESPONSE response.intendedRecipient = cmdInfo.IntendedRecipient; response.bulkDeleteResponse = bulkDeleteResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.DELETE_BULK); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (OperationCanceledException ex) { exception = ex.ToString(); Dispose(); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; exception = exc.ToString(); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); } finally { try { TimeSpan executionTime = stopWatch.Elapsed; if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.DELETEBULK.ToLower()); // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); log.GenerateBulkDeleteAPILogItem(cmdInfo.Keys.Length, cmdInfo.FlagMap, cmdInfo.ProviderName, cmdInfo.DsItemsRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } } finally { cmdInfo.FlagMap.MarkFree(NCModulesConstants.SocketServer); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { NCache nCache = clientManager.CmdExecuter as NCache; int overload; long dataLength = 0; string exception = null; bool itemUpdated = false; bool itemRemove = false; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { try { overload = command.MethodOverload; serializationContext = nCache.CacheId; cmdInfo = base.ParseCommand(command, clientManager, serializationContext); } catch (System.Exception exc) { _addResult = OperationResult.Failure; { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } Notifications callbackEntry = null; if (cmdInfo.UpdateCallbackId != -1 || cmdInfo.RemoveCallbackId != -1 || (!cmdInfo.RequestId.Equals("-1") && cmdInfo.DoAsync) || cmdInfo.DsItemAddedCallbackId != -1) { if (cmdInfo.RemoveCallbackId != -1) { itemRemove = true; } if (cmdInfo.UpdateCallbackId != -1) { itemUpdated = true; } callbackEntry = new Notifications(!string.IsNullOrEmpty(cmdInfo.ClientID) ? cmdInfo.ClientID : clientManager.ClientID, Convert.ToInt32(cmdInfo.RequestId), cmdInfo.RemoveCallbackId, cmdInfo.UpdateCallbackId, (short)(cmdInfo.RequestId == -1 ? -1 : 0), cmdInfo.DsItemAddedCallbackId, (EventDataFilter)cmdInfo.UpdateDataFilter, (EventDataFilter)cmdInfo.RemoveDataFilter); } UserBinaryObject data = cmdInfo.value as UserBinaryObject; if (data != null) { dataLength = data.Length; } if (!cmdInfo.DoAsync) { OperationContext operationContext = null; try { operationContext = _operationContext; operationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); UInt64 itemVersion = 0; if (cmdInfo.ItemVersion == 0) { itemVersion = (ulong)(DateTime.UtcNow - Common.Util.Time.ReferenceTime).TotalMilliseconds; } else { itemVersion = cmdInfo.ItemVersion; } operationContext.Add(OperationContextFieldName.ItemVersion, itemVersion); operationContext.Add(OperationContextFieldName.MethodOverload, overload); operationContext?.MarkInUse(NCModulesConstants.SocketServer); if (cmdInfo.Group != null) { if (string.IsNullOrEmpty(cmdInfo.Type)) { cmdInfo.Type = oldClientsGroupType; } } nCache.Cache.Add(cmdInfo.Key, cmdInfo.value, cmdInfo.ExpirationHint, cmdInfo.EvictionHint, cmdInfo.Group, cmdInfo.SubGroup, cmdInfo.queryInfo, cmdInfo.Flag, cmdInfo.ProviderName, cmdInfo.ResyncProviderName, operationContext, null, callbackEntry, cmdInfo.Type); stopWatch.Stop(); if (operationContext.Contains(OperationContextFieldName.ItemVersion)) { itemVersion = (ulong)operationContext.GetValueByField(OperationContextFieldName.ItemVersion); } _addResponse.itemversion = itemVersion; if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(_addResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(_addResponse, Response.Type.ADD)); } else { //PROTOBUF:RESPONSE var response = Stash.ProtobufResponse; response.addResponse = _addResponse; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.ADD); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (System.Exception exc) { _addResult = OperationResult.Failure; exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { operationContext?.MarkFree(NCModulesConstants.SocketServer); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.ADD.ToLower()); object toInsert; if (cmdInfo.value is UserBinaryObject) { toInsert = dataLength; } else { toInsert = cmdInfo.DataFormatValue; } Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); log.GenerateADDInsertAPILogItem(cmdInfo.Key, toInsert, expirationHint["dependency"] != null ? expirationHint["dependency"] as ArrayList : null, expirationHint["absolute-expiration"] != null ? (long)expirationHint["absolute-expiration"] : -1, expirationHint["sliding-expiration"] != null ? (long)expirationHint["sliding-expiration"] : -1, cmdInfo.EvictionHint.Priority, expirationHint["tag-info"] != null ? expirationHint["tag-info"] as Hashtable : null, cmdInfo.Group, cmdInfo.SubGroup, cmdInfo.Flag, cmdInfo.ProviderName, cmdInfo.ResyncProviderName, false, expirationHint["named-tags"] != null ? expirationHint["named-tags"] as Hashtable : null, cmdInfo.UpdateCallbackId, cmdInfo.DsItemAddedCallbackId, false, itemUpdated, itemRemove, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString()); } } catch { } } } else { OperationContext operationContext = null; try { operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.WriteThru, cmdInfo.Flag.IsBitSet(BitSetConstants.WriteThru)); operationContext.Add(OperationContextFieldName.WriteBehind, cmdInfo.Flag.IsBitSet(BitSetConstants.WriteBehind)); if (cmdInfo.ProviderName != null) { operationContext.Add(OperationContextFieldName.WriteThruProviderName, cmdInfo.ProviderName); } operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); UInt64 itemVersion = 0; if (cmdInfo.ItemVersion == 0) { itemVersion = (ulong)(DateTime.UtcNow - Common.Util.Time.ReferenceTime).TotalMilliseconds; } else { itemVersion = cmdInfo.ItemVersion; } operationContext.Add(OperationContextFieldName.ItemVersion, itemVersion); operationContext.Add(OperationContextFieldName.MethodOverload, overload); operationContext.MarkInUse(NCModulesConstants.SocketServer); bool onAsyncCall = false; if (callbackEntry != null) { onAsyncCall = true; } if (cmdInfo.Group != null) { if (string.IsNullOrEmpty(cmdInfo.Type)) { cmdInfo.Type = oldClientsGroupType; } } // Fetching this from pool to avoid value corruption for eviction hint for old cmdInfo.EvictionHint = Caching.EvictionPolicies.PriorityEvictionHint.Create( clientManager.CacheTransactionalPool, cmdInfo.EvictionHint.Priority ); nCache.Cache.AddAsync(cmdInfo.Key, cmdInfo.value, cmdInfo.ExpirationHint, cmdInfo.EvictionHint, cmdInfo.Group, cmdInfo.SubGroup, cmdInfo.Flag, cmdInfo.queryInfo, cmdInfo.ProviderName, operationContext, callbackEntry, cmdInfo.Type); stopWatch.Stop(); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.ADDASYNC.ToLower()); Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); object toInsert; if (cmdInfo.value is UserBinaryObject) { toInsert = dataLength; } else { toInsert = cmdInfo.DataFormatValue; } log.GenerateADDInsertAPILogItem(cmdInfo.Key, toInsert, expirationHint["dependency"] != null ? expirationHint["dependency"] as ArrayList : null, expirationHint["absolute-expiration"] != null ? (long)expirationHint["absolute-expiration"] : -1, expirationHint["sliding-expiration"] != null ? (long)expirationHint["sliding-expiration"] : -1, cmdInfo.EvictionHint.Priority, expirationHint["tag-info"] != null ? expirationHint["tag-info"] as Hashtable : null, cmdInfo.Group, cmdInfo.SubGroup, cmdInfo.Flag, cmdInfo.ProviderName, cmdInfo.ResyncProviderName, false, expirationHint["named-tags"] != null ? expirationHint["named-tags"] as Hashtable : null, cmdInfo.UpdateCallbackId, cmdInfo.DsItemAddedCallbackId, onAsyncCall, itemUpdated, itemRemove, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString()); } } catch { } } finally { operationContext?.MarkFree(NCModulesConstants.SocketServer); } } } finally { cmdInfo.Flag?.MarkFree(NCModulesConstants.SocketServer); } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (System.Exception exc) { if (!base.immatureId.Equals("-2")) { //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } NCache nCache = clientManager.CmdExecuter as NCache; CacheEntry entry = null; try { object lockId = cmdInfo.LockId; DateTime lockDate = new DateTime(); OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); // ReadThruOptions readOptions = new ReadThruOptions(cmdInfo.ReadMode, cmdInfo.ProviderName); //operationContext.Add(OperationContextFieldName.ReadThruOptions, readOptions); operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); entry = (CacheEntry)nCache.Cache.GetCacheEntry(cmdInfo.Key, cmdInfo.Group, cmdInfo.SubGroup, ref lockId, ref lockDate, cmdInfo.LockTimeout, cmdInfo.LockAccessType, operationContext, ref cmdInfo.CacheItemVersion); stopWatch.Stop(); GetCacheItemResponse getCacheItemResponse = new GetCacheItemResponse(); getCacheItemResponse.lockId = lockId == null ? string.Empty : lockId.ToString(); getCacheItemResponse.lockTicks = lockDate.Ticks; if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(getCacheItemResponse, command.requestID, command.commandID); if (entry == null) { _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(getCacheItemResponse, Response.Type.GET_CACHE_ITEM)); return; } else { getCacheItemResponse.itemType = MiscUtil.EntryTypeToProtoItemType(entry.Type); } getCacheItemResponse = PopulateResponse(entry, getCacheItemResponse, clientManager, nCache.Cache); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(getCacheItemResponse, Response.Type.GET_CACHE_ITEM)); } else { Response response = new Response(); ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.GET_CACHE_ITEM); if (entry == null) { response.getItem = getCacheItemResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); return; } else { getCacheItemResponse.itemType = MiscUtil.EntryTypeToProtoItemType(entry.Type); } getCacheItemResponse = PopulateResponse(entry, getCacheItemResponse, clientManager, nCache.Cache); response.getItem = getCacheItemResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (System.Exception exc) { exception = exc.ToString(); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { int result = 0; if (entry != null) { result = 1; } else { result = 0; } APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetCacheItem.ToLower()); } if (entry != null) { MiscUtil.ReturnEntryToPool(entry, clientManager.CacheTransactionalPool); } } catch { } if (entry != null) { entry.MarkFree(NCModulesConstants.Global); } cmdInfo.FlagMap?.MarkFree(NCModulesConstants.SocketServer); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload = 0; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); Keys = new List <string>(); string key = null; NCache nCache = clientManager.CmdExecuter as NCache; try { overload = command.MethodOverload; switch (command.type) { case Common.Protobuf.Command.Type.CONTAINS: Alachisoft.NCache.Common.Protobuf.ContainsCommand containsCommand = command.containsCommand; Keys.Add(containsCommand.key); key = containsCommand.key; RequestId = containsCommand.requestId.ToString(); break; case Common.Protobuf.Command.Type.CONTAINS_BULK: Alachisoft.NCache.Common.Protobuf.ContainsBulkCommand containsBulkCommand = command.containsBulkCommand; FeatureUsageCollector.Instance.GetFeature(FeatureEnum.bulk_operations).UpdateUsageTime(); Keys = containsBulkCommand.keys; RequestId = containsBulkCommand.requestId.ToString(); break; default: throw new Exception("Invalid Command Received in ContainsCommand"); } var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); Hashtable exists = nCache.Cache.Contains(Keys, operationContext); stopWatch.Stop(); if (clientManager.ClientVersion >= 5000) { Alachisoft.NCache.Common.Protobuf.ContainBulkResponse containsBulkResponse = new Alachisoft.NCache.Common.Protobuf.ContainBulkResponse(); containsBulkResponse.exists = CompactBinaryFormatter.ToByteBuffer(exists, null); ResponseHelper.SetResponse(containsBulkResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(containsBulkResponse, Common.Protobuf.Response.Type.CONTAINS_BULK)); } else { Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.ContainResponse containResponse = new Alachisoft.NCache.Common.Protobuf.ContainResponse(); IDictionary <string, bool> keysPresent = ExtractKeyStatus(exists, Keys); containResponse.exists = keysPresent[key]; response.contain = containResponse; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.CONTAINS); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.Contains.ToLower()); log.GenerateContainsCommandAPILogItem(key, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("ContCmd.Exec", "cmd executed on cache"); } }
public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); int overload = 1; bool subscribed = false; string exceptionMessage = null; try { NCache nCache = clientManager.CmdExecuter as NCache; var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); if (command.commandVersion < 1) { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 SP1 or later { operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture)); } CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); if (nCache != null) { _command = command.subscribeTopicCommand; SubscriptionInfo subscriptionInfo = new SubscriptionInfo() { SubscriptionId = _command.subscriptionName, ClientId = clientManager.ClientID, Type = (SubscriptionType)_command.pubSubType, SubPolicyType = (SubscriptionPolicyType)_command.subscriptionPolicy, CreationTime = _command.creationTime, Expiration = _command.expirationTime }; SubscriptionOperation subOperation = new SubscriptionOperation(_command.topicName, TopicOperationType.Subscribe, subscriptionInfo); subscribed = nCache.Cache.TopicOpertion(subOperation, operationContext); stopWatch.Stop(); //Common.Protobuf.Response response = new Common.Protobuf.Response(); Common.Protobuf.SubscribeTopicResponse subscribeTopicResponse = new Common.Protobuf.SubscribeTopicResponse(); subscribeTopicResponse.success = subscribed; if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(subscribeTopicResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(subscribeTopicResponse, Common.Protobuf.Response.Type.SUBSCRIBE_TOPIC)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.subscribeTopicResponse = subscribeTopicResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.SUBSCRIBE_TOPIC); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } } catch (Exception exc) { exceptionMessage = exc.ToString(); _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.CreateTopicSubscriptoin); log.GenerateSubscribeToTopicAPILogItem(_command.topicName, (SubscriptionType)_command.pubSubType, executionTime, clientManager.ClientID, clientManager.ClientIP, overload, subscribed, exceptionMessage, APIClassNames.TOPIC); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; int count = 0; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("BulkGetCmd.Exec", "cmd parsed"); } } catch (Exception exc) { _getBulkCacheItemResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } NCache nCache = clientManager.CmdExecuter as NCache; List <CacheEntry> pooledEntries = null; try { OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient)) { operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient); } operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout); operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true); operationContext.CancellationToken = CancellationToken; IDictionary getResult = (IDictionary)nCache.Cache.GetBulkCacheItems(cmdInfo.Keys, cmdInfo.FlagMap, operationContext); count = getResult.Count; stopWatch.Stop(); Alachisoft.NCache.Common.Protobuf.BulkGetCacheItemResponse bulkGetCacheItemResponse = new Alachisoft.NCache.Common.Protobuf.BulkGetCacheItemResponse(); IDictionaryEnumerator enu = getResult.GetEnumerator(); while (enu.MoveNext()) { CacheEntry cacheEntry = null; try { var keyCacheItem = new Alachisoft.NCache.Common.Protobuf.KeyCacheItemPair(); keyCacheItem.key = (string)enu.Key; cacheEntry = (CacheEntry)enu.Value; if (cacheEntry != null) { if (cacheEntry.IsFromPool) { if (pooledEntries == null) { pooledEntries = new List <CacheEntry>(); } pooledEntries.Add(cacheEntry); } keyCacheItem.cacheItem = PopulateResponse(cacheEntry, clientManager, nCache.Cache); keyCacheItem.cacheItem.itemType = MiscUtil.EntryTypeToProtoItemType(cacheEntry.Type); bulkGetCacheItemResponse.KeyCacheItemPairs.Add(keyCacheItem); } else { bulkGetCacheItemResponse.KeyCacheItemPairs.Add(null); } } finally { if (cacheEntry != null) { cacheEntry.MarkFree(NCModulesConstants.Global); } } } if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(bulkGetCacheItemResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(bulkGetCacheItemResponse, Common.Protobuf.Response.Type.BULK_GET_CACHEITEM)); } else { Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.BULK_GET_CACHEITEM); response.bulkGetCacheItem = bulkGetCacheItemResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (OperationCanceledException ex) { exception = ex.ToString(); Dispose(); } catch (System.Exception exc) { _getBulkCacheItemResult = OperationResult.Failure; exception = exc.ToString(); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetBulk.ToLower()); log.GenerateBulkGetAPILogItem(cmdInfo.Keys.Length, cmdInfo.providerName, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString(), count); } if (pooledEntries != null && pooledEntries.Count > 0) { MiscUtil.ReturnEntriesToPool(pooledEntries, clientManager.CacheTransactionalPool); } } catch { } try { cmdInfo.FlagMap?.MarkFree(NCModulesConstants.SocketServer); } catch { } } if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("BulkGetCmd.Exec", "cmd executed on cache"); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo = default(CommandInfo); int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } NCache nCache = clientManager.CmdExecuter as NCache; if (!cmdInfo.DoAsync) { try { Notifications notification = null; if (cmdInfo.DsClearedId != -1) { notification = new Notifications(clientManager.ClientID, -1, -1, -1, -1, cmdInfo.DsClearedId , Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None); //DataFilter not required } OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); operationContext.Add(OperationContextFieldName.WriteThruProviderName, cmdInfo.providerName); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); nCache.Cache.Clear(cmdInfo.FlagMap, notification, operationContext); stopWatch.Stop(); Alachisoft.NCache.Common.Protobuf.ClearResponse clearResponse = new Alachisoft.NCache.Common.Protobuf.ClearResponse(); if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(clearResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(clearResponse, Common.Protobuf.Response.Type.CLEAR)); } else { Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); response.clearResponse = clearResponse; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.CLEAR); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { //PROTOBUF:RESPONSE exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.Clear.ToLower()); log.GenerateClearAPILogItem(cmdInfo.FlagMap, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } } else { OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); operationContext.Add(OperationContextFieldName.WriteThruProviderName, cmdInfo.providerName); nCache.Cache.ClearAsync(cmdInfo.FlagMap, new Notifications(clientManager.ClientID, Convert.ToInt32(cmdInfo.RequestId), -1, -1, 0, cmdInfo.DsClearedId, EventDataFilter.None, EventDataFilter.None) , operationContext); stopWatch.Stop(); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.ClearAsync.ToLower()); log.GenerateClearAsyncAPILogItem(cmdInfo.FlagMap, cmdInfo.DsClearedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } } finally { cmdInfo.FlagMap?.MarkFree(NCModulesConstants.SocketServer); } }
public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { // int overload; string exception = null; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); long messageCount = 0; try { NCache nCache = clientManager.CmdExecuter as NCache; if (nCache != null) { OperationContext operationContext = null; CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); messageCount = nCache.Cache.GetMessageCount(command.messageCountCommand.topicName, operationContext); _operationSuccessStatus = true; } stopwatch.Stop(); Common.Protobuf.MessageCountResponse messageCountResponse = new Common.Protobuf.MessageCountResponse(); messageCountResponse.messageCount = messageCount; if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(messageCountResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(messageCountResponse, Common.Protobuf.Response.Type.MESSAGE_COUNT)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.messageCountResponse = messageCountResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.MESSAGE_COUNT); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception e) { exception = e.ToString(); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponseWithType(e, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopwatch.Elapsed; try { if (Management.APILogging.APILogManager.APILogManger != null && Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.MessageCount.ToLower()); log.GenerateCacheCountAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), messageCount); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; int overload; string exception = null; System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); try { overload = command.MethodOverload; stopWatch.Start(); cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); // _commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); } return; } try { CallbackInfo cbUpdate = null; CallbackInfo cbRemove = null; CallbackType callbackType = CallbackType(cmdInfo.callbackType); if (cmdInfo.dataFilter != -1) //Default value in protbuf set to -1 { EventDataFilter datafilter = (EventDataFilter)cmdInfo.dataFilter; cbUpdate = new CallbackInfo(!string.IsNullOrEmpty(cmdInfo.SurrogateClientID) ? cmdInfo.SurrogateClientID : clientManager.ClientID, cmdInfo.UpdateCallbackId, datafilter, callbackType); cbRemove = new CallbackInfo(!string.IsNullOrEmpty(cmdInfo.SurrogateClientID) ? cmdInfo.SurrogateClientID : clientManager.ClientID, cmdInfo.RemoveCallbackId, datafilter, cmdInfo.NotifyOnExpiration, callbackType); } else { cbUpdate = new CallbackInfo(!string.IsNullOrEmpty(cmdInfo.SurrogateClientID) ? cmdInfo.SurrogateClientID : clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None, callbackType); cbRemove = new CallbackInfo(!string.IsNullOrEmpty(cmdInfo.SurrogateClientID) ? cmdInfo.SurrogateClientID : clientManager.ClientID, cmdInfo.RemoveCallbackId, EventDataFilter.None, cmdInfo.NotifyOnExpiration, callbackType); } NCache nCache = clientManager.CmdExecuter as NCache; OperationContext context = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); context.Add(OperationContextFieldName.ClientId, !string.IsNullOrEmpty(cmdInfo.SurrogateClientID) ? cmdInfo.SurrogateClientID : clientManager.ClientID); context.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout); context.CancellationToken = CancellationToken; CommandsUtil.PopulateClientIdInContext(ref context, clientManager.ClientAddress); nCache.Cache.RegisterKeyNotificationCallback(cmdInfo.Keys, cbUpdate, cbRemove, context); if (clientManager.ClientVersion < 5000 && !clientManager.CreateEventSubscription) { Util.EventHelper.SubscribeEvents(clientManager.ClientID, TopicConstant.ItemLevelEventsTopic, nCache, context); clientManager.CreateEventSubscription = true; } stopWatch.Stop(); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.RegisterBulkKeyNotifResponse registerBulkKeyNotifResponse = new Alachisoft.NCache.Common.Protobuf.RegisterBulkKeyNotifResponse(); if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(registerBulkKeyNotifResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(registerBulkKeyNotifResponse, Common.Protobuf.Response.Type.REGISTER_BULK_KEY_NOTIF)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.registerBulkKeyNotifResponse = registerBulkKeyNotifResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.REGISTER_BULK_KEY_NOTIF); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (OperationCanceledException ex) { exception = ex.ToString(); Dispose(); } catch (Exception exc) { exception = exc.ToString(); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.RegisterKeyNotificationCallback.ToLower()); log.GenerateKeyNotificationCallback(cmdInfo.Keys.Length, cmdInfo.UpdateCallbackId, cmdInfo.RemoveCallbackId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { NCache nCache = clientManager.CmdExecuter as NCache; System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); int overload = 1; string exceptionMessage = null; try { if (nCache != null) { var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); if (command.commandVersion < 1) { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else { operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture)); } operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); _clientId = clientManager.ClientID; _command = command.mesasgeAcknowledgmentCommand; _topicWiseMessageIds = new Dictionary <string, IList <string> >(); foreach (KeyValue values in _command.values) { string key = values.key; var messageIdsList = new List <string>(); foreach (ValueWithType valueWithType in values.value) { if (valueWithType.value != null) { messageIdsList.Add(valueWithType.value); } } _topicWiseMessageIds.Add(key, messageIdsList); } nCache.Cache.AcknowledgeMessageReceipt(clientManager.ClientID, _topicWiseMessageIds, operationContext); stopWatch.Stop(); MessageAcknowledgmentResponse messageAckResponse = new MessageAcknowledgmentResponse(); if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(messageAckResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(messageAckResponse, Common.Protobuf.Response.Type.MESSAGE_ACKNOWLEDGEMENT)); } else { Common.Protobuf.Response response = new Common.Protobuf.Response(); response.messageAcknowledgmentResponse = messageAckResponse; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.MESSAGE_ACKNOWLEDGEMENT); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } } catch (System.Exception exc) { exceptionMessage = exc.ToString(); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.AcknowledgeTopicMessages); log.GenerateAcknowledgeTopicMessagesAPILogItem(executionTime, clientManager.ClientID, clientManager.ClientIP, overload, _topicWiseMessageIds, exceptionMessage); // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); } } catch { } } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; byte[] data = null; int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); try { overload = command.MethodOverload; stopWatch.Start(); cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); } return; } Alachisoft.NCache.Common.Protobuf.RaiseCustomEventCommand notifcommand = command.raiseCustomEventCommand; try { NCache nCache = clientManager.CmdExecuter as NCache; OperationContext operationContext = null; CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); nCache.Cache.SendNotification(notifcommand.notifIf, notifcommand.data, operationContext); Alachisoft.NCache.Common.Protobuf.RaiseCustomEventResponse raiseCustomEventResponse = new Alachisoft.NCache.Common.Protobuf.RaiseCustomEventResponse(); if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(raiseCustomEventResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(raiseCustomEventResponse, Common.Protobuf.Response.Type.RAISE_CUSTOM_EVENT)); } else { Common.Protobuf.Response response = new Common.Protobuf.Response(); response.raiseCustomEventResponse = raiseCustomEventResponse; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.RAISE_CUSTOM_EVENT); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { exception = exc.ToString(); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { stopWatch.Stop(); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.RaiseCustomEvent.ToLower()); log.GenerateraiseCustomAPILogItem(notifcommand.notifIf.Length, notifcommand.data.Length, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); int overload = 1; bool isTopicCreated = false; string exceptionMessage = null; try { NCache nCache = clientManager.CmdExecuter as NCache; var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); if (command.commandVersion < 1) { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 SP1 or later { operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture)); } if (nCache != null) { Common.Protobuf.GetTopicCommand getTopicCommand = command.getTopicCommand; _command = getTopicCommand; TopicOperation topicOperation = new TopicOperation(getTopicCommand.topicName, (TopicOperationType)getTopicCommand.type); isTopicCreated = nCache.Cache.TopicOpertion(topicOperation, operationContext); stopWatch.Stop(); Common.Protobuf.Response response = new Common.Protobuf.Response(); Common.Protobuf.GetTopicResponse getTopicResponse = new Common.Protobuf.GetTopicResponse(); getTopicResponse.success = isTopicCreated; if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(getTopicResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(getTopicResponse, Common.Protobuf.Response.Type.GET_TOPIC)); } else { //PROTOBUF:RESPONSE response.getTopicResponse = getTopicResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.GET_TOPIC); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } } catch (Exception exc) { exceptionMessage = exc.ToString(); _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { string methodName = null; if ((TopicOperationType)_command.type == TopicOperationType.Get) { methodName = MethodsName.GetTopic; } else { methodName = MethodsName.CreateTopic; } APILogItemBuilder log = new APILogItemBuilder(methodName); log.GenerateGetCreateOrDeleteTopicAPILogItem(_command.topicName, executionTime, clientManager.ClientID, clientManager.ClientIP, overload, isTopicCreated, exceptionMessage); // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); } } catch { } } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; int overload; string exception = null; System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); try { overload = command.MethodOverload; stopWatch.Start(); cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //_commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { CallbackInfo cbUpdate = null; CallbackInfo cbRemove = null; CallbackType callbackType = (CallbackType)cmdInfo.callbackType; if (cmdInfo.dataFilter != -1) //Default value in protbuf set to -1 { EventDataFilter datafilter = (EventDataFilter)cmdInfo.dataFilter; cbUpdate = new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, datafilter, callbackType); cbRemove = new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, datafilter, cmdInfo.NotifyOnExpiration, callbackType); } else { cbUpdate = new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None, callbackType); cbRemove = new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, EventDataFilter.None, cmdInfo.NotifyOnExpiration, callbackType); } NCache nCache = clientManager.CmdExecuter as NCache; OperationContext context = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); context.Add(OperationContextFieldName.ClientId, clientManager.ClientID); if (command.commandVersion < 1) { context.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 SP1 or later { context.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.clientLastViewId.ToString(CultureInfo.InvariantCulture)); } CommandsUtil.PopulateClientIdInContext(ref context, clientManager.ClientAddress); nCache.Cache.RegisterKeyNotificationCallback(cmdInfo.Key, cbUpdate, cbRemove , context); stopWatch.Stop(); if (clientManager.ClientVersion < 5000 && !clientManager.CreateEventSubscription) { Util.EventHelper.SubscribeEvents(clientManager.ClientID, TopicConstant.ItemLevelEventsTopic, nCache, context); clientManager.CreateEventSubscription = true; } //PROTOBUF:RESPONSE // Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.RegisterKeyNotifResponse registerKeyNotifResponse = new Alachisoft.NCache.Common.Protobuf.RegisterKeyNotifResponse(); //response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF; //response.registerKeyNotifResponse = registerKeyNotifResponse; //response.requestId = command.registerKeyNotifCommand.requestId; //response.commandID = command.commandID; //_serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response,Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF)); if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(registerKeyNotifResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(registerKeyNotifResponse, Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.registerKeyNotifResponse = registerKeyNotifResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } //_commandBytes = clientManager.ReplyPacket("REGKEYNOTIFRESULT \"" + cmdInfo.RequestId + "\"", new byte[0]); } catch (Exception exc) { exception = exc.ToString(); //_commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.RegisterKeyNotificationCallback.ToLower()); log.GenerateKeyNotificationCallback(1, cmdInfo.UpdateCallbackId, cmdInfo.RemoveCallbackId, 1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); } } catch { } } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (ArgumentOutOfRangeException arEx) { if (SocketServer.Logger.IsErrorLogsEnabled) { SocketServer.Logger.NCacheLog.Error("LockCommand", "command: " + command + " Error" + arEx); } _lockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { // _resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(arEx, base.immatureId), base.ParsingExceptionMessage(arEx)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } catch (Exception exc) { _lockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; object lockId = null; DateTime lockDate = DateTime.Now; var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); bool res = nCache.Cache.Lock(cmdInfo.Key, cmdInfo.LockTimeout, out lockId, out lockDate, operationContext); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.VerifyLockResponse verifyLockResponse = new Alachisoft.NCache.Common.Protobuf.VerifyLockResponse(); verifyLockResponse.lockId = lockId.ToString(); verifyLockResponse.success = res; verifyLockResponse.lockExpiration = lockDate.Ticks; if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(verifyLockResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(verifyLockResponse, Common.Protobuf.Response.Type.LOCK_VERIFY)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.lockVerify = verifyLockResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.LOCK_VERIFY); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { _lockResult = OperationResult.Failure; //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int dataLength = 0; int overload; string exception = null; System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (ArgumentOutOfRangeException arEx) { if (SocketServer.Logger.IsErrorLogsEnabled) { SocketServer.Logger.NCacheLog.Error("GetCommand", "command: " + command + " Error" + arEx); } _getResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } catch (Exception exc) { _getResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } Alachisoft.NCache.Common.Protobuf.GetResponse getResponse = null; CompressedValueEntry flagValueEntry = null; OperationContext operationContext = null; NCache nCache = clientManager.CmdExecuter as NCache; try { object lockId = cmdInfo.LockId; ulong version = cmdInfo.CacheItemVersion; DateTime lockDate = new DateTime(); operationContext = _operationContext; operationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); if (cmdInfo.LockAccessType == LockAccessType.ACQUIRE) { operationContext.Add(OperationContextFieldName.ClientThreadId, clientManager.ClientID); operationContext.Add(OperationContextFieldName.ClientThreadId, cmdInfo.ThreadId); operationContext.Add(OperationContextFieldName.IsRetryOperation, command.isRetryCommand); } flagValueEntry = nCache.Cache.GetGroup(cmdInfo.Key, cmdInfo.FlagMap, null, null, ref version, ref lockId, ref lockDate, cmdInfo.LockTimeout, cmdInfo.LockAccessType, operationContext); stopWatch.Stop(); UserBinaryObject ubObj = null; getResponse = _getResponse; if (flagValueEntry != null) { if (flagValueEntry.Value is UserBinaryObject) { ubObj = (UserBinaryObject)flagValueEntry.Value; } else { var flag = flagValueEntry.Flag; ubObj = (UserBinaryObject)nCache.Cache.SocketServerDataService.GetClientData(flagValueEntry.Value, ref flag, LanguageContext.DOTNET); } if (flagValueEntry.Value != null) { getResponse.itemType = MiscUtil.EntryTypeToProtoItemType(flagValueEntry.Type);// (Alachisoft.NCache.Common.Protobuf.CacheItemType.ItemType)flagValueEntry.Type; } } if (ubObj != null) { dataLength = ubObj.Length; } if (clientManager.ClientVersion >= 5000) { if (lockId != null) { getResponse.lockId = lockId.ToString(); } getResponse.requestId = cmdInfo.RequestId; getResponse.commandID = command.commandID; getResponse.lockTime = lockDate.Ticks; getResponse.version = version; if (ubObj == null) { // response.get = getResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(getResponse, Common.Protobuf.Response.Type.GET)); } else { //_dataPackageArray = ubObj.Data; getResponse.flag = flagValueEntry.Flag.Data; getResponse.data.AddRange(ubObj.DataList); // response.get = getResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(getResponse, Common.Protobuf.Response.Type.GET)); } } else { Alachisoft.NCache.Common.Protobuf.Response response = Stash.ProtobufResponse; response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.commandID = command.commandID; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET; if (lockId != null) { getResponse.lockId = lockId.ToString(); } getResponse.lockTime = lockDate.Ticks; getResponse.version = version; if (ubObj == null) { response.get = getResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } else { getResponse.flag = flagValueEntry.Flag.Data; getResponse.data.AddRange(ubObj.DataList); response.get = getResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } } catch (Exception exc) { exception = exc.ToString(); _getResult = OperationResult.Failure; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { operationContext?.MarkFree(NCModulesConstants.SocketServer); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { int resutlt = 0; if (getResponse != null) { resutlt = dataLength; } string methodName = null; if (cmdInfo.LockAccessType == LockAccessType.ACQUIRE) { methodName = MethodsName.GET.ToLower(); } else { methodName = MethodsName.GET.ToLower(); } APILogItemBuilder log = new APILogItemBuilder(methodName); log.GenerateGetCommandAPILogItem(cmdInfo.Key, null, null, (long)cmdInfo.CacheItemVersion, cmdInfo.LockAccessType, cmdInfo.LockTimeout, cmdInfo.LockId, cmdInfo.ProviderName, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resutlt); } } catch { } if (flagValueEntry != null) { MiscUtil.ReturnCompressedEntryToPool(flagValueEntry, clientManager.CacheTransactionalPool); MiscUtil.ReturnEntryToPool(flagValueEntry.Entry, clientManager.CacheTransactionalPool); } } //} //if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("GetCmd.Exec", "cmd executed on cache"); }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; byte[] data = null; NCache nCache = clientManager.CmdExecuter as NCache; int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; serializationContext = nCache.CacheId; cmdInfo = ParseCommand(nCache.Cache, command); } catch (System.Exception exc) { if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } data = new byte[1]; try { var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); //PROTOBUF:RESPONSE bool result = nCache.Cache.AddExpirationHint(cmdInfo.Key, cmdInfo.ExpHint, operationContext); //PROTOBUF:RESPONSE stopWatch.Stop(); AddAttributeResponse addResponse = new AddAttributeResponse(); addResponse.success = result; if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(addResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(addResponse, Response.Type.ADD_ATTRIBUTE)); } else { //PROTOBUF:RESPONSE Response response = new Response(); response.addAttributeResponse = addResponse; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.ADD_ATTRIBUTE); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (System.Exception exc) { //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); //PROTOBUF:RESPONSEexception = exc.ToString(); exception = exc.ToString(); //_resultPacket = Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { stopWatch.Stop(); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.SetAttributes.ToLower()); Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpHint, null); log.GenerateAddAttributeAPILogItem(cmdInfo.Key, expirationHint["absolute-expiration"] != null ? (long)expirationHint["absolute-expiration"] : -1, expirationHint["dependency"] != null ? expirationHint["dependency"] as ArrayList : null, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString()); } } catch { } } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("LockCmd.Exec", "cmd parsed"); } } catch (ArgumentOutOfRangeException arEx) { if (SocketServer.Logger.IsErrorLogsEnabled) { SocketServer.Logger.NCacheLog.Error("LockCommand", "command: " + command + " Error" + arEx); } _lockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { // _resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(arEx, base.immatureId), base.ParsingExceptionMessage(arEx)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } catch (Exception exc) { _lockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); } return; } object lockId = null; try { NCache nCache = clientManager.CmdExecuter as NCache; DateTime lockDate = DateTime.Now; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); operationContext.Add(OperationContextFieldName.ClientThreadId, cmdInfo.ThreadId); operationContext.Add(OperationContextFieldName.IsRetryOperation, command.isRetryCommand); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); bool res = nCache.Cache.Lock(cmdInfo.Key, cmdInfo.LockTimeout, out lockId, out lockDate, operationContext); stopWatch.Stop(); string lockIdString = lockId == null ? "" : lockId.ToString(); //PROTOBUF:RESPONSE //Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.LockResponse lockResponse = new Alachisoft.NCache.Common.Protobuf.LockResponse(); lockResponse.lockId = lockIdString; lockResponse.locked = res; lockResponse.lockTime = lockDate.Ticks; if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(lockResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(lockResponse, Common.Protobuf.Response.Type.LOCK)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.lockResponse = lockResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.LOCK); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { _lockResult = OperationResult.Failure; //PROTOBUF:RESPONSE exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.Lock.ToLower()); log.GenerateLockAPILogItem(cmdInfo.Key, cmdInfo.LockTimeout, lockId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("LockCmd.Exec", "cmd executed on cache"); } } }
public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); int overload = 1; string exceptionMessage = null; NCache nCache = clientManager.CmdExecuter as NCache; try { if (nCache != null) { _command = command.messagePublishCommand; var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); if (command.commandVersion < 1) { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else { operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture)); } CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); BitSet flag = BitSet.CreateAndMarkInUse(clientManager.CacheFakePool, NCModulesConstants.SocketServer); flag.Data = ((byte)(byte)_command.flag); try { foreach (KeyValuePair pair in _command.keyValuePair) { _metaData.Add(pair.key, pair.value); } ICollection dataList = _command.data as ICollection; if (dataList != null) { _value = UserBinaryObject.CreateUserBinaryObject(dataList); } else { _value = _command.data; } nCache.Cache.PublishMessage(_command.messageId, _value, _command.creationTime, _command.expiration, _metaData, flag, operationContext ); stopWatch.Stop(); } finally { flag?.MarkFree(NCModulesConstants.SocketServer); } // MessagePublishResponse messagePublishResponse = new MessagePublishResponse(); //response.requestId = Convert.ToInt64(_command.requestId); //response.commandID = command.commandID; //response.responseType = Response.Type.MESSAGE_PUBLISH; //_serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(response,Common.Protobuf.Response.Type.MESSAGE_PUBLISH)); if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(messagePublishResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(messagePublishResponse, Common.Protobuf.Response.Type.MESSAGE_PUBLISH)); } else { //PROTOBUF:RESPONSE Response response = new Response(); response.messagePublishResponse = messagePublishResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.MESSAGE_PUBLISH); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } } catch (System.Exception exc) { exceptionMessage = exc.ToString(); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.PublishMessageOnTopic); int size = _value != null ? ((UserBinaryObject)_value).Size : 0; bool notifyOnFailure = bool.Parse(_metaData[TopicConstant.NotifyOption] as string); DeliveryOption deliveryOption = (DeliveryOption)(int.Parse(_metaData[TopicConstant.DeliveryOption] as string)); string topicName = _metaData[TopicConstant.TopicName] as string; topicName = topicName.Split(TopicConstant.TopicSeperator)[1]; log.GeneratePublishTopicMessageAPILogItem(topicName, _command.messageId, size, deliveryOption, notifyOnFailure, _command.expiration, executionTime, clientManager.ClientID, clientManager.ClientIP, overload, exceptionMessage); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; int overload; string exception = null; System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } int count = 0; string keyPackage = null; try { NCache nCache = clientManager.CmdExecuter as NCache; CommandsUtil.PopulateClientIdInContext(ref cmdInfo.OperationContext, clientManager.ClientAddress); EnumerationDataChunk nextChunk = nCache.Cache.GetNextChunk(cmdInfo.Pointer, cmdInfo.OperationContext); stopWatch.Stop(); if (!clientManager.EnumerationPointers.ContainsKey(cmdInfo.Pointer.Id)) { clientManager.EnumerationPointers.Add(cmdInfo.Pointer.Id, cmdInfo.Pointer); } else { clientManager.EnumerationPointers[cmdInfo.Pointer.Id] = cmdInfo.Pointer; } if (clientManager.ClientVersion >= 5000) { Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse getNextChunkResponse = new Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse(); getNextChunkResponse.requestId = Convert.ToInt64(cmdInfo.RequestId); getNextChunkResponse.commandID = command.commandID; getNextChunkResponse.intendedRecipient = cmdInfo.OperationContext.GetValueByField(OperationContextFieldName.IntendedRecipient).ToString(); if (nextChunk.Data != null) { getNextChunkResponse.keys.AddRange(nextChunk.Data); } getNextChunkResponse.enumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufEnumerationPointer(nextChunk.Pointer); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(getNextChunkResponse, Common.Protobuf.Response.Type.GET_NEXT_CHUNK)); } else { Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse getNextChunkResponse = new Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.commandID = command.commandID; response.intendedRecipient = cmdInfo.OperationContext.GetValueByField(OperationContextFieldName.IntendedRecipient).ToString(); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_NEXT_CHUNK; response.getNextChunkResponse = getNextChunkResponse; if (nextChunk.Data != null) { getNextChunkResponse.keys.AddRange(nextChunk.Data); } getNextChunkResponse.enumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufEnumerationPointer(nextChunk.Pointer); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetNextChunk.ToLower()); log.GenerateGetEnumeratorAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; //while(true) //{ Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); } return; } //TODO byte[] data = null; Hashtable removeResult = null; try { NCache nCache = clientManager.CmdExecuter as NCache; Notifications cbEnrty = null; if (cmdInfo.DsItemsRemovedId != -1) { cbEnrty = new Notifications(clientManager.ClientID, -1, -1, -1, -1, cmdInfo.DsItemsRemovedId , Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None); //DataFilter not required } OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout); operationContext.CancellationToken = CancellationToken; removeResult = (Hashtable)nCache.Cache.Remove(cmdInfo.Keys, cmdInfo.FlagMap, cbEnrty, cmdInfo.ProviderName, operationContext); stopWatch.Stop(); BulkRemoveResponseBuilder.BuildResponse(removeResult, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, command.requestID, nCache.Cache, clientManager); } catch (OperationCanceledException ex) { exception = ex.ToString(); Dispose(); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; exception = exc.ToString(); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.REMOVEBULK.ToLower()); // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); log.GenerateBulkDeleteAPILogItem(cmdInfo.Keys.Length, cmdInfo.FlagMap, cmdInfo.ProviderName, cmdInfo.DsItemsRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } if (removeResult?.Count > 0) { foreach (DictionaryEntry removeEntry in removeResult) { if (removeEntry.Value is CompressedValueEntry compressedValueEntry) { MiscUtil.ReturnEntryToPool(compressedValueEntry.Entry, clientManager.CacheTransactionalPool); MiscUtil.ReturnCompressedEntryToPool(compressedValueEntry, clientManager.CacheTransactionalPool); } } } } } finally { cmdInfo.FlagMap.MarkFree(NCModulesConstants.SocketServer); } //} }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; int overload; string exception = null; System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); try { overload = command.MethodOverload; stopWatch.Start(); cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout); operationContext.CancellationToken = CancellationToken; CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); nCache.Cache.UnregisterKeyNotificationCallback(cmdInfo.Keys , new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None) //DataFilter not required while unregistration , new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, EventDataFilter.None) //DataFilter not required while unregistration , operationContext); stopWatch.Stop(); Alachisoft.NCache.Common.Protobuf.UnregisterBulkKeyNotifResponse unregResponse = new Common.Protobuf.UnregisterBulkKeyNotifResponse(); if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(unregResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(unregResponse, Common.Protobuf.Response.Type.UNREGISTER_BULK_KEY_NOTIF)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.unregisterBulkKeyNotifResponse = unregResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.UNREGISTER_BULK_KEY_NOTIF); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (OperationCanceledException ex) { exception = ex.ToString(); Dispose(); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.UnRegisterKeyNotificationCallback.ToLower()); log.GenerateKeyNotificationCallback(cmdInfo.Keys.Length, cmdInfo.UpdateCallbackId, cmdInfo.RemoveCallbackId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (System.Exception exc) { _removeResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } CompressedValueEntry flagValueEntry = null; NCache nCache = clientManager.CmdExecuter as NCache; if (!cmdInfo.DoAsync) { OperationContext operationContext = null; try { Notifications notification = null; if (cmdInfo.DsItemRemovedId != -1) { notification = new Notifications(clientManager.ClientID, -1, -1, -1, -1, cmdInfo.DsItemRemovedId , Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None); //DataFilter not required } operationContext = _operationContext; operationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); operationContext.Add(OperationContextFieldName.MethodOverload, overload); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); flagValueEntry = nCache.Cache.Remove(cmdInfo.Key, cmdInfo.FlagMap, notification, cmdInfo.LockId, cmdInfo.Version, cmdInfo.LockAccessType, cmdInfo.ProviderName, operationContext); stopWatch.Stop(); UserBinaryObject ubObject = null; if (flagValueEntry != null) { if (flagValueEntry.Value is UserBinaryObject) { ubObject = (UserBinaryObject)flagValueEntry.Value; } else { var flag = flagValueEntry.Flag; ubObject = (flagValueEntry == null) ? null : (UserBinaryObject)nCache.Cache.SocketServerDataService.GetClientData(flagValueEntry.Value, ref flag, LanguageContext.DOTNET); } } //PROTOBUF:RESPONSE RemoveResponse removeResponse = _removeResponse; if (ubObject != null) { removeResponse.value.AddRange(ubObject.DataList); removeResponse.flag = flagValueEntry.Flag.Data; removeResponse.itemType = MiscUtil.EntryTypeToProtoItemType(flagValueEntry.Type); } if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(removeResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(removeResponse, Response.Type.REMOVE)); } else { Response response = Stash.ProtobufResponse; { response.remove = removeResponse; }; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.REMOVE); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (System.Exception exc) { _removeResult = OperationResult.Failure; exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { operationContext?.MarkFree(NCModulesConstants.SocketServer); cmdInfo.FlagMap?.MarkFree(NCModulesConstants.SocketServer); TimeSpan executionTime = stopWatch.Elapsed; if (flagValueEntry != null) { MiscUtil.ReturnEntryToPool(flagValueEntry.Entry, clientManager.CacheTransactionalPool); MiscUtil.ReturnCompressedEntryToPool(flagValueEntry, clientManager.CacheTransactionalPool); } try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.REMOVE.ToLower()); log.GenerateRemoveAPILogItem(cmdInfo.Key, cmdInfo.FlagMap, cmdInfo.LockId, (long)cmdInfo.Version, cmdInfo.LockAccessType, cmdInfo.ProviderName, cmdInfo.DsItemRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } } else { OperationContext operationContext = null; try { cmdInfo.FlagMap = new BitSet { Data = cmdInfo.FlagMap.Data }; object[] package = null; if (cmdInfo.RequestId != -1 || cmdInfo.DsItemRemovedId != -1) { package = new object[] { cmdInfo.Key, cmdInfo.FlagMap, new Notifications(clientManager.ClientID, Convert.ToInt32(cmdInfo.RequestId), -1, -1, (short)(cmdInfo.RequestId == -1 ? -1 : 0), cmdInfo.DsItemRemovedId , Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None), cmdInfo.ProviderName }; //DataFilter not required } else { package = new object[] { cmdInfo.Key, cmdInfo.FlagMap, null, cmdInfo.ProviderName }; } operationContext = OperationContext.CreateAndMarkInUse(clientManager.CacheFakePool, NCModulesConstants.SocketServer); operationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); operationContext.Add(OperationContextFieldName.MethodOverload, overload); nCache.Cache.RemoveAsync(package, operationContext); stopWatch.Stop(); } finally { operationContext?.MarkFree(NCModulesConstants.SocketServer); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.RemoveAsync.ToLower()); log.GenerateRemoveAPILogItem(cmdInfo.Key, cmdInfo.FlagMap, cmdInfo.LockId, (long)cmdInfo.Version, cmdInfo.LockAccessType, cmdInfo.ProviderName, cmdInfo.DsItemRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("UnlockCmd.Exec", "cmd parsed"); } } catch (ArgumentOutOfRangeException arEx) { if (SocketServer.Logger.IsErrorLogsEnabled) { SocketServer.Logger.NCacheLog.Error("UnlockCommand", "command: " + command + " Error" + arEx); } _unlockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } catch (Exception exc) { _unlockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); nCache.Cache.Unlock(cmdInfo.Key, cmdInfo.lockId, cmdInfo.isPreemptive, operationContext); stopWatch.Stop(); //PROTOBUF:RESPONSE // Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.UnlockResponse unlockResponse = new Alachisoft.NCache.Common.Protobuf.UnlockResponse(); if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(unlockResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(unlockResponse, Common.Protobuf.Response.Type.UNLOCK)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.unlockResponse = unlockResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.UNLOCK); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { exception = exc.ToString(); _unlockResult = OperationResult.Failure; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.Unlock.ToLower()); log.GeneratUnlockAPILogItem(cmdInfo.Key, cmdInfo.lockId != null?cmdInfo.lockId.ToString() :null, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("UnlockCmd.Exec", "cmd executed on cache"); } } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; int overload; string exception = null; System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); try { overload = command.MethodOverload; stopWatch.Start(); cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //_commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); nCache.Cache.UnregisterKeyNotificationCallback(cmdInfo.Key , new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None) //DataFilter not required while unregistration , new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, EventDataFilter.None) //DataFilter not required while unregistration , operationContext); stopWatch.Stop(); //Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.UnregisterKeyNotifResponse unregisterKeyNotifResponse = new Alachisoft.NCache.Common.Protobuf.UnregisterKeyNotifResponse(); // response.requestId = Convert.ToInt64(cmdInfo.RequestId); // response.commandID = command.commandID; // response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.UNREGISTER_KEY_NOTIF; //response.unregisterKeyNotifResponse = unregisterKeyNotifResponse; // _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response,Common.Protobuf.Response.Type.UNREGISTER_KEY_NOTIF)); //_commandBytes = clientManager.ReplyPacket("UNREGKEYNOTIFRESULT \"" + cmdInfo.RequestId + "\"", new byte[0]); if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(unregisterKeyNotifResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(unregisterKeyNotifResponse, Common.Protobuf.Response.Type.UNREGISTER_KEY_NOTIF)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.unregisterKeyNotifResponse = unregisterKeyNotifResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.UNREGISTER_KEY_NOTIF); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.UnRegisterKeyNotificationCallback.ToLower()); log.GenerateKeyNotificationCallback(1, cmdInfo.UpdateCallbackId, cmdInfo.RemoveCallbackId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (System.Exception exc) { _removeResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } NCache nCache = clientManager.CmdExecuter as NCache; if (!cmdInfo.DoAsync) { try { Notifications notification = null; if (cmdInfo.DsItemRemovedId != -1) { notification = new Notifications(clientManager.ClientID, -1, -1, -1, -1, cmdInfo.DsItemRemovedId , Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None); //DataFilter not required } OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); operationContext.Add(OperationContextFieldName.MethodOverload, overload); operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); nCache.Cache.Delete(cmdInfo.Key, cmdInfo.FlagMap, notification, cmdInfo.LockId, cmdInfo.Version, cmdInfo.LockAccessType, operationContext); stopWatch.Stop(); //PROTOBUF: RESPONSE DeleteResponse deleteResponse = new DeleteResponse(); if (clientManager.ClientVersion >= 5000) { ResponseHelper.SetResponse(deleteResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(deleteResponse, Response.Type.DELETE)); } else { //PROTOBUF:RESPONSE Response response = new Response(); response.deleteResponse = deleteResponse; ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.DELETE); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (System.Exception exc) { _removeResult = OperationResult.Failure; exception = exc.ToString(); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.DELETE.ToLower()); log.GenerateDeleteAPILogItem(cmdInfo.Key, cmdInfo.FlagMap, cmdInfo.LockId, (long)cmdInfo.Version, cmdInfo.LockAccessType, cmdInfo.ProviderName, cmdInfo.DsItemRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } } else { object[] package = null; if (cmdInfo.RequestId != -1 || cmdInfo.DsItemRemovedId != -1) { package = new object[] { cmdInfo.Key, cmdInfo.FlagMap, new Notifications(clientManager.ClientID, Convert.ToInt32(cmdInfo.RequestId), -1, -1, (short)(cmdInfo.RequestId == -1 ? -1 : 0), cmdInfo.DsItemRemovedId, EventDataFilter.None, EventDataFilter.None) }; //DataFilter not required } else { package = new object[] { cmdInfo.Key, cmdInfo.FlagMap, null, cmdInfo.ProviderName }; } OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.RaiseCQNotification, true); operationContext.Add(OperationContextFieldName.MethodOverload, overload); nCache.Cache.RemoveAsync(package, operationContext); stopWatch.Stop(); TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.DELETEASYNC.ToLower()); log.GenerateDeleteAPILogItem(cmdInfo.Key, cmdInfo.FlagMap, cmdInfo.LockId, (long)cmdInfo.Version, cmdInfo.LockAccessType, cmdInfo.ProviderName, cmdInfo.DsItemRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString()); } } catch { } } } finally { MiscUtil.ReturnBitsetToPool(cmdInfo.FlagMap, clientManager.CacheTransactionalPool); cmdInfo.FlagMap.MarkFree(NCModulesConstants.SocketServer); } }
public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { CommandInfo cmdInfo; string exception = null; int updateCount = 0; int removeCount = 0; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { cmdInfo = ParseCommand(command, clientManager); } catch (System.Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); return; } try { NCache cmdExecuter = clientManager.CmdExecuter as NCache; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); if (cmdInfo.CommandVersion < 1) { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 or later { operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); } CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); PollingResult result = cmdExecuter.Cache.Poll(operationContext); stopWatch.Stop(); PollResponse pollResponse = new PollResponse(); pollResponse.removedKeys.AddRange(result.RemovedKeys); pollResponse.updatedKeys.AddRange(result.UpdatedKeys); updateCount = result.UpdatedKeys.Count; removeCount = result.RemovedKeys.Count; if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(pollResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(pollResponse, Common.Protobuf.Response.Type.POLL)); } else { Common.Protobuf.Response response = new Common.Protobuf.Response(); response.pollResponse = pollResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.POLL); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (System.Exception exc) { exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Management.APILogging.APILogManager.APILogManger != null && Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.Poll.ToLower()); log.GeneratePollCommandAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), updateCount, removeCount); } } catch { } } }