public bool TryResend(int hashSlot, Message message, EndPoint endpoint, bool isMoved) { try { if (serverType == ServerType.Standalone || hashSlot < 0 || hashSlot >= RedisClusterSlotCount) { return(false); } ServerEndPoint server = multiplexer.GetServerEndPoint(endpoint); if (server != null) { bool retry = false; if ((message.Flags & CommandFlags.NoRedirect) == 0) { message.SetAsking(!isMoved); message.SetNoRedirect(); // once is enough // note that everything so far is talking about MASTER nodes; we might be // wanting a SLAVE, so we'll check ServerEndPoint resendVia = null; var command = message.Command; switch (Message.GetMasterSlaveFlags(message.Flags)) { case CommandFlags.DemandMaster: resendVia = server.IsSelectable(command) ? null : server; break; case CommandFlags.PreferMaster: resendVia = server.IsSelectable(command) ? FindSlave(server, command) : server; break; case CommandFlags.PreferSlave: resendVia = FindSlave(server, command) ?? (server.IsSelectable(command) ? null : server); break; case CommandFlags.DemandSlave: resendVia = FindSlave(server, command); break; } if (resendVia == null) { multiplexer.Trace("Unable to resend to " + endpoint); } else { message.PrepareToResend(resendVia, isMoved); retry = resendVia.TryEnqueue(message); } } if (isMoved) // update map; note we can still update the map even if we aren't actually goint to resend { var arr = MapForMutation(); var oldServer = arr[hashSlot]; arr[hashSlot] = server; if (oldServer != server) { multiplexer.OnHashSlotMoved(hashSlot, oldServer == null ? null : oldServer.EndPoint, endpoint); } } return(retry); } return(false); } catch { return(false); } }