public ReadFromStreamCommand(string key, string lockHandle, int offset, int length) { base.name = "ReadFromStreamCommand"; _readFromStreamCommand = new Alachisoft.NCache.Common.Protobuf.ReadFromStreamCommand(); _readFromStreamCommand.key = key; _readFromStreamCommand.lockHandle = lockHandle; _readFromStreamCommand.offset = offset; _readFromStreamCommand.requestId = base.RequestId; _readFromStreamCommand.length = length; }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { Alachisoft.NCache.Common.Protobuf.ReadFromStreamCommand readFromStreamCommand = command.readFromStreamCommand; ReadFromStreamCommandInfo cmdInfo = new ReadFromStreamCommandInfo(); cmdInfo.key = readFromStreamCommand.key; cmdInfo.length = readFromStreamCommand.length; cmdInfo.lockHandle = readFromStreamCommand.lockHandle; cmdInfo.offset = readFromStreamCommand.offset; cmdInfo.requestId = readFromStreamCommand.requestId; int bytesRead = 0; List <byte[]> buffer = null; VirtualArray vBuffer = null; try { bytesRead = ((NCache)clientManager.CmdExecuter).Cache.ReadFromStream(ref vBuffer, cmdInfo.key, cmdInfo.lockHandle, cmdInfo.offset, cmdInfo.length, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation)); } catch (Exception e) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(e, command.requestID, command.commandID)); return; } Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.ReadFromStreamResponse readFromStreamResponse = new Alachisoft.NCache.Common.Protobuf.ReadFromStreamResponse(); if (bytesRead > 0) { foreach (byte[] buffersegment in vBuffer.BaseArray) { readFromStreamResponse.buffer.Add(buffersegment); } } readFromStreamResponse.bytesRead = bytesRead; response.requestId = cmdInfo.requestId; response.commandID = command.commandID; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.READ_FROM_STREAM; response.readFromStreamResponse = readFromStreamResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); }