private void ParseClusterNodes(string s, string originalIP) { if (s == null) { return; } int len = s.Length - 1; int i = 0; int start = i; ClusterNode node = null; RedisNativeClient client = null; while (i < len) { // UUID. start = i; while (s[i] != ' ') { i++; } node = this.GetClusterNode(s.Substring(start, i - start)); // IP. i++; start = i; while (s[i] != ':') { i++; } node.ip = s.Substring(start, i - start); // Port. i++; start = i; while (s[i] != ' ') { i++; } node.port = ushort.Parse(s.Substring(start, i - start)); // Record this client. if (originalIP != null) { if (Global.LocalhostIPv4.CompareTo(node.ip) == 0) { node.ip = originalIP; } } client = this.GetRedisClient(node.ip, node.port); // Status. i++; start = i; while (s[i] != ' ') { i++; } if (s.Substring(start, i - start).Contains("master")) { // This is a master. node.SetMaster(); i += 3; } else { // This is a slave. node.SetSlave(); // Master UUID. i++; start = i; while (s[i] != ' ') { i++; } node.masterUUID = s.Substring(start, i - start); i++; } // Number of sent PING commands. start = i; while (s[i] != ' ') { i++; } node.ping = ulong.Parse(s.Substring(start, i - start)); // Number of received PONG replies. i++; start = i; while (s[i] != ' ') { i++; } node.pong = ulong.Parse(s.Substring(start, i - start)); // Epoch. i++; start = i; while (s[i] != ' ') { i++; } node.epoch = ulong.Parse(s.Substring(start, i - start)); // "connected" or "disconnected". i++; start = i; while ((i < len) && (s[i] != ' ') && (s[i] != '\r') && (s[i] != '\n')) { i++; } if ("connected".CompareTo(s.Substring(start, i - start)) == 0) { node.SetConnected(); if (node.IsMaster()) { if ((i < len) && (s[i] != '\r') && (s[i] != '\n')) { // Start slot. i++; start = i; while (s[i] != '-') { i++; } node.startSlot = ushort.Parse(s.Substring(start, i - start)); // End slot. i++; start = i; while (s[i] != '\r' && s[i] != '\n') { i++; } node.endSlot = ushort.Parse(s.Substring(start, i - start)); this.SetHashSlots(node.ip, node.port, node.startSlot, node.endSlot); } } } else { node.SetDisconnected(); } while (i < len) { if (s[i] == '\n') { break; } i++; } } }