Package com.netflix.astyanax.connectionpool

Examples of com.netflix.astyanax.connectionpool.Host


      boolean b = true;
      logger.info("Strategy: " + METASTRATEGY.getValue() + " RF: "
          + METARF.getValue());
      try {
        b = keyspace.getConnectionPool().hasHost(
            new Host("localhost:9160", 9160));
      } catch (ConnectionException ex) {

      }
      if (b) {
        keyspace.createKeyspace(ImmutableMap
View Full Code Here


                                            @Override
                                            public Host apply(InstanceInfo info) {
                                                String[] parts = StringUtils.split(
                                                        StringUtils.split(info.getHostName(), ".")[0], '-');
       
                                                Host host = new Host(info.getHostName(), info.getPort())
                                                        .addAlternateIpAddress(
                                                                StringUtils.join(new String[] { parts[1], parts[2], parts[3],
                                                                        parts[4] }, "."))
                                                        .addAlternateIpAddress(info.getIPAddr())
                                                        .setId(info.getId());
                                               
                                                try {
                                                    if (info.getDataCenterInfo() instanceof AmazonInfo) {
                                                        AmazonInfo amazonInfo = (AmazonInfo)info.getDataCenterInfo();
                                                        host.setRack(amazonInfo.get(MetaDataKey.availabilityZone));
                                                    }
                                                }
                                                catch (Throwable t) {
                                                    LOG.error("Error getting rack for host " + host.getName(), t);
                                                }
       
                                                return host;
                                            }
                                        }));
View Full Code Here

public class LocalHostSupplierProvider implements HostSupplierProvider {
    private final List<Host> localhost;
   
    public LocalHostSupplierProvider() {
        localhost = Lists.newArrayList(new Host("localhost", 9160));
    }
View Full Code Here

                                        }), new Function<InstanceInfo, Host>() {
                                            public Host apply(InstanceInfo info) {
                                                String[] parts = StringUtils.split(
                                                        StringUtils.split(info.getHostName(), ".")[0], '-');
       
                                                Host host = new Host(info.getHostName(), info.getPort())
                                                        .addAlternateIpAddress(
                                                                StringUtils.join(new String[] { parts[1], parts[2], parts[3],
                                                                        parts[4] }, "."))
                                                        .addAlternateIpAddress(info.getIPAddr())
                                                        .setId(info.getId());
                                               
                                                try {
                                                    if (info.getDataCenterInfo() instanceof AmazonInfo) {
                                                        AmazonInfo amazonInfo = (AmazonInfo)info.getDataCenterInfo();
                                                        host.setRack(amazonInfo.get(MetaDataKey.availabilityZone));
                                                    }
                                                }
                                                catch (Throwable t) {
                                                    LOG.error("Error getting rack for host " + host.getName(), t);
                                                }
       
                                                return host;
                                            }
                                        }));
View Full Code Here

    public List<Host> get() {
        // TODO Auto-generated method stub
        List<Host>  list = new ArrayList<Host>();
//        Host h1 = new Host("ec2-54-235-224-8.compute-1.amazonaws.com",7102);
        Host h1 = new Host("54.235.224.8",7102);

//        Host h2 = new Host("ec2-54-224-106-243.compute-1.amazonaws.com",7102);
        Host h2 = new Host("54.224.106.243",7102);

//        Host h3 = new Host("ec2-54-242-127-138.compute-1.amazonaws.com",7102);
        Host h3 = new Host("54.242.127.138",7102);

        list.add(h1);
        list.add(h2);
        list.add(h3);
        return list;
View Full Code Here

    }
   
    com.datastax.driver.core.Host fromHost = rs.getExecutionInfo().getQueriedHost();
    InetAddress add = fromHost.getAddress();
   
    Host toHost = new Host(add.getHostAddress(), -1);
    toHost.setRack(fromHost.getRack());
    return toHost;
  }
View Full Code Here

        }

        List<Host> result = Lists.newArrayList(Collections2.filter(sourceList, new Predicate<Host>() {
            @Override
            public boolean apply(Host host) {
                Host foundHost = lookup.get(host.getHostName());
                if (foundHost == null) {
                    for (String addr : host.getAlternateIpAddresses()) {
                        foundHost = lookup.get(addr);
                        if (foundHost != null) {
                            break;
                        }
                    }
                }
               
                if (foundHost != null) {
                    host.setTokenRanges(foundHost.getTokenRanges());
                    return true;
                }
               
                return false;
            }
View Full Code Here

            BigInteger minInitialToken,
            BigInteger maxInitialToken) {
       
        List<Host> hosts = Lists.newArrayList();
        for (int i = 0; i < nHosts; i++) {
            hosts.add(new Host("127.0." + id + "." + i + ":" + TestHostType.GOOD_FAST.ordinal(), 9160));
        }

        for (int i = 0; i < nHosts; i++) {
            String startToken = TokenGenerator.initialToken(nHosts, i,   minInitialToken, maxInitialToken);
            String endToken   = TokenGenerator.initialToken(nHosts, i+1, minInitialToken, maxInitialToken);
View Full Code Here

    }

    @Test
    public void testAddHost() {
        Host host = new Host("127.0.0.1", TestHostType.GOOD_FAST.ordinal());

        CountingConnectionPoolMonitor monitor = new CountingConnectionPoolMonitor();

        ConnectionPoolConfiguration config = createConfig();
        SimpleHostConnectionPool<TestClient> pool = new SimpleHostConnectionPool<TestClient>(
View Full Code Here

        Assert.assertEquals(1,      pool.getIdleConnectionCount());
    }

    @Test
    public void testAddHostWithCheckedException() {
        Host host = new Host("127.0.0.1",
                TestHostType.CONNECT_TIMEOUT.ordinal());

        ConnectionPoolConfiguration config = createConfig();
        CountingConnectionPoolMonitor monitor = new CountingConnectionPoolMonitor();
        SimpleHostConnectionPool<TestClient> pool = new SimpleHostConnectionPool<TestClient>(
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.connectionpool.Host

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.