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
            {
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }

                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                EnumerationDataChunk nextChunk = nCache.Cache.GetNextChunk(cmdInfo.Pointer, cmdInfo.OperationContext);

                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetGroupNextChunkResponse getNextChunkResponse = new Alachisoft.NCache.Common.Protobuf.GetGroupNextChunkResponse();
                response.requestId    = Convert.ToInt64(cmdInfo.RequestId);
                response.commandID    = command.commandID;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_GROUP_NEXT_CHUNK;
                response.getGroupNextChunkResponse = getNextChunkResponse;

                getNextChunkResponse.keys.AddRange(nextChunk.Data);
                getNextChunkResponse.groupEnumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufGroupEnumerationPointer(nextChunk.Pointer as GroupEnumerationPointer);

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                exception = exception.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.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.GetGroupNextChunk.ToLower());
                        log.GenerateGetEnumeratorAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 2
0
        internal GetNextChunkCommand(EnumerationPointer pointer)
        {
            base.name = "GetNextChunkCommand";

            _getNextChunkCommand = new Alachisoft.NCache.Common.Protobuf.GetNextChunkCommand();
            _getNextChunkCommand.enumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufEnumerationPointer(pointer);
        }
Ejemplo n.º 3
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            try
            {
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                }

                return;
            }

            int    count      = 0;
            string keyPackage = null;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                EnumerationDataChunk nextChunk = nCache.Cache.GetNextChunk(cmdInfo.Pointer, cmdInfo.OperationContext);

                if (!clientManager.EnumerationPointers.ContainsKey(cmdInfo.Pointer.Id))
                {
                    clientManager.EnumerationPointers.Add(cmdInfo.Pointer.Id, cmdInfo.Pointer);
                }
                else
                {
                    clientManager.EnumerationPointers[cmdInfo.Pointer.Id] = cmdInfo.Pointer;
                }

                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.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)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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
                {
                }
            }
        }