Пример #1
0
        //PROTOBUF
        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;
            }

            try
            {
                NCache     nCache     = clientManager.CmdExecuter as NCache;
                int        bucketSize = 0;
                NewHashmap hashmap    = nCache.Cache.GetOwnerHashMap(out bucketSize);
                byte[]     buffer     = new byte[0];

                //TODO:Incomplete conversion
                Alachisoft.NCache.Common.Protobuf.Response           response           = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetHashmapResponse getHashmapResponse = new Alachisoft.NCache.Common.Protobuf.GetHashmapResponse();

                response.getHashmap   = getHashmapResponse;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_HASHMAP;
                response.requestId    = command.requestID;

                if (hashmap != null)
                {
                    getHashmapResponse.viewId     = hashmap.LastViewId;
                    getHashmapResponse.bucketSize = bucketSize;

                    foreach (string member in hashmap.Members)
                    {
                        getHashmapResponse.members.Add(member);
                    }
                    foreach (DictionaryEntry entry in hashmap.Map)
                    {
                        Alachisoft.NCache.Common.Protobuf.KeyValuePair keyValue =
                            new Alachisoft.NCache.Common.Protobuf.KeyValuePair();
                        keyValue.key   = entry.Key.ToString();
                        keyValue.value = entry.Value.ToString();

                        getHashmapResponse.keyValuePair.Add(keyValue);
                    }
                }
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
Пример #2
0
        //PROTOBUF
        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;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                int bucketSize = 0;
                NewHashmap hashmap = nCache.Cache.GetOwnerHashMap(out bucketSize);
                byte[] buffer = new byte[0];

                //TODO:Incomplete conversion
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetHashmapResponse getHashmapResponse = new Alachisoft.NCache.Common.Protobuf.GetHashmapResponse();

                response.getHashmap = getHashmapResponse;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_HASHMAP;
                response.requestId = command.requestID;

                if (hashmap != null)
                {
                    getHashmapResponse.viewId = hashmap.LastViewId;
                    getHashmapResponse.bucketSize = bucketSize;

                    foreach (string member in hashmap.Members)
                    {
                        getHashmapResponse.members.Add(member);
                    }
                    foreach (DictionaryEntry entry in hashmap.Map)
                    {
                        Alachisoft.NCache.Common.Protobuf.KeyValuePair keyValue =
                            new Alachisoft.NCache.Common.Protobuf.KeyValuePair();
                        keyValue.key = entry.Key.ToString();
                        keyValue.value = entry.Value.ToString();

                        getHashmapResponse.keyValuePair.Add(keyValue);
                    }
                }
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }