//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")) { // _resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(arEx, base.immatureId), base.ParsingExceptionMessage(arEx)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } catch (Exception exc) { _lockResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; object lockId = null; DateTime lockDate = DateTime.Now; var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); bool res = nCache.Cache.Lock(cmdInfo.Key, cmdInfo.LockTimeout, out lockId, out lockDate, operationContext); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.VerifyLockResponse verifyLockResponse = new Alachisoft.NCache.Common.Protobuf.VerifyLockResponse(); verifyLockResponse.lockId = lockId.ToString(); verifyLockResponse.success = res; verifyLockResponse.lockExpiration = lockDate.Ticks; if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(verifyLockResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(verifyLockResponse, Common.Protobuf.Response.Type.LOCK_VERIFY)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.lockVerify = verifyLockResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.LOCK_VERIFY); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } catch (Exception exc) { _lockResult = OperationResult.Failure; //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } }
//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); } 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)); } }