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;
}