public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { ///Command: /// GETLOGGINGINFO "requestId" /// string requestId = string.Empty; Alachisoft.NCache.Common.Protobuf.GetLoggingInfoCommand getLoggingInfoCommand = command.getLoggingInfoCommand; requestId = getLoggingInfoCommand.requestId.ToString(); bool errorEnabled = ConnectionManager.GetClientLoggingInfo(LoggingInfo.LoggingType.Error) == LoggingInfo.LogsStatus.Enable; bool detailedEnabled = ConnectionManager.GetClientLoggingInfo(LoggingInfo.LoggingType.Detailed) == LoggingInfo.LogsStatus.Enable; if (!errorEnabled) detailedEnabled = false; try { Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.GetLoggingInfoResponse loggingInfoResponse = new Alachisoft.NCache.Common.Protobuf.GetLoggingInfoResponse(); response.requestId = command.requestID; loggingInfoResponse.errorsEnabled = errorEnabled; loggingInfoResponse.detailedErrorsEnabled = detailedEnabled; response.getLoggingInfoResponse = loggingInfoResponse; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_LOGGING_INFO; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
protected object ExecuteCommandOnCacehServer(Alachisoft.NCache.Common.Protobuf.ManagementCommand command) { ManagementResponse response = null; if (_requestManager != null) { try { response = _requestManager.SendRequest(command) as ManagementResponse; } catch (System.Exception e) { throw new ManagementException(e.Message,e); } if (response != null && response.exception != null) { throw new ManagementException(response.exception.message); } } if (response != null) return response.ReturnValue; return null; }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("RemCmd.Exec", "cmd parsed"); } catch (Exception exc) { _removeResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } NCache nCache = clientManager.CmdExecuter as NCache; try { CallbackEntry cbEntry = null; CompressedValueEntry flagValueEntry = null; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); flagValueEntry = nCache.Cache.Remove(cmdInfo.Key, cmdInfo.FlagMap, cbEntry, cmdInfo.LockId, cmdInfo.LockAccessType, operationContext); UserBinaryObject ubObject = (flagValueEntry == null) ? null : (UserBinaryObject) flagValueEntry.Value; //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.RemoveResponse removeResponse = new Alachisoft.NCache.Common.Protobuf.RemoveResponse(); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REMOVE; response.remove = removeResponse; response.requestId = Convert.ToInt64(cmdInfo.RequestId); if (ubObject != null) { removeResponse.value.AddRange(ubObject.DataList); removeResponse.flag = flagValueEntry.Flag.Data; } _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _removeResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add( Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } finally { if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("RemCmd.Exec", "cmd executed on cache"); } }
public Alachisoft.ContentOptimization.Caching.Expiration Convert(Alachisoft.ContentOptimization.Caching.ExpirationType type) { var expiration = new Alachisoft.ContentOptimization.Caching.Expiration(); expiration.ExpirationType = type; expiration.Duration = this.Duration.HasValue ? this.Duration.Value : 5; return expiration; }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.ManagementCommand command) { object result = null; try { if (command.objectName == ManagementUtil.ManagementObjectName.CacheServer) { result = CacheProvider.ManagementRpcService.InvokeMethodOnTarget(command.methodName, command.overload, GetTargetMethodParameters(command.arguments)); } Alachisoft.NCache.Common.Protobuf.ManagementResponse response = new Alachisoft.NCache.Common.Protobuf.ManagementResponse(); response.methodName = command.methodName; response.version = command.commandVersion; response.requestId = command.requestId; response.returnVal = SerializeResponse(result); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeManagementExceptionResponse(exc, Convert.ToInt32(command.requestId))); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (ArgumentOutOfRangeException arEx) { if (SocketServer.Logger.IsErrorLogsEnabled) SocketServer.Logger.NCacheLog.Error( "LockCommand", "command: " + command + " Error" + arEx); _lockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(arEx, command.requestID)); } return; } catch (Exception exc) { _lockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; object lockId = null; DateTime lockDate = DateTime.Now; bool res = nCache.Cache.Lock(cmdInfo.Key, cmdInfo.LockTimeout, out lockId, out lockDate, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation)); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.VerifyLockResponse verifyLockResponse = new Alachisoft.NCache.Common.Protobuf.VerifyLockResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.LOCK_VERIFY; response.lockVerify = verifyLockResponse; verifyLockResponse.lockId = lockId.ToString(); verifyLockResponse.success = res; verifyLockResponse.lockExpiration = lockDate.Ticks; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _lockResult = OperationResult.Failure; //PROTOBUF:RESPONSE _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); if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("UnlockCmd.Exec", "cmd parsed"); } catch (ArgumentOutOfRangeException arEx) { if (SocketServer.Logger.IsErrorLogsEnabled) SocketServer.Logger.NCacheLog.Error("UnlockCommand", "command: " + command + " Error" + arEx); _unlockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(arEx, command.requestID)); } return; } catch (Exception exc) { _unlockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; nCache.Cache.Unlock(cmdInfo.Key, cmdInfo.lockId, cmdInfo.isPreemptive, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation)); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.UnlockResponse unlockResponse = new Alachisoft.NCache.Common.Protobuf.UnlockResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.UNLOCK; response.unlockResponse = unlockResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _unlockResult = OperationResult.Failure; _serializedResponsePackets.Add(clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc))); } finally { if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("UnlockCmd.Exec", "cmd executed on cache"); } }
public static Alachisoft.NCache.Common.Protobuf.EnumerationPointer ConvertToProtobufEnumerationPointer(Alachisoft.NCache.Common.DataStructures.EnumerationPointer pointer) { Alachisoft.NCache.Common.Protobuf.EnumerationPointer enumerationPointer = new Alachisoft.NCache.Common.Protobuf.EnumerationPointer(); enumerationPointer.chunkId = pointer.ChunkId; enumerationPointer.id = pointer.Id; enumerationPointer.isDisposed = pointer.isDisposable; return enumerationPointer; }
//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")) //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); return; } try { //Fetch mapped servers ServerMapping serverMapping = Management.MappingConfiguration.MappingConfigurationManager.GetMappingConfiguration().ClientIPMapping; Mapping[] mappedServers = serverMapping.MappingServers; Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.GetServerMappingResponse getServerMappingResponse = new Alachisoft.NCache.Common.Protobuf.GetServerMappingResponse(); if (mappedServers != null) { for (int i = 0; i < mappedServers.Length; i++) { Common.Protobuf.ServerMapping mappingObject = new Common.Protobuf.ServerMapping(); //Map the server list to protobuf object mappingObject.privateIp = mappedServers[i].PrivateIP; mappingObject.privatePort = mappedServers[i].PrivatePort; mappingObject.publicIp = mappedServers[i].PublicIP; mappingObject.publicPort = mappedServers[i].PublicPort; //Adding to list to be sent as a response getServerMappingResponse.serverMapping.Add(mappingObject); } } else SocketServer.Logger.NCacheLog.Error("Server Mapping is null"); response.getServerMappingResponse = getServerMappingResponse; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_SERVER_MAPPING; response.requestId = command.requestID; _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(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
internal NagglingManager(Connection parent, Socket workingSocket, Alachisoft.NCache.Common.DataStructures.Queue msgQueue, long nagglingSize, object syncLock) { _parent = parent; _workingSocket = workingSocket; _nagglingSize = nagglingSize; _msgQueue = msgQueue; _sendBuffer = new byte[_sendBufferSize]; _syncLock = syncLock; }
public UpHandler(Alachisoft.NCache.Common.DataStructures.Queue mq, Protocol handler, string name, int id) { this.mq = mq; this.handler = handler; if(name != null) Name = name; IsBackground = true; this.id = id; }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; ClientId = clientManager.ClientID; //Asif Imam NCache nCache = clientManager.CmdExecuter as NCache; try { serailizationContext = nCache.CacheId; cmdInfo = base.ParseCommand(command, clientManager, serailizationContext); if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("BulkInsCmd.Exec", "cmd parsed"); } catch (Exception exc) { _insertBulkResult = OperationResult.Failure; //if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } //TODO byte[] dataPackage = null; try { OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient)) operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient); Hashtable insertResult = (Hashtable)nCache.Cache.Insert(cmdInfo.Keys, cmdInfo.Values, cmdInfo.CallbackEnteries, cmdInfo.ExpirationHint, cmdInfo.EvictionHint, cmdInfo.QueryInfo, cmdInfo.Flags, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkInsertResponse bulkInsertResponse = new Alachisoft.NCache.Common.Protobuf.BulkInsertResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.intendedRecipient = cmdInfo.IntendedRecipient; bulkInsertResponse.keyExceptionPackage = new Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse(); //TODO : Package Key Value Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysExceptions(insertResult, bulkInsertResponse.keyExceptionPackage); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.INSERT_BULK; response.bulkInsert = bulkInsertResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _insertBulkResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("BulkInsCmd.Exec", "cmd executed on cache"); }
//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)); } }
//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")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { CallbackInfo cbUpdate = null; CallbackInfo cbRemove = null; if(cmdInfo.dataFilter != -1) //Default value in protbuf set to -1 { EventDataFilter datafilter = (EventDataFilter)cmdInfo.dataFilter; cbUpdate = new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, datafilter); cbRemove = new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, datafilter, cmdInfo.NotifyOnExpiration); } else { cbUpdate = new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None); cbRemove = new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId,EventDataFilter.DataWithMetadata, cmdInfo.NotifyOnExpiration); } NCache nCache = clientManager.CmdExecuter as NCache; nCache.Cache.RegisterKeyNotificationCallback(cmdInfo.Key, cbUpdate, cbRemove , new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation)); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.RegisterKeyNotifResponse registerKeyNotifResponse = new Alachisoft.NCache.Common.Protobuf.RegisterKeyNotifResponse(); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF; response.registerKeyNotifResponse = registerKeyNotifResponse; response.requestId = command.registerKeyNotifCommand.requestId; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
//PROTOBUF private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager) { CommandInfo cmdInfo = new CommandInfo(); Alachisoft.NCache.Common.Protobuf.ClearCommand clearCommand= command.clearCommand; cmdInfo.FlagMap = new BitSet((byte)clearCommand.flag); cmdInfo.RequestId = clearCommand.requestId.ToString(); return cmdInfo; }
//PROTOBUF private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager) { CommandInfo cmdInfo = new CommandInfo(); Alachisoft.NCache.Common.Protobuf.CountCommand countCommand = command.countCommand; cmdInfo.RequestId = countCommand.requestId.ToString(); return cmdInfo; }
//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 private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager) { CommandInfo cmdInfo = new CommandInfo(); Alachisoft.NCache.Common.Protobuf.GetRunningServersCommand getRunningServerCommand = command.getRunningServersCommand; cmdInfo.CacheId = getRunningServerCommand.cacheId; cmdInfo.IsDotNetClient = getRunningServerCommand.isDotnetClient; cmdInfo.RequestId = getRunningServerCommand.requestId.ToString(); return cmdInfo; }
private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo = new CommandInfo(); Alachisoft.NCache.Common.Protobuf.AddAttributeCommand addAttributeCommand = command.addAttributeCommand; cmdInfo.ExpHint = Alachisoft.NCache.Caching.Util.ProtobufHelper.GetExpirationHintObj(addAttributeCommand.absExpiration, 0, serializationContext); cmdInfo.Key = addAttributeCommand.key; cmdInfo.RequestId = addAttributeCommand.requestId.ToString(); return cmdInfo; }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (ArgumentOutOfRangeException arEx) { if (SocketServer.Logger.IsErrorLogsEnabled) SocketServer.Logger.NCacheLog.Error( "IsLockedCommand", "command: " + command + " Error" + arEx); if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(arEx, command.requestID)); } return; } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; object lockId = cmdInfo.LockId; DateTime lockDate = new DateTime(); bool res = nCache.Cache.IsLocked(cmdInfo.Key, ref lockId, ref lockDate, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation)); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.IsLockedResponse isLockedResponse = new Alachisoft.NCache.Common.Protobuf.IsLockedResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.ISLOCKED; response.isLockedResponse = isLockedResponse; isLockedResponse.isLocked = res; isLockedResponse.lockId = lockId.ToString(); isLockedResponse.lockTime = lockDate.Ticks; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
//PROTOBUF private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager) { CommandInfo cmdInfo = new CommandInfo(); //HACK:notifMask Alachisoft.NCache.Common.Protobuf.RegisterNotifCommand registerNotifCommand = command.registerNotifCommand; cmdInfo.RegNotifs = registerNotifCommand.notifMask; cmdInfo.RequestId = registerNotifCommand.requestId.ToString(); cmdInfo.datafilter = registerNotifCommand.datafilter; cmdInfo.sequence = registerNotifCommand.sequence; return cmdInfo; }
//PROTOBUF private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager) { CommandInfo cmdInfo = new CommandInfo(); Alachisoft.NCache.Common.Protobuf.UnRegisterKeyNotifCommand unRegisterKeyNotifCommand = command.unRegisterKeyNotifCommand; cmdInfo.Key = unRegisterKeyNotifCommand.key; cmdInfo.RemoveCallbackId = (short)unRegisterKeyNotifCommand.removeCallbackId; cmdInfo.RequestId = unRegisterKeyNotifCommand.requestId.ToString(); cmdInfo.UpdateCallbackId = (short)unRegisterKeyNotifCommand.updateCallbackId; return cmdInfo; }
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; } int count = 0; string keyPackage = null; try { NCache nCache = clientManager.CmdExecuter as NCache; EnumerationDataChunk nextChunk = nCache.Cache.GetNextChunk(cmdInfo.Pointer, cmdInfo.OperationContext); if (!clientManager.EnumerationPointers.ContainsKey(cmdInfo.Pointer.Id)) { clientManager.EnumerationPointers.Add(cmdInfo.Pointer.Id, cmdInfo.Pointer); } else { clientManager.EnumerationPointers[cmdInfo.Pointer.Id] = cmdInfo.Pointer; } Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse getNextChunkResponse = new Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.intendedRecipient = cmdInfo.OperationContext.GetValueByField(OperationContextFieldName.IntendedRecipient).ToString(); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_NEXT_CHUNK; response.getNextChunkResponse = getNextChunkResponse; if (nextChunk.Data != null) getNextChunkResponse.keys.AddRange(nextChunk.Data); getNextChunkResponse.enumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufEnumerationPointer(nextChunk.Pointer); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
public UpHandler(Alachisoft.NCache.Common.DataStructures.Queue mq, Protocol handler) { this.mq = mq; this.handler = handler; if (handler != null) { Name = "UpHandler (" + handler.Name + ')'; } else { Name = "UpHandler"; } IsBackground = true; }
//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; } NCache nCache = clientManager.CmdExecuter as NCache; try { object lockId = cmdInfo.LockId; DateTime lockDate = new DateTime(); OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true); CacheEntry entry = (CacheEntry)nCache.Cache.GetCacheEntry(cmdInfo.Key, ref lockId, ref lockDate, cmdInfo.LockTimeout, cmdInfo.LockAccessType, operationContext); Alachisoft.NCache.Common.Protobuf.GetCacheItemResponse getCacheItemResponse = new Alachisoft.NCache.Common.Protobuf.GetCacheItemResponse(); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_CACHE_ITEM; if (entry == null) { getCacheItemResponse.lockId = lockId == null ? string.Empty : lockId.ToString(); getCacheItemResponse.lockTicks = lockDate.Ticks; response.getItem = getCacheItemResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); return; } getCacheItemResponse = PopulateResponse(entry, getCacheItemResponse, clientManager); response.getItem = getCacheItemResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } //TODO byte[] data = null; try { NCache nCache = clientManager.CmdExecuter as NCache; CallbackEntry cbEnrty = null; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient)) operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient); nCache.Cache.Delete(cmdInfo.Keys, cmdInfo.FlagMap, cbEnrty, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkDeleteResponse bulkDeleteResponse = new Alachisoft.NCache.Common.Protobuf.BulkDeleteResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.intendedRecipient = cmdInfo.IntendedRecipient; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.DELETE_BULK; response.bulkDeleteResponse = bulkDeleteResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { if (clientManager != null) { clientManager._leftGracefully = true; clientManager.CmdExecuter.Dispose(); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); response.requestId = command.requestID; response.disposeResponse = new Alachisoft.NCache.Common.Protobuf.DisposeResponse(); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.DISPOSE; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } }
private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager) { CommandInfo cmdInfo = new CommandInfo(); Alachisoft.NCache.Common.Protobuf.GetNextChunkCommand getNextChunkCommand = command.getNextChunkCommand; cmdInfo.RequestId = getNextChunkCommand.requestId.ToString(); cmdInfo.Pointer = EnumerationPointerConversionUtil.GetFromProtobufEnumerationPointer(getNextChunkCommand.enumerationPointer); string intendedRecepient = command.intendedRecipient; long lastViewId = command.clientLastViewId; cmdInfo.OperationContext = new OperationContext(); cmdInfo.OperationContext.Add(OperationContextFieldName.IntendedRecipient, intendedRecepient); cmdInfo.OperationContext.Add(OperationContextFieldName.ClientLastViewId, lastViewId); return cmdInfo; }
private static char Delimitor = '|'; //Asif Imam 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")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; QueryResultSet resultSet = null; Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); if (cmdInfo.CommandVersion <= 1) //NCache 3.8 SP4 and previous { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 SP1 or later { operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); } resultSet = nCache.Cache.Search(cmdInfo.Query, cmdInfo.Values, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); response.search = SearchResponseBuilder.BuildResponse(resultSet, cmdInfo.CommandVersion); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.SEARCH; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
internal static EventCacheItem ConvertToEventEntry(Alachisoft.NCache.Common.Protobuf.EventCacheItem cacheItem) { Byte[] objectValue = null; if (cacheItem == null) return null; EventCacheItem item = new EventCacheItem(); item.CacheItemPriority = (CacheItemPriority)cacheItem.priority; if (cacheItem.value != null && cacheItem.value.Count > 0) { UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(cacheItem.value.ToArray()); objectValue = ubObject.GetFullObject(); item.Value = objectValue; } return item; }