Exemple #1
0
        public GetTopicCommand(string topicName, TopicOperationType type)
        {
            name = "GetTopicCommand";

            _getTopicCommand           = new Common.Protobuf.GetTopicCommand();
            _getTopicCommand.topicName = topicName;
            _getTopicCommand.type      = (int)type;
        }
Exemple #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;
            bool   isTopicCreated   = 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));
                }
                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
                {
                }
            }
        }