redis.clients.jedis.Jedis.clusterSlots()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中redis.clients.jedis.Jedis.clusterSlots()方法的一些代码示例,展示了Jedis.clusterSlots()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.clusterSlots()方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:clusterSlots

Jedis.clusterSlots介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

public void discoverClusterSlots(Jedis jedis) {
 w.lock();
 try {
  this.slots.clear();
  List<Object> slots = jedis.clusterSlots();
  for (Object slotInfoObj : slots) {
   List<Object> slotInfo = (List<Object>) slotInfoObj;
   if (slotInfo.size() <= 2) {
    continue;
   }
   List<Integer> slotNums = getAssignedSlotArray(slotInfo);
   // hostInfos
   List<Object> hostInfos = (List<Object>) slotInfo.get(2);
   if (hostInfos.size() <= 0) {
    continue;
   }
   // at this time, we just use master, discard slave information
   HostAndPort targetNode = generateHostAndPort(hostInfos);
   setNodeIfNotExist(targetNode);
   assignSlotsToNode(slotNums, targetNode);
  }
 } finally {
  w.unlock();
 }
}

代码示例来源:origin: io.leopard/leopard-redis

@Override
public List<Object> clusterSlots() {
  return jedis.clusterSlots();
}

代码示例来源:origin: io.leopard/leopard-redis

@Override
public List<Object> clusterSlots() {
  return jedis.clusterSlots();
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public List<Object> clusterSlots() {
 String command = "clusterSlots";
 return instrumented(command, () -> delegated.clusterSlots());
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

public List<Object> clusterSlots() {
  Jedis jedis = getJedis();
  try {
    return jedis.clusterSlots();
  } finally {Streams.safeClose(jedis);}
}

代码示例来源:origin: apache/servicemix-bundles

private void discoverClusterSlots(Jedis jedis) {
 List<Object> slots = jedis.clusterSlots();
 this.slots.clear();
 for (Object slotInfoObj : slots) {
  List<Object> slotInfo = (List<Object>) slotInfoObj;
  if (slotInfo.size() <= MASTER_NODE_INDEX) {
   continue;
  }
  List<Integer> slotNums = getAssignedSlotArray(slotInfo);
  // hostInfos
  List<Object> hostInfos = (List<Object>) slotInfo.get(MASTER_NODE_INDEX);
  if (hostInfos.isEmpty()) {
   continue;
  }
  // at this time, we just use master, discard slave information
  HostAndPort targetNode = generateHostAndPort(hostInfos);
  assignSlotsToNode(slotNums, targetNode);
 }
}

代码示例来源:origin: apache/servicemix-bundles

public void discoverClusterNodesAndSlots(Jedis jedis) {
 w.lock();
 try {
  reset();
  List<Object> slots = jedis.clusterSlots();
  for (Object slotInfoObj : slots) {
   List<Object> slotInfo = (List<Object>) slotInfoObj;
   if (slotInfo.size() <= MASTER_NODE_INDEX) {
    continue;
   }
   List<Integer> slotNums = getAssignedSlotArray(slotInfo);
   // hostInfos
   int size = slotInfo.size();
   for (int i = MASTER_NODE_INDEX; i < size; i++) {
    List<Object> hostInfos = (List<Object>) slotInfo.get(i);
    if (hostInfos.size() <= 0) {
     continue;
    }
    HostAndPort targetNode = generateHostAndPort(hostInfos);
    setupNodeIfNotExist(targetNode);
    if (i == MASTER_NODE_INDEX) {
     assignSlotsToNode(slotNums, targetNode);
    }
   }
  }
 } finally {
  w.unlock();
 }
}

相关文章

微信公众号

最新文章

更多

Jedis类方法