protected override IOperationResult ProcessResponse(BinaryResponse response) { var result = new BinaryOperationResult(); var status = response.StatusCode; this.StatusCode = status; if (status == 0) { if (mode != MutationMode.Touch) { var data = response.Data; if (data.Count != 8) { return(result.Fail("Result must be 8 bytes long, received: " + data.Count, new InvalidOperationException())); } this.result = BinaryConverter.DecodeUInt64(data.Array, data.Offset); } return(result.Pass()); } var message = ResultHelper.ProcessResponseData(response.Data); return(result.Fail(message)); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { return(new BinaryOperationResult() { Success = true }); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var status = response.StatusCode; var result = new BinaryOperationResult(); this.StatusCode = status; if (status == 0) { int flags = BinaryConverter.DecodeInt32(response.Extra, 0); this.result = new CacheItem((ushort)flags, response.Data); this.Cas = response.CAS; #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) log.DebugFormat("Get succeeded for key '{0}'.", this.Key); #endif return result.Pass(); } this.Cas = 0; #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) log.DebugFormat("Get failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count)); #endif var message = ResultHelper.ProcessResponseData(response.Data); return result.Fail(message); }
protected internal override async Task <IOperationResult> ReadResponseAsync(PooledSocket socket, CancellationToken cancellationToken = default(CancellationToken)) { var response = new BinaryResponse(); var serverData = new Dictionary <string, string>(); var success = false; while (await response.ReadAsync(socket, cancellationToken).ConfigureAwait(false) && response.KeyLength > 0) { success = true; var data = response.Data; var key = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength); var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength); serverData[key] = value; } this._result = serverData; this.StatusCode = response.StatusCode; var result = new BinaryOperationResult() { StatusCode = StatusCode }; result.PassOrFail(success, "Failed to read response"); return(result); }
protected internal override IOperationResult ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var success = response.Read(socket); this.Cas = response.CAS; this.StatusCode = response.StatusCode; var result = new BinaryOperationResult() { Success = success, Cas = this.Cas, StatusCode = this.StatusCode }; IOperationResult responseResult; if (!(responseResult = this.ProcessResponse(response)).Success) { result.InnerResult = responseResult; responseResult.Combine(result); } return(result); }
protected internal override IOperationResult ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.Cas = response.CAS; this.StatusCode = response.StatusCode; var result = new BinaryOperationResult() { Success = retval, Cas = this.Cas, StatusCode = this.StatusCode }; IOperationResult responseResult; if (!(responseResult = this.ProcessResponse(response)).Success) { result.InnerResult = responseResult; result.Fail("Failed to process response, see StatusCode or InnerResult for details"); } return(result); }
protected override bool ProcessResponse(BinaryResponse response) { if (response.StatusCode == 0) { int flags = BinaryConverter.DecodeInt32(response.Extra, 0); this.result = new CacheItem((ushort)flags, response.Data); this.Cas = response.CAS; #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) { log.DebugFormat("Get succeeded for key '{0}'.", this.Key); } #endif return(true); } this.Cas = 0; #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) { log.DebugFormat("Get failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count)); } #endif return(false); }
protected override bool ProcessResponse(BinaryResponse response) { if (response.StatusCode == 0) { int flags = BinaryConverter.DecodeInt32(response.Extra, 0); this.result = new CacheItem((ushort)flags, response.Data); this.Cas = response.CAS; #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) log.DebugFormat("Get succeeded for key '{0}'.", this.Key); #endif return true; } this.Cas = 0; #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) log.DebugFormat("Get failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count)); #endif return false; }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var status = response.StatusCode; var result = new BinaryOperationResult(); this.StatusCode = status; if (status == 0) { int flags = BinaryConverter.DecodeInt32(response.Extra, 0); this.result = new CacheItem((ushort)flags, response.Data); this.Cas = response.CAS; #if EVEN_MORE_LOGGING if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogDebug("Get succeeded for key '{0}'.", this.Key); } #endif return(result.Pass()); } this.Cas = 0; #if EVEN_MORE_LOGGING if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogDebug("Get failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count)); } #endif var message = ResultHelper.ProcessResponseData(response.Data); return(result.Fail(message)); }
protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket) { var response = new BinaryResponse(); var serverData = new Dictionary <string, string>(); var retval = false; while ((await response.ReadAsync(socket)) && response.KeyLength > 0) { retval = true; var data = response.Data; var key = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength); var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength); serverData[key] = value; } this.result = serverData; this.StatusCode = response.StatusCode; var result = new BinaryOperationResult() { StatusCode = StatusCode }; result.PassOrFail(retval, "Failed to read response"); return(result); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var result = new BinaryOperationResult(); #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) { if (response.StatusCode == 0) { log.DebugFormat("Store succeeded for key '{0}'.", this.Key); } else { log.DebugFormat("Store failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count)); } } #endif this.StatusCode = response.StatusCode; if (response.StatusCode == 0) { return(result.Pass()); } else { var message = ResultHelper.ProcessResponseData(response.Data); return(result.Fail(message)); } }
protected internal override bool ReadResponse(PooledSocket socket) { this.result = new Dictionary<string, CacheItem>(); this.Cas = new Dictionary<string, ulong>(); var response = new BinaryResponse(); while (response.Read(socket)) { // found the noop, quit if (response.CorrelationId == this.noopId) return true; string key; // find the key to the response if (!this.idToKey.TryGetValue(response.CorrelationId, out key)) { // we're not supposed to get here tho log.WarnFormat("Found response with CorrelationId {0}, but no key is matching it.", response.CorrelationId); continue; } if (log.IsDebugEnabled) log.DebugFormat("Reading item {0}", key); // deserialize the response int flags = BinaryConverter.DecodeInt32(response.Extra, 0); this.result[key] = new CacheItem((ushort)flags, response.Data); this.Cas[key] = response.CAS; } // finished reading but we did not find the NOOP return false; }
protected internal override IOperationResult ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var serverData = new Dictionary<string, string>(); var retval = false; while (response.Read(socket) && response.KeyLength > 0) { retval = true; var data = response.Data; var key = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength); var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength); serverData[key] = value; } this.result = serverData; this.StatusCode = response.StatusCode; var result = new BinaryOperationResult() { StatusCode = StatusCode }; result.PassOrFail(retval, "Failed to read response"); return result; }
protected internal override async Task <IOperationResult> ReadResponseAsync(PooledSocket socket, CancellationToken cancellationToken = default(CancellationToken)) { var response = new BinaryResponse(); var success = await response.ReadAsync(socket, cancellationToken).ConfigureAwait(false); this.Cas = response.CAS; this.StatusCode = response.StatusCode; var result = new BinaryOperationResult() { Success = success, Cas = this.Cas, StatusCode = this.StatusCode }; IOperationResult responseResult; if (!(responseResult = this.ProcessResponse(response)).Success) { result.InnerResult = responseResult; responseResult.Combine(result); } return(result); }
protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket) { var response = new BinaryResponse(); var retval = await response.ReadAsync(socket); this.Cas = response.CAS; this.StatusCode = response.StatusCode; var result = new BinaryOperationResult() { Success = retval, Cas = this.Cas, StatusCode = this.StatusCode }; IOperationResult responseResult; if (!(responseResult = this.ProcessResponse(response)).Success) { result.InnerResult = responseResult; responseResult.Combine(result); } return(result); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var result = new BinaryOperationResult(); return(response.StatusCode == 0 ? result.Pass() : result.Fail(OperationResultHelper.ProcessResponseData(response.Data))); }
protected internal override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.Cas = response.CAS; return retval & this.ProcessResponse(response); }
protected internal override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.StatusCode = StatusCode; return(retval); }
protected internal override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.Cas = response.CAS; return(retval & this.ProcessResponse(response)); }
protected internal override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.StatusCode = StatusCode; return retval; }
protected override bool ProcessResponse(BinaryResponse response) { var r = base.ProcessResponse(response); if (this.locator != null && !VBucketAwareOperationFactory.GuessResponseState(response, out this.state)) return false; return r; }
protected internal override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.StatusCode = response.StatusCode; this.Data = response.Data.Array; return retval; }
protected override bool ProcessResponse(BinaryResponse response) { #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) if (response.StatusCode == 0) log.DebugFormat("Delete succeeded for key '{0}'.", this.Key); else log.DebugFormat("Delete failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count)); #endif return true; }
protected internal override bool ReadResponseAsync(PooledSocket socket, Action<bool> next) { this.result = new Dictionary<string, CacheItem>(); this.Cas = new Dictionary<string, ulong>(); this.currentSocket = socket; this.asyncReader = new BinaryResponse(); this.asyncLoopState = null; this.afterAsyncRead = next; return this.DoReadAsync(); }
protected internal override bool ReadResponseAsync(PooledSocket socket, Action <bool> next) { this.result = new Dictionary <string, CacheItem>(); this.Cas = new Dictionary <string, ulong>(); this.currentSocket = socket; this.asyncReader = new BinaryResponse(); this.asyncLoopState = null; this.afterAsyncRead = next; return(this.DoReadAsync()); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var r = base.ProcessResponse(response); var result = new BinaryOperationResult(); if (this.locator != null && !VBucketAwareOperationFactory.GuessResponseState(response, out this.state)) { return result.Fail("Failed to process response"); } return r; }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var r = response.StatusCode == 0; var result = new BinaryOperationResult(); if (this.locator != null && !VBucketAwareOperationFactory.GuessResponseState(response, out this.state)) { return result.Fail("Process response failed"); } return result.PassOrFail(r, "Processing response failed"); }
protected internal override async Task <IOperationResult> ReadResponseAsync(PooledSocket socket, CancellationToken cancellationToken = default(CancellationToken)) { var response = new BinaryResponse(); var success = await response.ReadAsync(socket, cancellationToken).ConfigureAwait(false); this.StatusCode = StatusCode; var result = new BinaryOperationResult() { Success = success, StatusCode = this.StatusCode }; result.PassOrFail(success, "Failed to read response"); return(result); }
protected override bool ProcessResponse(BinaryResponse response) { if (response.StatusCode == 0) { var data = response.Data; if (data.Count != 8) throw new InvalidOperationException("result must be 8 bytes long, received: " + data.Count); this.result = BinaryConverter.DecodeUInt64(data.Array, data.Offset); return true; } return false; }
protected internal override IOperationResult ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.StatusCode = StatusCode; var result = new BinaryOperationResult() { Success = retval, StatusCode = this.StatusCode }; result.PassOrFail(retval, "Failed to read response"); return(result); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var result = new BinaryOperationResult(); this.StatusCode = response.StatusCode; if (response.StatusCode == 0) { return(result.Pass()); } else { var message = ResultHelper.ProcessResponseData(response.Data); return(result.Fail(message)); } }
protected internal override IOperationResult ReadResponse(IPooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.StatusCode = StatusCode; var result = new BinaryOperationResult() { Success = retval, StatusCode = this.StatusCode }; result.PassOrFail(retval, "Failed to read response"); return result; }
protected internal override IOperationResult ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var success = response.Read(socket); this.StatusCode = response.StatusCode; this.Data = response.Data.Array; var result = new BinaryOperationResult { StatusCode = this.StatusCode }; result.PassOrFail(success, "Failed to read response"); return(result); }
protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket) { var response = new BinaryResponse(); var retval = await response.ReadAsync(socket); this.StatusCode = response.StatusCode; this.Data = response.Data.Array; var result = new BinaryOperationResult { StatusCode = this.StatusCode }; result.PassOrFail(retval, "Failed to read response"); return(result); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var status = response.StatusCode; var result = new BinaryOperationResult(); this.StatusCode = status; if (status == 0) { this.Cas = response.CAS; return result.Pass(); } this.Cas = 0; var message = ResultHelper.ProcessResponseData(response.Data); return result.Fail(message); }
protected internal override IOperationResult ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.StatusCode = response.StatusCode; this.Data = response.Data.Array; var result = new BinaryOperationResult { StatusCode = this.StatusCode }; result.PassOrFail(retval, "Failed to read response"); return result; }
protected override bool ProcessResponse(BinaryResponse response) { if (response.StatusCode == 0) { var data = response.Data; if (data.Count != 8) { throw new InvalidOperationException("result must be 8 bytes long, received: " + data.Count); } this.result = BinaryConverter.DecodeUInt64(data.Array, data.Offset); return(true); } return(false); }
protected override bool ProcessResponse(BinaryResponse response) { #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) { if (response.StatusCode == 0) { log.DebugFormat("Delete succeeded for key '{0}'.", this.Key); } else { log.DebugFormat("Delete failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count)); } } #endif return(true); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var status = response.StatusCode; var result = new BinaryOperationResult(); this.StatusCode = status; if (status == 0) { int flags = BinaryConverter.DecodeInt32(response.Extra, 0); this.result = new CacheItem((ushort)flags, response.Data); this.Cas = response.CAS; return(result.Pass()); } this.Cas = 0; return(result.Fail(OperationResultHelper.ProcessResponseData(response.Data))); }
protected internal override IOperationResult ReadResponse(PooledSocket socket) { this.result = new Dictionary <string, CacheItem>(); this.Cas = new Dictionary <string, ulong>(); var result = new TextOperationResult(); var response = new BinaryResponse(); while (response.Read(socket)) { this.StatusCode = response.StatusCode; // found the noop, quit if (response.CorrelationId == this.noopId) { return(result.Pass()); } string key; // find the key to the response if (!this.idToKey.TryGetValue(response.CorrelationId, out key)) { // we're not supposed to get here tho log.WarnFormat("Found response with CorrelationId {0}, but no key is matching it.", response.CorrelationId); continue; } if (log.IsDebugEnabled) { log.DebugFormat("Reading item {0}", key); } // deserialize the response int flags = BinaryConverter.DecodeInt32(response.Extra, 0); this.result[key] = new CacheItem((ushort)flags, response.Data); this.Cas[key] = response.CAS; } // finished reading but we did not find the NOOP return(result.Fail("Found response with CorrelationId {0}, but no key is matching it.")); }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var result = new BinaryOperationResult(); #if EVEN_MORE_LOGGING if (log.IsDebugEnabled) if (response.StatusCode == 0) log.DebugFormat("Delete succeeded for key '{0}'.", this.Key); else log.DebugFormat("Delete failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count)); #endif if (response.StatusCode == 0) { return result.Pass(); } else { var message = ResultHelper.ProcessResponseData("Delete failed for key " + Key, response.Data); return result.Fail(message); } }
protected override IOperationResult ProcessResponse(BinaryResponse response) { var result = new BinaryOperationResult(); var status = response.StatusCode; this.StatusCode = status; if (status == 0) { var data = response.Data; if (data.Count != 8) return result.Fail("Result must be 8 bytes long, received: " + data.Count, new InvalidOperationException()); this.result = BinaryConverter.DecodeUInt64(data.Array, data.Offset); return result.Pass(); } var message = ResultHelper.ProcessResponseData("Mutate failed for key " + Key, response.Data); return result.Fail(message); }
protected internal override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var serverData = new Dictionary <string, string>(); var retval = false; while (response.Read(socket) && response.KeyLength > 0) { retval = true; var data = response.Data; var key = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength); var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength); serverData[key] = value; } this.result = serverData; return(retval); }
protected internal override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var serverData = new Dictionary<string, string>(); var retval = false; while (response.Read(socket) && response.KeyLength > 0) { retval = true; var data = response.Data; var key = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength); var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength); serverData[key] = value; } this.result = serverData; return retval; }
protected internal override IOperationResult ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); var retval = response.Read(socket); this.Cas = response.CAS; this.StatusCode = response.StatusCode; var result = new BinaryOperationResult() { Success = retval, Cas = this.Cas, StatusCode = this.StatusCode }; IOperationResult responseResult; if (! (responseResult = this.ProcessResponse(response)).Success) { result.InnerResult = responseResult; responseResult.Combine(result); } return result; }
private void StoreResult(BinaryResponse reader) { string key; // find the key to the response if (!this.idToKey.TryGetValue(reader.CorrelationId, out key)) { // we're not supposed to get here tho log.WarnFormat("Found response with CorrelationId {0}, but no key is matching it.", reader.CorrelationId); } else { if (log.IsDebugEnabled) { log.DebugFormat("Reading item {0}", key); } // deserialize the response var flags = (ushort)BinaryConverter.DecodeInt32(reader.Extra, 0); this.result[key] = new CacheItem(flags, reader.Data); this.Cas[key] = reader.CAS; } }
protected override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); if (response.Read(socket)) { this.Result = DecodeResult(response.Data); return true; } return false; }
private void StoreResult(BinaryResponse reader) { string key; // find the key to the response if (!this.idToKey.TryGetValue(reader.CorrelationId, out key)) { // we're not supposed to get here tho log.WarnFormat("Found response with CorrelationId {0}, but no key is matching it.", reader.CorrelationId); } else { if (log.IsDebugEnabled) log.DebugFormat("Reading item {0}", key); // deserialize the response var flags = (ushort)BinaryConverter.DecodeInt32(reader.Extra, 0); this.result[key] = new CacheItem(flags, reader.Data); this.Cas[key] = reader.CAS; } }
internal static bool GuessResponseState(BinaryResponse response, out OperationState state) { switch (response.StatusCode) { case 0: state = OperationState.Success; return true; case 7: state = OperationState.InvalidVBucket; break; default: state = OperationState.Failure; break; } return false; }
protected internal override bool ReadResponse(PooledSocket socket) { var response = new BinaryResponse(); return(response.Read(socket)); }
protected override IOperationResult ReadResponse(IPooledSocket socket) { var response = new BinaryResponse(); var result = new BinaryOperationResult(); if (response.Read(socket)) { this.Result = DecodeResult(response.Data); result.Pass(); return result; } result.Fail("Processing of response failed"); return result; }
protected abstract bool ProcessResponse(BinaryResponse response);
protected override bool ReadResponseAsync(IPooledSocket socket, Action<bool> next) { var response = new BinaryResponse(); bool ioPending; var retval = response.ReadAsync(socket, (readSuccess) => { if (readSuccess) this.DecodeResult(response.Data); next(readSuccess); }, out ioPending); if (!ioPending && retval) this.Result = this.DecodeResult(response.Data); return retval; }
protected override bool ProcessResponse(BinaryResponse response) { base.ProcessResponse(response); if (!GuessResponseState(response, out this.state)) return false; return true; }
protected override IOperationResult ProcessResponse(BinaryResponse response) { base.ProcessResponse(response); var result = new BinaryOperationResult(); if (!GuessResponseState(response, out this.state)) { var message = ResultHelper.ProcessResponseData(response.Data, "Failed to process response"); return result.Fail(message); } return result.Pass(); }
protected abstract IOperationResult ProcessResponse(BinaryResponse response);
protected override IOperationResult ProcessResponse(BinaryResponse response) { return new BinaryOperationResult() { Success = true }; }
protected override bool ProcessResponse(BinaryResponse response) { return true; }