Beispiel #1
0
 public Alachisoft.NCache.Common.DataStructures.RequestStatus GetRequestStatus(string clientId, long requestId, long commandId)
 {
     return(bookie.GetRequestStatus(clientId, requestId, commandId));
 }
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            NCache      nCache = clientManager.CmdExecuter as NCache;

            //TODO
            byte[] data = null;

            try
            {
                //cmdInfo = ParseCommand(command, clientManager);
                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("ContCmd.Exec", "cmd parsed");
                }
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc));
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }

            try
            {
                //data = new byte[1];
                //data[0] = (byte)(nCache.Cache.Contains(cmdInfo.Key) ? 49 : 48);
                RequestStatus requestStatus;

                if (command.inquiryRequestCommand.serverIP.Equals(ConnectionManager.ServerIpAddress))
                {
                    requestStatus = _bookie.GetRequestStatus(clientManager.ClientID,
                                                             command.inquiryRequestCommand.inquiryRequestId, command.inquiryRequestCommand.inquiryCommandId);
                }
                else
                {
                    requestStatus = nCache.Cache.GetClientRequestStatus(clientManager.ClientID,
                                                                        command.inquiryRequestCommand.inquiryRequestId, command.inquiryRequestCommand.inquiryCommandId,
                                                                        command.inquiryRequestCommand.serverIP);
                    if (requestStatus == null)
                    {
                        requestStatus = new RequestStatus(Common.Enum.RequestStatus.NODE_DOWN);
                    }
                }

                Common.Protobuf.InquiryRequestResponse inquiryResponse = new Common.Protobuf.InquiryRequestResponse();
                inquiryResponse.status = requestStatus.Status;

                if (inquiryResponse.status == Common.Enum.RequestStatus.RECEIVED_AND_EXECUTED)
                {
                    IList existingResponse = requestStatus.RequestResult;
                    foreach (byte[] extRes in existingResponse)
                    {
                        inquiryResponse.value.Add(extRes);
                    }
                }

                inquiryResponse.expirationInterval = _bookie.CleanInterval;

                if (clientManager.ClientVersion >= 5000)
                {
                    Common.Util.ResponseHelper.SetResponse(inquiryResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(inquiryResponse, Common.Protobuf.Response.Type.INQUIRY_REQUEST_RESPONSE));
                }
                else
                {
                    Common.Protobuf.Response response = new Common.Protobuf.Response();
                    response.inquiryRequestResponse = inquiryResponse;
                    Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.INQUIRY_REQUEST_RESPONSE);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc));
                _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc,
                                                                                                             command.requestID, command.commandID, clientManager.ClientVersion));
            }
            if (ServerMonitor.MonitorActivity)
            {
                ServerMonitor.LogClientActivity("ContCmd.Exec", "cmd executed on cache");
            }
        }
Beispiel #3
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            NCache      nCache = clientManager.CmdExecuter as NCache;

            byte[] data = null;

            try
            {
                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("ContCmd.Exec", "cmd parsed");
                }
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }
                return;
            }

            try
            {
                RequestStatus requestStatus;

                if (command.inquiryRequestCommand.serverIP.Equals(ConnectionManager.ServerIpAddress))
                {
                    requestStatus = _bookie.GetRequestStatus(clientManager.ClientID,
                                                             command.inquiryRequestCommand.inquiryRequestId, command.inquiryRequestCommand.inquiryCommandId);
                }
                else
                {
                    requestStatus = nCache.Cache.GetClientRequestStatus(clientManager.ClientID,
                                                                        command.inquiryRequestCommand.inquiryRequestId, command.inquiryRequestCommand.inquiryCommandId,
                                                                        command.inquiryRequestCommand.serverIP);
                    if (requestStatus == null)
                    {
                        requestStatus = new RequestStatus(Common.Enum.RequestStatus.NODE_DOWN);
                    }
                }

                Common.Protobuf.Response response = new Common.Protobuf.Response();
                Common.Protobuf.InquiryRequestResponse inquiryResponse = new Common.Protobuf.InquiryRequestResponse();
                response.requestId     = Convert.ToInt64(command.requestID);
                response.commandID     = command.commandID;
                inquiryResponse.status = requestStatus.Status;

                if (inquiryResponse.status == Common.Enum.RequestStatus.RECEIVED_AND_EXECUTED)
                {
                    IList existingResponse = requestStatus.RequestResult;
                    foreach (byte[] extRes in existingResponse)
                    {
                        inquiryResponse.value.Add(extRes);
                    }
                }

                inquiryResponse.expirationInterval = _bookie.CleanInterval;
                response.responseType           = Common.Protobuf.Response.Type.INQUIRY_REQUEST_RESPONSE;
                response.inquiryRequestResponse = inquiryResponse;
                _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponse(exc,
                                                                                                     command.requestID, command.commandID));
            }
            if (ServerMonitor.MonitorActivity)
            {
                ServerMonitor.LogClientActivity("ContCmd.Exec", "cmd executed on cache");
            }
        }