/// <summary> /// Sends a request with the policy defined with the configuration object, to multiple nodes if the replicas setting /// is different from zero. /// </summary> /// <param name="request">A memcache request derived from RedundantRequest</param> /// <returns> /// True if the request was sent to at least one node. The caller will receive a callback (if not null). /// False if the request could not be sent to any node. In that case, the callback will not be called. /// </returns> protected bool SendRequest(IMemcacheRequest request) { int countTrySends = 0; int countTrySendsOK = 0; foreach (var node in _locator.Locate(request.Key)) { countTrySends++; if (node.TrySend(request, _configuration.QueueTimeout)) { countTrySendsOK++; } // Break after trying to send the request to replicas+1 nodes if (countTrySends > request.Replicas) { break; } } if (countTrySendsOK == 0) { // The callback will not be called return(false); } else { // Call Fail() on the request as many times as node.TrySend returned false for (; countTrySendsOK < countTrySends; countTrySendsOK++) { request.Fail(); } return(true); } }
private string FindNodePath() { var nodePath = nodeLocator.Locate(); if (string.IsNullOrEmpty(nodePath)) { throw new FileNotFoundException("Could not find node.exe"); } return(nodePath); }
public virtual Task <IOperation> Execute(IItemOperation op) { var node = locator.Locate(op.Key); if (!node.IsAlive) { return(failSingle.Task); } var retval = node.Enqueue(op); ioQueue.Add(node); return(retval); }
public virtual Task <IOperation> Execute(IItemOperation op) { var node = locator.Locate(op.Key); if (node == null) { new IOException("All nodes are dead"); } if (!node.IsAlive) { new IOException($"Node {node} is dead"); } var retval = node.Enqueue(op); ioQueue.Add(node); return(retval); }