private bool ExecuteWithRedirect(IMemcachedNode startNode, ISingleItemOperation op) { if (startNode.Execute(op)) { return(true); } var iows = op as IOperationWithState; // different op factory, we do not know how to retry if (iows == null) { return(false); } #if HAS_FORWARD_MAP // node responded with invalid vbucket // this should happen only when a node is in a transitioning state if (iows.State == OpState.InvalidVBucket) { // check if we have a forward-locator // (whihc supposedly reflects the state of the cluster when all vbuckets have been migrated succesfully) IMemcachedNodeLocator fl = this.nsPool.ForwardLocator; if (fl != null) { var nextNode = fl.Locate(op.Key); if (nextNode != null) { // the node accepted the requesta if (nextNode.Execute(op)) { return(true); } } } } #endif // still invalid vbucket, try all nodes in sequence if (iows.State == OperationState.InvalidVBucket) { var nodes = this.Pool.GetWorkingNodes(); foreach (var node in nodes) { if (node.Execute(op)) { return(true); } // the node accepted our request so quit if (iows.State != OperationState.InvalidVBucket) { break; } } } return(false); }
public IMemcachedNode Locate(string key) { return(nodeLocator.Locate(key)); }
IMemcachedNode IServerPool.Locate(string key) { var node = NodeLocator.Locate(key); return(node); }