public IObserveOperationResult ExecuteObserveOperation(IObserveOperation op) { var readResult = new ObserveOperationResult(); var result = this.Acquire(); if (result.Success && result.HasValue) { try { var socket = result.Value; var b = op.GetBuffer(); socket.Write(b); readResult = op.ReadResponse(socket) as ObserveOperationResult; if (readResult.Success) { readResult.Pass(); } else { readResult.InnerResult = result; readResult.Fail("Failed to read response, see inner result for details"); } return(readResult); } catch (IOException e) { log.Error(e); readResult.Fail("Exception reading response", e); return(readResult); } finally { ((IDisposable)result.Value).Dispose(); } } else { readResult.Fail("Failed to obtain socket from pool"); return(readResult); } }
public IObserveOperationResult ExecuteObserveOperation(IObserveOperation op) { var readResult = new ObserveOperationResult(); var result = this.Acquire(); if (result.Success && result.HasValue) { try { var socket = result.Value; var b = op.GetBuffer(); socket.Write(b); readResult = op.ReadResponse(socket) as ObserveOperationResult; if (readResult.Success) { readResult.Pass(); } else { readResult.InnerResult = result; readResult.Fail("Failed to read response, see inner result for details"); } return readResult; } catch (IOException e) { log.Error(e); readResult.StatusCode = StatusCode.UnspecifiedError; readResult.Fail("Exception reading response", e); return readResult; } finally { ((IDisposable)result.Value).Dispose(); } } else { result.Combine(readResult); return readResult; } }
public IObserveOperationResult ExecuteObserveOperation(IObserveOperation op) { return Execute(op) as IObserveOperationResult; }
private IObserveOperationResult checkNodesForKey(ObservedNode[] nodes, IObserveOperation command, ref bool isMasterInExpectedState, ref int replicaFoundCount, ref int replicaPersistedCount, ObserveKeyState persistedKeyState, ObserveKeyState replicatedKeyState) { var tmpReplicaFoundCount = 0; var tmpReplicaPersistedCount = 0; var tmpIsPersistedToMaster = false; var result = new ObserveOperationResult(); var lockObject = new object(); foreach (var node in nodes) { lock (lockObject) { var opResult = node.Node.ExecuteObserveOperation(command); if (log.IsDebugEnabled) log.Debug("Node: " + node.Node.EndPoint + ", Result: " + opResult.KeyState + ", Master: " + node.IsMaster + ", Cas: " + opResult.Cas + ", Key: " + _settings.Key); if (!opResult.Success) //Probably an IO Exception { break; } else if (node.IsMaster && opResult.Cas != _settings.Cas && (persistedKeyState == ObserveKeyState.FoundPersisted || replicatedKeyState == ObserveKeyState.FoundNotPersisted)) { result.Success = false; result.Message = ObserveOperationConstants.MESSAGE_MODIFIED; break; } else if (opResult.KeyState == persistedKeyState) { node.KeyIsPersisted = true; if (node.IsMaster) { tmpIsPersistedToMaster = true; } else { tmpReplicaPersistedCount++; } } else if (opResult.KeyState == replicatedKeyState) { if (!node.IsMaster) { tmpReplicaFoundCount++; } } } } isMasterInExpectedState = tmpIsPersistedToMaster; replicaFoundCount = tmpReplicaFoundCount; replicaPersistedCount = tmpReplicaPersistedCount; if (log.IsDebugEnabled) log.Debug("Master Persisted: " + tmpIsPersistedToMaster + ", Replica Found: " + replicaFoundCount + ", Replica Persisted: " + tmpReplicaPersistedCount); return result; }
private IObserveOperationResult checkNodesForKey(ObservedNode[] nodes, IObserveOperation command, ref bool isMasterInExpectedState, ref int replicaFoundCount, ref int replicaPersistedCount) { var tmpReplicaFoundCount = 0; var tmpReplicaPersistedCount = 0; var tmpIsPersistedToMaster = false; var result = new ObserveOperationResult(); var lockObject = new object(); foreach (var node in nodes) { lock (lockObject) { var opResult = node.Node.ExecuteObserveOperation(command); if (log.IsDebugEnabled) { log.Debug("Node: " + node.Node.EndPoint + ", Result: " + opResult.KeyState + ", Master: " + node.IsMaster + ", Cas: " + opResult.Cas + ", Key: " + _settings.Key); } if (!opResult.Success) //Probably an IO Exception { break; } else if (node.IsMaster && opResult.Cas != _settings.Cas) { result.Success = false; result.Message = ObserveOperationConstants.MESSAGE_MODIFIED; break; } else if (opResult.KeyState == ObserveKeyState.FoundPersisted) { node.KeyIsPersisted = true; if (node.IsMaster) { tmpIsPersistedToMaster = true; } else { tmpReplicaPersistedCount++; } } else if (opResult.KeyState == ObserveKeyState.FoundNotPersisted) { if (!node.IsMaster) { tmpReplicaFoundCount++; } } } } isMasterInExpectedState = tmpIsPersistedToMaster; replicaFoundCount = tmpReplicaFoundCount; replicaPersistedCount = tmpReplicaPersistedCount; if (log.IsDebugEnabled) { log.Debug("Master Persisted: " + tmpIsPersistedToMaster + ", Replica Found: " + replicaFoundCount + ", Replica Persisted: " + tmpReplicaPersistedCount); } return(result); }
public IObserveOperationResult ExecuteObserveOperation(IObserveOperation op) { return(Execute(op) as IObserveOperationResult); }