private IOperationResult ExecuteWithRedirect(IMemcachedNode startNode, ISingleItemOperation op) { IOperationResult result = startNode.Execute(op); if (!result.Success) { IOperationWithState state = op as IOperationWithState; if (state == null) { return(result); } if (state.State != OperationState.InvalidVBucket) { return(result); } foreach (IMemcachedNode node in base.Pool.GetWorkingNodes()) { result = node.Execute(op); if (result.Success) { return(result); } if (state.State != OperationState.InvalidVBucket) { return(result); } } } return(result); }
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); }
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; }