//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.SerializeExceptionResponseWithoutType(exc, command.requestID, command.commandID));
                }
                return;
            }

            Alachisoft.NCache.Caching.Cache cache = null;

            try
            {
                string server = ConnectionManager.ServerIpAddress;
                int    port   = ConnectionManager.ServerPort;

                Dictionary <string, int> runningServers = new Dictionary <string, int>();
                runningServers = ((NCache)clientManager.CmdExecuter).Cache.GetRunningServers(server, port);

                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse getRunningServerResponse = new Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse();

                //getRunningServerResponse = new List<Common.Protobuf.KeyValuePair>();
                if (runningServers != null)
                {
                    Dictionary <string, int> .Enumerator ide = runningServers.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        Common.Protobuf.KeyValuePair pair = new Common.Protobuf.KeyValuePair();
                        pair.key   = ide.Current.Key;
                        pair.value = ide.Current.Value.ToString();
                        getRunningServerResponse.keyValuePair.Add(pair);
                    }
                }

                response.requestId        = Convert.ToInt64(cmdInfo.RequestId);
                response.commandID        = command.commandID;
                response.getRunningServer = getRunningServerResponse;
                response.responseType     = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_RUNNING_SERVERS;

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithoutType(exc, command.requestID, command.commandID));
            }
        }
        //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;
            }

            Cache cache = null;

            try
            {
                string server = ConnectionManager.ServerIpAddress;
                int port = ConnectionManager.ServerPort;

                Dictionary<string, int> runningServers = new Dictionary<string, int>();

                cache = CacheProvider.Provider.GetCacheInstanceIgnoreReplica(cmdInfo.CacheId);

                if (cache == null) throw new Exception("Cache is not registered");
                if (!cache.IsRunning) throw new Exception("Cache is not running");

                runningServers = cache.GetRunningServers(server, port);
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse getRunningServerResponse = new Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse();

                if (runningServers != null)
                {
                    Dictionary<string, int>.Enumerator ide = runningServers.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        Common.Protobuf.KeyValuePair pair = new Common.Protobuf.KeyValuePair();
                        pair.key = ide.Current.Key;
                        pair.value = ide.Current.Value.ToString();
                        getRunningServerResponse.keyValuePair.Add(pair);
                    }
                }

                response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                response.getRunningServer = getRunningServerResponse;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_RUNNING_SERVERS;

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
Exemple #3
0
        private static Common.Protobuf.MessageKeyValueResponse GetKeyValue(Message entry)
        {
            Common.Protobuf.MessageKeyValueResponse messageKeyValue = new Common.Protobuf.MessageKeyValueResponse();
            Common.Protobuf.KeyValuePair            keyValue        = new Common.Protobuf.KeyValuePair();
            keyValue.key = TopicConstant.DeliveryOption;
            int deliveryOption = (int)entry.MessageMetaData.DeliveryOption;

            keyValue.value = deliveryOption.ToString();
            messageKeyValue.keyValuePair.Add(keyValue);
            return(messageKeyValue);
        }
Exemple #4
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
#if !DEVELOPMENT
            try
            {
                int    bucketSize = 0;
                byte[] buffer     = new byte[0];

                NCache     nCache  = clientManager.CmdExecuter as NCache;
                NewHashmap hashmap = nCache.Cache.GetOwnerHashMap(out bucketSize);

                Common.Protobuf.Response           response           = new Common.Protobuf.Response();
                Common.Protobuf.GetHashmapResponse getHashmapResponse = new Common.Protobuf.GetHashmapResponse();

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

                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)
                    {
                        Common.Protobuf.KeyValuePair keyValue = new Common.Protobuf.KeyValuePair();
                        keyValue.key   = entry.Key.ToString();
                        keyValue.value = entry.Value.ToString();

                        //nCache.Cache.NCacheLog.CriticalInfo("GetHashmapCommand", string.Format("Bucket id : {0} , Server : {1}", keyValue.key, keyValue.value));

                        getHashmapResponse.keyValuePair.Add(keyValue);
                    }
                }

                if (clientManager.ClientVersion >= 5000)
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response, Common.Protobuf.Response.Type.GET_HASHMAP));
                }
                else
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error("GetHashmapCommand.Execute", clientManager.ClientSocket.RemoteEndPoint.ToString() + " : " + exc.ToString());
                }

                //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc));
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
#endif
        }
Exemple #5
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;
            }

            Cache cache = null;

            try
            {
                string server = ConnectionManager.ServerIpAddress;
                int    port   = ConnectionManager.ServerPort;

                Dictionary <string, int> runningServers = new Dictionary <string, int>();

                cache = CacheProvider.Provider.GetCacheInstanceIgnoreReplica(cmdInfo.CacheId);

                if (cache == null)
                {
                    throw new Exception("Cache is not registered");
                }
                if (!cache.IsRunning)
                {
                    throw new Exception("Cache is not running");
                }

                runningServers = cache.GetRunningServers(server, port);
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse getRunningServerResponse = new Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse();

                if (runningServers != null)
                {
                    Dictionary <string, int> .Enumerator ide = runningServers.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        Common.Protobuf.KeyValuePair pair = new Common.Protobuf.KeyValuePair();
                        pair.key   = ide.Current.Key;
                        pair.value = ide.Current.Value.ToString();
                        getRunningServerResponse.keyValuePair.Add(pair);
                    }
                }


                response.requestId        = Convert.ToInt64(cmdInfo.RequestId);
                response.getRunningServer = getRunningServerResponse;
                response.responseType     = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_RUNNING_SERVERS;

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