Esempio n. 1
0
        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;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                if (nCache != null)
                {
                    _command = command.getMessageCommand;
                    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));
                    }
                    _clientId = clientManager.ClientID;
                    SubscriptionInfo subInfo = new SubscriptionInfo()
                    {
                        ClientId = clientManager.ClientID
                    };
                    _result = nCache.Cache.GetAssignedMessages(subInfo, operationContext);
                    GetMessageResponseBuilder.BuildResponse(_result, command.commandVersion, _command.requestId.ToString(CultureInfo.InvariantCulture), _serializedResponsePackets, command.commandID, nCache.Cache);
                }
            }
            catch (System.Exception exc)
            {
                exceptionMessage = exc.ToString();
                _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            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.GetTopicMessages);
                        log.GenerateGetTopicMessagesAPILogItem(executionTime, clientManager.ClientID, clientManager.ClientIP, overload, _result, exceptionMessage);
                    }
                }
                catch
                {
                }
            }
        }
Esempio n. 2
0
        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;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                if (nCache != null)
                {
                    _command = command.getMessageCommand;
                    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));
                    }
                    _clientId = clientManager.ClientID;
                    SubscriptionInfo subInfo = new SubscriptionInfo()
                    {
                        ClientId = clientManager.ClientID
                    };

                    MessageResponse response = nCache.Cache.GetAssignedMessages(subInfo, operationContext);
                    stopWatch.Stop();
                    //filter event messages for older clients that use pubsub
                    if (clientManager.ClientVersion < 5000)
                    {
                        if (response.AssignedMessages.ContainsKey(TopicConstant.ItemLevelEventsTopic))
                        {
                            response.AssignedMessages.Remove(TopicConstant.ItemLevelEventsTopic);
                        }
                        if (response.AssignedMessages.ContainsKey(TopicConstant.CollectionEventsTopic))
                        {
                            response.AssignedMessages.Remove(TopicConstant.CollectionEventsTopic);
                        }
                    }

                    GetMessageResponseBuilder.BuildResponse(response.AssignedMessages, command.commandVersion, _command.requestId.ToString(CultureInfo.InvariantCulture), _serializedResponsePackets, command.commandID, command.requestID, nCache, _clientId, clientManager);
                }
            }
            catch (System.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.GetTopicMessages);
                        log.GenerateGetTopicMessagesAPILogItem(executionTime, clientManager.ClientID, clientManager.ClientIP, overload, _messages, exceptionMessage);

                        // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo);
                    }
                }
                catch
                {
                }
            }
        }
Esempio n. 3
0
 public GetMessageCommand(BitSet flagMap)
 {
     name = "GetMessageCommand";
     _getMessgaeCommand      = new Common.Protobuf.GetMessageCommand();
     _getMessgaeCommand.flag = flagMap.Data;
 }