refactoring

pull/2382/head
Nikita Koksharov 5 years ago
parent 0041487e74
commit 31ed986967

@ -15,18 +15,17 @@
*/
package org.redisson.client.protocol.decoder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import org.redisson.cluster.ClusterNodeInfo;
import org.redisson.cluster.ClusterSlotRange;
import org.redisson.cluster.ClusterNodeInfo.Flag;
import org.redisson.cluster.ClusterSlotRange;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
*
@ -84,7 +83,7 @@ public class ClusterNodesDecoder implements Decoder<List<ClusterNodeInfo>> {
if (params.length > 8) {
for (int i = 0; i < params.length - 8; i++) {
String slots = params[i + 8];
if (slots.indexOf("-<-") != -1 || slots.indexOf("->-") != -1) {
if (slots.contains("-<-") || slots.contains("->-")) {
continue;
}

@ -22,6 +22,8 @@ import java.util.Set;
import org.redisson.misc.RedisURI;
import static org.redisson.connection.MasterSlaveConnectionManager.MAX_SLOT;
/**
*
* @author Nikita Koksharov
@ -39,7 +41,7 @@ public class ClusterPartition {
private final Set<RedisURI> slaveAddresses = new HashSet<>();
private final Set<RedisURI> failedSlaves = new HashSet<>();
private final BitSet slots = new BitSet();
private final BitSet slots = new BitSet(MAX_SLOT);
private final Set<ClusterSlotRange> slotRanges = new HashSet<ClusterSlotRange>();
private ClusterPartition parent;
@ -86,17 +88,13 @@ public class ClusterPartition {
public void addSlotRanges(Set<ClusterSlotRange> ranges) {
for (ClusterSlotRange clusterSlotRange : ranges) {
for (int i = clusterSlotRange.getStartSlot(); i < clusterSlotRange.getEndSlot() + 1; i++) {
slots.set(i);
}
slots.set(clusterSlotRange.getStartSlot(), clusterSlotRange.getEndSlot() + 1);
}
slotRanges.addAll(ranges);
}
public void removeSlotRanges(Set<ClusterSlotRange> ranges) {
for (ClusterSlotRange clusterSlotRange : ranges) {
for (int i = clusterSlotRange.getStartSlot(); i < clusterSlotRange.getEndSlot() + 1; i++) {
slots.clear(i);
}
slots.clear(clusterSlotRange.getStartSlot(), clusterSlotRange.getEndSlot() + 1);
}
slotRanges.removeAll(ranges);
}
@ -105,7 +103,7 @@ public class ClusterPartition {
}
public Iterable<Integer> getSlots() {
return (Iterable<Integer>) slots.stream()::iterator;
return slots.stream()::iterator;
}
public BitSet slots() {

Loading…
Cancel
Save