@@ -113,6 +113,7 @@ class RedisConfig(val initialHost: RedisEndpoint) extends Serializable {
113
113
* @return a list of RedisNode whose slots union [sPos, ePos] is not null
114
114
*/
115
115
def getNodesBySlots (sPos : Int , ePos : Int ): Array [RedisNode ] = {
116
+ /* This function judges if [sPos1, ePos1] union [sPos2, ePos2] is not null */
116
117
def inter (sPos1 : Int , ePos1 : Int , sPos2 : Int , ePos2 : Int ) =
117
118
if (sPos1 <= sPos2) ePos1 >= sPos2 else ePos2 >= sPos1
118
119
@@ -210,6 +211,15 @@ class RedisConfig(val initialHost: RedisEndpoint) extends Serializable {
210
211
val slotInfo = slotInfoObj.asInstanceOf [java.util.List [java.lang.Object ]]
211
212
val sPos = slotInfo.get(0 ).toString.toInt
212
213
val ePos = slotInfo.get(1 ).toString.toInt
214
+ /*
215
+ * We will get all the nodes with the slots range [sPos, ePos],
216
+ * and create RedisNode for each nodes, the total field of all
217
+ * RedisNode are the number of the nodes whose slots range is
218
+ * as above, and the idx field is just an index for each node
219
+ * which will be used for adding support for slaves and so on.
220
+ * And the idx of a master is always 0, we rely on this fact to
221
+ * filter master.
222
+ */
213
223
(0 until (slotInfo.size - 2 )).map(i => {
214
224
val node = slotInfo(i + 2 ).asInstanceOf [java.util.List [java.lang.Object ]]
215
225
val host = SafeEncoder .encode(node.get(0 ).asInstanceOf [Array [scala.Byte ]])
0 commit comments