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

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

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

Host.<init>介绍

暂无

代码示例

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

private List<Host> parseHostsFrom(String hostConfig){
    List<String> hostConfigs = Arrays.asList(hostConfig.split(";"));

    List<Host> hosts = hostConfigs.stream().map(hc -> {
      String[] hostConfigValues = hc.split(":");
      String host = hostConfigValues[0];
      int port = Integer.parseInt(hostConfigValues[1]);
      String rack = hostConfigValues[2];
      return new Host(host, port, rack, Host.Status.Up);
    }).collect(Collectors.toList());

    return hosts;
  }
}

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

@Override
  public HostSupplier get() {
    Host dynoHost = new Host("localhost", 0, configuration.getAvailabilityZone(), Host.Status.Up);
    return ()-> Lists.newArrayList(dynoHost);
  }
}

代码示例来源: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.spinnaker.kork/kork-dynomite

public List<Host> getDynoHosts() {
 return hosts.stream()
  .map(it -> new Host(it.hostname, it.ipAddress, it.port, it.rack, it.datacenter, it.status, it.hashtag))
  .collect(Collectors.toList());
}

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

private List<Host> parseHostsFrom(String hostConfig){
    List<String> hostConfigs = Arrays.asList(hostConfig.split(";"));

    List<Host> hosts = hostConfigs.stream().map(hc -> {
      String[] hostConfigValues = hc.split(":");
      String host = hostConfigValues[0];
      int port = Integer.parseInt(hostConfigValues[1]);
      String rack = hostConfigValues[2];
      return new Host(host, port, rack, Host.Status.Up);
    }).collect(Collectors.toList());

    return hosts;
  }
}

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

@Override
  public HostSupplier get() {
    Host dynoHost = new Host("localhost", 0, configuration.getAvailabilityZone(), Host.Status.Up);
    return ()-> Lists.newArrayList(dynoHost);
  }
}

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

private List<Host> readHostsFromFile(String filename, int port) throws Exception {
  List<Host> hosts = new ArrayList<Host>();
  File file = new File(filename);
  BufferedReader reader = new BufferedReader(new FileReader(file));
  try {
    String line = null;
    while ((line = reader.readLine()) != null) {
      if (line.trim().isEmpty()) {
        continue;
      }
      String[] parts = line.trim().split(" ");
      if (parts.length != 2) {
        throw new RuntimeException("Bad data format in file:" + line);
      }
      Host host = new Host(parts[0].trim(), port, parts[1].trim(), Status.Up);
      hosts.add(host);
    }
  } finally {
    reader.close();
  }
  return hosts;
}

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

public void initWithLocalHost() throws Exception {
  final int port = 6379;
  final HostSupplier localHostSupplier = new HostSupplier() {
    final Host hostSupplierHost = new Host("localhost", localRack, Status.Up);
    @Override
    public List<Host> getHosts() {
      return Collections.singletonList(hostSupplierHost);
    }
  };
  final TokenMapSupplier tokenSupplier = new TokenMapSupplier() {
    final Host tokenHost = new Host("localhost", port, localRack, Status.Up);
    final HostToken localHostToken = new HostToken(100000L, tokenHost);
    @Override
    public List<HostToken> getTokens(Set<Host> activeHosts) {
      return Collections.singletonList(localHostToken);
    }
    @Override
    public HostToken getTokenForHost(Host host, Set<Host> activeHosts) {
      return localHostToken;
    }
  };
  init(localHostSupplier, port, tokenSupplier);
}

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

@Override
  public List<Host> getHosts() {
    List<Host> hosts = new LinkedList<>();
    hosts.add(new Host("host1", 8102, "us-east-1a", Status.Up));
    hosts.add(new Host("host1", 8102, "us-east-1b", Status.Up));
    hosts.add(new Host("host1", 8102, "us-east-1d", Status.Up));
    
    return hosts;
  }
};

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

@Override
public void init(DataGenerator dataGenerator) throws Exception {
  this.dataGenerator = dataGenerator;
  if (jedisClient.get() != null) {
    return;
  }
  logger.info("Initing dyno jedis client");
  logger.info("\nDynomite Cluster: " + ClusterName);
  HostSupplier hSupplier = () -> {
    List<Host> hosts = new ArrayList<>();
    hosts.add(new Host("localhost", 8102, "local-dc", Host.Status.Up));
    return hosts;
  };
  DynoJedisClient jClient = new DynoJedisClient.Builder().withApplicationName(ClusterName)
      .withDynomiteClusterName(ClusterName).withHostSupplier(hSupplier).build();
  jedisClient.set(jClient);
}

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

@Override
public void init(DataGenerator dataGenerator) throws Exception {
  this.dataGenerator = dataGenerator;
  if (jedisClient.get() != null) {
    return;
  }
  logger.info("Initing dyno jedis client");
  logger.info("\nDynomite Cluster: " + ClusterName);
  HostSupplier hSupplier = () -> {
    List<Host> hosts = new ArrayList<>();
    hosts.add(new Host("localhost", 8102, "local-dc", Host.Status.Up));
    return hosts;
  };
  DynoJedisClient jClient = new DynoJedisClient.Builder().withApplicationName(ClusterName)
      .withDynomiteClusterName(ClusterName).withHostSupplier(hSupplier).build();
  jedisClient.set(jClient);
}

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

@Override
public void init(DataGenerator dataGenerator) throws Exception {
  this.dataGenerator = dataGenerator;
  if (jedisClient.get() != null) {
    return;
  }
  logger.info("Initing dyno jedis client");
  logger.info("\nDynomite Cluster: " + ClusterName);
  HostSupplier hSupplier = () -> {
    List<Host> hosts = new ArrayList<>();
    hosts.add(new Host("localhost", 8102, "local-dc", Host.Status.Up));
    return hosts;
  };
  DynoJedisClient jClient = new DynoJedisClient.Builder().withApplicationName(ClusterName)
      .withDynomiteClusterName(ClusterName).withHostSupplier(hSupplier).build();
  jedisClient.set(jClient);
}

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

@Override
public void init(DataGenerator dataGenerator) throws Exception {
  this.dataGenerator = dataGenerator;
  if (jedisClient.get() != null) {
    return;
  }
  logger.info("Initing dyno jedis client");
  logger.info("\nDynomite Cluster: " + ClusterName);
  HostSupplier hSupplier = () -> {
    List<Host> hosts = new ArrayList<>();
    hosts.add(new Host("localhost", 8102, "local-dc", Host.Status.Up));
    return hosts;
  };
  DynoJedisClient jClient = new DynoJedisClient.Builder().withApplicationName(ClusterName)
      .withDynomiteClusterName(ClusterName).withHostSupplier(hSupplier).build();
  jedisClient.set(jClient);
}

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

@Override
public void init(DataGenerator dataGenerator) throws Exception {
  this.dataGenerator = dataGenerator;
  if (jedisClient.get() != null) {
    return;
  }
  logger.info("Initing dyno jedis client");
  logger.info("\nDynomite Cluster: " + ClusterName);
  HostSupplier hSupplier = () -> {
    List<Host> hosts = new ArrayList<>();
    hosts.add(new Host("localhost", 8102, "local-dc",Host.Status.Up));
    return hosts;
  };
  DynoJedisClient jClient = new DynoJedisClient.Builder().withApplicationName(ClusterName)
      .withDynomiteClusterName(ClusterName).withHostSupplier(hSupplier).build();
  jedisClient.set(jClient);
}

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

@Override
public void init(DataGenerator dataGenerator) throws Exception {
  this.dataGenerator = dataGenerator;
  if (jedisClient.get() != null) {
    return;
  }
  logger.info("Initing dyno jedis client");
  logger.info("\nDynomite Cluster: " + ClusterName);
  HostSupplier hSupplier = () -> {
    List<Host> hosts = new ArrayList<>();
    hosts.add(new Host("localhost", 8102, "local-dc",Host.Status.Up));
    return hosts;
  };
  DynoJedisClient jClient = new DynoJedisClient.Builder().withApplicationName(ClusterName)
      .withDynomiteClusterName(ClusterName).withHostSupplier(hSupplier).build();
  jedisClient.set(jClient);
}

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

@Override
public void init(DataGenerator dataGenerator) throws Exception {
  this.dataGenerator = dataGenerator;
  if (jedisClient.get() != null) {
    return;
  }
  logger.info("Initing dyno jedis client");
  logger.info("\nDynomite Cluster: " + ClusterName);
  HostSupplier hSupplier = () -> {
    List<Host> hosts = new ArrayList<>();
    hosts.add(new Host("localhost", 8102, "local-dc", Host.Status.Up));
    return hosts;
  };
  DynoJedisClient jClient = new DynoJedisClient.Builder().withApplicationName(ClusterName)
      .withDynomiteClusterName(ClusterName).withHostSupplier(hSupplier).build();
  jedisClient.set(jClient);
}

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

@Override
public void init(DataGenerator dataGenerator) throws Exception {
  this.dataGenerator = dataGenerator;
  if (jedisClient.get() != null) {
    return;
  }
  logger.info("Initing dyno jedis client");
  logger.info("\nDynomite Cluster: " + ClusterName);
  HostSupplier hSupplier = () -> {
    List<Host> hosts = new ArrayList<>();
    hosts.add(new Host("localhost", 8102, "local-dc", Host.Status.Up));
    return hosts;
  };
  DynoJedisClient jClient = new DynoJedisClient.Builder().withApplicationName(ClusterName)
      .withDynomiteClusterName(ClusterName).withHostSupplier(hSupplier).build();
  jedisClient.set(jClient);
}

代码示例来源: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: Netflix/dyno-queues

@Override
  public Host apply(InstanceInfo info) {
    Host.Status status = info.getStatus() == InstanceStatus.UP ? Host.Status.Up : Host.Status.Down;
    String rack = null;
    if (info.getDataCenterInfo() instanceof AmazonInfo) {
      AmazonInfo amazonInfo = (AmazonInfo) info.getDataCenterInfo();
      rack = amazonInfo.get(MetaDataKey.availabilityZone);
    }
    Host host = new Host(info.getHostName(), info.getIPAddr(), rack, status);
    return host;
  }
}));

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

@Override
  public Host apply(InstanceInfo info) {
    
    Host.Status status = info.getStatus() == InstanceStatus.UP ? Host.Status.Up : Host.Status.Down;
    
    String rack = null;
    try {
      if (info.getDataCenterInfo() instanceof AmazonInfo) {
        AmazonInfo amazonInfo = (AmazonInfo)info.getDataCenterInfo();
        rack = amazonInfo.get(MetaDataKey.availabilityZone);
      }
    }
    catch (Throwable t) {
      Logger.error("Error getting rack for host " + info.getHostName(), t);
    }
    if(rack == null) {
      Logger.error("Rack wasn't found for host:" + info.getHostName() + " there may be issues matching it up to the token map");
    }
    Host host = new Host(info.getHostName(), info.getIPAddr(), rack, status);
    return host;
  }
}));

相关文章