//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)); } }
//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)); } }