com.netflix.dyno.connectionpool.Host.getRack()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(134)

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

Host.getRack介绍

暂无

代码示例

代码示例来源:origin: Netflix/conductor

@Override
  public List<Host> getHosts() {
    List<Host> hosts = super.getHosts();
    List<Host> updatedHosts = new ArrayList<>(hosts.size());
    hosts.forEach(host -> {
      updatedHosts.add(new Host(host.getHostName(), host.getIpAddress(), readConnPort, host.getRack(), host.getDatacenter(), host.isUp() ? Host.Status.Up : Host.Status.Down));
    });
    return updatedHosts;
  }
};

代码示例来源:origin: com.netflix.dyno/dyno-core

private boolean isLocalZoneHost(Host host) {
  if (localZone == null || localZone.isEmpty()) {
    Logger.warn("Local rack was not defined");
    return true; // consider everything
  }
  return localZone.equalsIgnoreCase(host.getRack());
}

代码示例来源:origin: com.netflix.dyno/dyno-core

@Override
  public boolean apply(HostToken x) {
    if (localRack == null) {
      return true;
    }
    return rack.equals(x.getHost().getRack());
  }
});

代码示例来源:origin: Netflix/dyno-queues

@Override
public Set<String> getQueueShards() {
  return hs.getHosts().stream().map(host -> host.getRack()).map(rack -> rack.replaceAll(region, "")).collect(Collectors.toSet());
}

代码示例来源:origin: com.netflix.dyno/dyno-core

/*package private*/ int calculateReplicationFactor(List<HostToken> allHostTokens) {
  Map<Long, Integer> groups = new HashMap<>();
  Set<HostToken> uniqueHostTokens = new HashSet<>(allHostTokens);
  String dataCenter = cpConfig.getLocalDataCenter();
  if (dataCenter == null) {
    dataCenter = localRack.substring(0, localRack.length() - 1);
  }
  for (HostToken hostToken: uniqueHostTokens) {
    if (hostToken.getHost().getRack().contains(dataCenter)) {
      Long token = hostToken.getToken();
      if (groups.containsKey(token)) {
        int current = groups.get(token);
        groups.put(token, current + 1);
      } else {
        groups.put(token, 1);
      }
    }
  }
  Set<Integer> uniqueCounts = new HashSet<>(groups.values());
  if (uniqueCounts.size() > 1) {
    throw new RuntimeException("Invalid configuration - replication factor cannot be asymmetric");
  }
  int rf = uniqueCounts.toArray(new Integer[uniqueCounts.size()])[0];
  if (rf > 3) {
    logger.warn("Replication Factor is high: " + uniqueHostTokens);
  }
  return rf;
}

代码示例来源:origin: com.netflix.dyno/dyno-core

public void removeHost(Host host) {
  HostToken hostToken = hostTokens.remove(host);
  if (hostToken != null) {
    HostSelectionStrategy<CL> selector = findSelectorForRack(host.getRack());
    if (selector != null) {
      selector.removeHostPool(hostToken);
    }
    topology.get().removeHost(hostToken.getHost().getRack(), hostToken.getToken(), hostToken.getHost());
  }
}

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
  public List<Host> getHosts() {
    List<Host> hosts = super.getHosts();
    List<Host> updatedHosts = new ArrayList<>(hosts.size());
    hosts.forEach(host -> {
      updatedHosts.add(new Host(host.getHostName(), host.getIpAddress(), readConnPort, host.getRack(), host.getDatacenter(), host.isUp() ? Host.Status.Up : Host.Status.Down));
    });
    return updatedHosts;
  }
};

代码示例来源:origin: com.netflix.dyno/dyno-core

public void addHost(Host host, HostConnectionPool<CL> hostPool) {
  
  HostToken hostToken = tokenSupplier.getTokenForHost(host, hostTokens.keySet());
  if (hostToken == null) {
    throw new DynoConnectException("Could not find host token for host: " + host);
  }
  
  hostTokens.put(hostToken.getHost(), hostToken);
  
  HostSelectionStrategy<CL> selector = findSelectorForRack(host.getRack());
  if (selector != null) {
    selector.addHostPool(hostToken, hostPool);
  }
  topology.get().addHostToken(hostToken.getHost().getRack(), hostToken.getToken(), hostToken.getHost());
}

代码示例来源:origin: com.netflix.dyno/dyno-core

sb.append("\nHost: " + host.getHostAddress() + ":" + host.getPort() + ":" + host.getRack() + "\t");
sb.append(" borrowed: " + hStats.getConnectionsBorrowed());
sb.append(" returned: " + hStats.getConnectionsReturned());

代码示例来源:origin: com.netflix.dyno/dyno-core

public TokenPoolTopology createTokenPoolTopology(List<HostToken> allHostTokens) {
  TokenPoolTopology topology = new TokenPoolTopology(replicationFactor.get());
  for (HostToken hostToken : allHostTokens) {
    String rack = hostToken.getHost().getRack();
    topology.addHostToken(rack, hostToken.getToken(), hostToken.getHost());
  }
  if (localRack != null) {
    addTokens(topology, localRack, localSelector);
    for (String remoteRack : remoteRackSelectors.keySet()) {
      addTokens(topology, remoteRack, remoteRackSelectors.get(remoteRack));
    }
  }
  return topology;
}

代码示例来源:origin: com.netflix.dyno/dyno-core

String rack = host.getRack();
if (localRack != null && !localRack.isEmpty() && rack != null && !rack.isEmpty() && !localRack.equals(rack)) {
  remoteRacks.add(rack);

代码示例来源:origin: com.netflix.dyno/dyno-core

hostFromTokenMapSupplier.getPort(), hostFromTokenMapSupplier.getSecurePort(), hostFromTokenMapSupplier.getRack(),
         hostFromTokenMapSupplier.getDatacenter(), Host.Status.Up, hostFromTokenMapSupplier.getHashtag(),
         hostFromTokenMapSupplier.getPassword()));
  hostFromTokenMapSupplier.getPort(), hostFromTokenMapSupplier.getSecurePort(), hostFromTokenMapSupplier.getRack(),
  hostFromTokenMapSupplier.getDatacenter(), Host.Status.Down, hostFromTokenMapSupplier.getHashtag(),
  hostFromTokenMapSupplier.getPassword()));
h.getPort(), h.getSecurePort(), h.getRack(),
h.getDatacenter(), Host.Status.Down, h.getHashtag()));

代码示例来源:origin: com.netflix.dyno/dyno-core

Connection<CL> c = getConnection(null, token, duration, unit, new RunOnce());
if (tokenRackMapper != null) {
  tokenRackMapper.setRackForToken(token, c.getHost().getRack());

相关文章