Пример #1
0
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            long   requestId;
            string taskId;
            short  callbackId;
            long   clientLastViewId;

            Common.Protobuf.TaskEnumeratorCommand taskEnumeratorCommand = command.TaskEnumeratorCommand;
            taskId           = taskEnumeratorCommand.TaskId;
            requestId        = command.requestID;
            callbackId       = (short)taskEnumeratorCommand.CallbackId;
            clientLastViewId = command.clientLastViewId;
            try
            {
                ICommandExecuter tempVar = clientManager.CmdExecuter;
                NCache           nCache  = (NCache)((tempVar is NCache) ? tempVar : null);

                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.ClientLastViewId, clientLastViewId);

                List <Common.MapReduce.TaskEnumeratorResult> enumerators =
                    nCache.Cache.GetTaskEnumerator(new Common.MapReduce.TaskEnumeratorPointer(
                                                       clientManager.ClientID, taskId, callbackId), operationContext);

                Common.Protobuf.Response reponse = new Common.Protobuf.Response();
                reponse.requestId = requestId;
                reponse.commandID = command.commandID;
                Common.Protobuf.TaskEnumeratorResponse taskEnumResponse = new Common.Protobuf.TaskEnumeratorResponse();
                foreach (Common.MapReduce.TaskEnumeratorResult rslt in enumerators)
                {
                    taskEnumResponse.TaskEnumeratorResult.Add(Serialization.Formatters.CompactBinaryFormatter.ToByteBuffer(rslt, nCache.Cache.Name));
                }

                reponse.responseType           = Alachisoft.NCache.Common.Protobuf.Response.Type.TASK_ENUMERATOR;
                reponse.TaskEnumeratorResponse = taskEnumResponse;
                _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(reponse));
            }
            catch (Exception ex)
            {
                _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponse(ex, command.requestID, command.commandID));
            }
        }
Пример #2
0
        protected override void CreateCommand()
        {
            try
            {
                base._command = new Common.Protobuf.Command();

                Common.Protobuf.TaskEnumeratorCommand taskEnumeratorCommand =
                    new Common.Protobuf.TaskEnumeratorCommand();
                taskEnumeratorCommand.TaskId     = this.taskId;
                taskEnumeratorCommand.CallbackId = this.callbackId;
                base._command.requestID          = this.RequestId;
                base._command.clientLastViewId   = this.ClientLastViewId;

                base._command.TaskEnumeratorCommand = taskEnumeratorCommand;
                base._command.type = Common.Protobuf.Command.Type.TASK_ENUMERATOR;
            }
            catch (Exception ex)
            {
            }
        }