Codota Logo
Host.getRack
Code IndexAdd Codota to your IDE (free)

How to use
getRack
method
in
com.datastax.driver.core.Host

Best Java code snippets using com.datastax.driver.core.Host.getRack (Showing top 20 results out of 315)

  • Common ways to obtain Host
private void myMethod () {
Host h =
  • Codota IconControlConnection controlConnection;controlConnection.connectedHost()
  • Codota IconMetadata metadata;InetSocketAddress address;metadata.getHost(address)
  • Codota IconConcurrentMap concurrentMap;Object object;concurrentMap.get(object)
  • Smart code suggestions by Codota
}
origin: apache/storm

/**
 * {@inheritDoc}
 */
@Override
public synchronized Session connect() throws NoHostAvailableException {
  if (isDisconnected()) {
    LOG.info("Connected to cluster: {}", cluster.getClusterName());
    for (Host host : getAllHosts())
      LOG.info("Datacenter: {}; Host: {}; Rack: {}", host.getDatacenter(), host.getAddress(), host.getRack());
    LOG.info("Connect to cluster using keyspace %s", keyspace);
    session = cluster.connect(keyspace);
  } else {
    LOG.warn("{} - Already connected to cluster: {}", getExecutorName(), cluster.getClusterName());
  }
  if (session.isClosed()) {
    LOG.warn("Session has been closed - create new one!");
    this.session = cluster.newSession();
  }
  return session;
}
origin: Netflix/conductor

  @Override
  public Cluster get() {
    String host = configuration.getHostAddress();
    int port = configuration.getPort();

    LOGGER.info("Connecting to cassandra cluster with host:{}, port:{}", host, port);

    Cluster cluster = Cluster.builder()
        .addContactPoint(host)
        .withPort(port)
        .build();

    Metadata metadata = cluster.getMetadata();
    LOGGER.info("Connected to cluster: {}", metadata.getClusterName());
    metadata.getAllHosts().forEach(h -> {
      LOGGER.info("Datacenter:{}, host:{}, rack: {}", h.getDatacenter(), h.getAddress(), h.getRack());
    });
    return cluster;
  }
}
origin: brianfrankcooper/YCSB

logger.info("Datacenter: {}; Host: {}; Rack: {}\n",
  discoveredHost.getDatacenter(), discoveredHost.getAddress(),
  discoveredHost.getRack());
origin: com.datastax.cassandra/cassandra-driver-core

private Map<String, Set<String>> getRacksInDcs(Iterable<Host> hosts) {
 Map<String, Set<String>> result = new HashMap<String, Set<String>>();
 for (Host host : hosts) {
  Set<String> racks = result.get(host.getDatacenter());
  if (racks == null) {
   racks = new HashSet<String>();
   result.put(host.getDatacenter(), racks);
  }
  racks.add(host.getRack());
 }
 return result;
}
origin: com.datastax.cassandra/cassandra-driver-core

if (rf == null || dcReplicas.size() >= rf) continue;
String rack = h.getRack();
origin: com.datastax.cassandra/cassandra-driver-core

private static void updateLocationInfo(
  Host host,
  String datacenter,
  String rack,
  boolean isInitialConnection,
  Cluster.Manager cluster) {
 if (MoreObjects.equal(host.getDatacenter(), datacenter)
   && MoreObjects.equal(host.getRack(), rack)) return;
 // If the dc/rack information changes for an existing node, we need to update the load balancing
 // policy.
 // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes
 // that the policy will update correctly, but in practice this should work.
 if (!isInitialConnection) cluster.loadBalancingPolicy().onDown(host);
 host.setLocationInfo(datacenter, rack);
 if (!isInitialConnection) cluster.loadBalancingPolicy().onAdd(host);
}
origin: io.prestosql.cassandra/cassandra-driver

private Map<String, Set<String>> getRacksInDcs(Iterable<Host> hosts) {
  Map<String, Set<String>> result = new HashMap<String, Set<String>>();
  for (Host host : hosts) {
    Set<String> racks = result.get(host.getDatacenter());
    if (racks == null) {
      racks = new HashSet<String>();
      result.put(host.getDatacenter(), racks);
    }
    racks.add(host.getRack());
  }
  return result;
}
origin: com.yugabyte/cassandra-driver-core

private Map<String, Set<String>> getRacksInDcs(Iterable<Host> hosts) {
  Map<String, Set<String>> result = new HashMap<String, Set<String>>();
  for (Host host : hosts) {
    Set<String> racks = result.get(host.getDatacenter());
    if (racks == null) {
      racks = new HashSet<String>();
      result.put(host.getDatacenter(), racks);
    }
    racks.add(host.getRack());
  }
  return result;
}
origin: com.facebook.presto.cassandra/cassandra-driver

private Map<String, Set<String>> getRacksInDcs(Iterable<Host> hosts) {
  Map<String, Set<String>> result = new HashMap<String, Set<String>>();
  for (Host host : hosts) {
    Set<String> racks = result.get(host.getDatacenter());
    if (racks == null) {
      racks = new HashSet<String>();
      result.put(host.getDatacenter(), racks);
    }
    racks.add(host.getRack());
  }
  return result;
}
origin: org.springframework.data/spring-data-cassandra

private RingMember(Host host) {
  Assert.notNull(host, "Host must not be null");
  this.hostName = host.getAddress().getHostName();
  this.address = host.getAddress().getHostAddress();
  this.dc = host.getDatacenter();
  this.rack = host.getRack();
}
origin: org.springframework.data/spring-cql

public RingMember(Host h) {
  this.hostName = h.getAddress().getHostName();
  this.address = h.getAddress().getHostAddress();
  this.DC = h.getDatacenter();
  this.rack = h.getRack();
}
origin: intuit/wasabi

host.getDatacenter(),
host.getAddress(),
host.getRack());
origin: QSFT/Doradus

private void displayClusterInfo() {
  Metadata metadata = m_cluster.getMetadata();
  m_logger.info("Connected to cluster with topography:");
  RoundRobinPolicy policy = new RoundRobinPolicy();
  for (Host host : metadata.getAllHosts()) {
    m_logger.info("   Host {}: datacenter: {}, rack: {}, distance: {}",
           new Object[]{host.getAddress(), host.getDatacenter(), 
      host.getRack(), policy.distance(host)});
  }
  m_logger.info("Database contains {} keyspaces", metadata.getKeyspaces().size());
}   // displayClusterInfo
origin: com.dell.doradus/doradus-server

private void displayClusterInfo() {
  Metadata metadata = m_cluster.getMetadata();
  m_logger.info("Connected to cluster with topography:");
  RoundRobinPolicy policy = new RoundRobinPolicy();
  for (Host host : metadata.getAllHosts()) {
    m_logger.info("   Host {}: datacenter: {}, rack: {}, distance: {}",
           new Object[]{host.getAddress(), host.getDatacenter(), 
      host.getRack(), policy.distance(host)});
  }
  m_logger.info("Database contains {} keyspaces", metadata.getKeyspaces().size());
}   // displayClusterInfo
origin: com.stratio.cassandra/cassandra-driver-core

private static void updateLocationInfo(Host host, String datacenter, String rack, Cluster.Manager cluster) {
  if (Objects.equal(host.getDatacenter(), datacenter) && Objects.equal(host.getRack(), rack))
    return;
  // If the dc/rack information changes, we need to update the load balancing policy.
  // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes
  // that the policy will update correctly, but in practice this should work.
  cluster.loadBalancingPolicy().onDown(host);
  host.setLocationInfo(datacenter, rack);
  cluster.loadBalancingPolicy().onAdd(host);
}
origin: com.netflix.astyanax/astyanax-cql

private Host parseHostInfo(ResultSet rs) {
  
  if (rs == null) {
    return null;
  }
  
  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;
}

origin: jgoodyear/ApacheKarafCookbook

public void connect(String node) {
  cluster = Cluster.builder().addContactPoint(node).build();
  Metadata metadata = cluster.getMetadata();
  System.out.printf("Connected to cluster: %s\n", metadata.getClusterName());
  for (Host host : metadata.getAllHosts()) {
    System.out.printf("Datatacenter: %s; Host: %s; Rack: %s\n", host.getDatacenter(), host.getAddress(), host.getRack());
  }
  session = cluster.connect("karaf_demo");
}
origin: io.prestosql.cassandra/cassandra-driver

private static void updateLocationInfo(Host host, String datacenter, String rack, boolean isInitialConnection, Cluster.Manager cluster) {
  if (Objects.equal(host.getDatacenter(), datacenter) && Objects.equal(host.getRack(), rack))
    return;
  // If the dc/rack information changes for an existing node, we need to update the load balancing policy.
  // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes
  // that the policy will update correctly, but in practice this should work.
  if (!isInitialConnection)
    cluster.loadBalancingPolicy().onDown(host);
  host.setLocationInfo(datacenter, rack);
  if (!isInitialConnection)
    cluster.loadBalancingPolicy().onAdd(host);
}
origin: com.yugabyte/cassandra-driver-core

private static void updateLocationInfo(Host host, String datacenter, String rack, boolean isInitialConnection, Cluster.Manager cluster) {
  if (MoreObjects.equal(host.getDatacenter(), datacenter) && MoreObjects.equal(host.getRack(), rack))
    return;
  // If the dc/rack information changes for an existing node, we need to update the load balancing policy.
  // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes
  // that the policy will update correctly, but in practice this should work.
  if (!isInitialConnection)
    cluster.loadBalancingPolicy().onDown(host);
  host.setLocationInfo(datacenter, rack);
  if (!isInitialConnection)
    cluster.loadBalancingPolicy().onAdd(host);
}
origin: com.facebook.presto.cassandra/cassandra-driver

private static void updateLocationInfo(Host host, String datacenter, String rack, boolean isInitialConnection, Cluster.Manager cluster) {
  if (Objects.equal(host.getDatacenter(), datacenter) && Objects.equal(host.getRack(), rack))
    return;
  // If the dc/rack information changes for an existing node, we need to update the load balancing policy.
  // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes
  // that the policy will update correctly, but in practice this should work.
  if (!isInitialConnection)
    cluster.loadBalancingPolicy().onDown(host);
  host.setLocationInfo(datacenter, rack);
  if (!isInitialConnection)
    cluster.loadBalancingPolicy().onAdd(host);
}
com.datastax.driver.coreHostgetRack

Javadoc

Returns the name of the rack this host is part of.

The returned rack name is the one as known by Cassandra. It is also possible for this information to be unavailable. In that case this method returns null, and the caller should always be aware of this possibility.

Popular methods of Host

  • getAddress
    Returns the address that the driver will use to connect to the node. This is a shortcut for getSocke
  • getDatacenter
    Returns the name of the datacenter this host is part of. The returned datacenter name is the one as
  • getCassandraVersion
    The Cassandra version the host is running. It is also possible for this information to be unavailabl
  • isUp
    Returns whether the host is considered up by the driver. Please note that this is only the view of t
  • getSocketAddress
    Returns the address and port that the driver will use to connect to the node. This is the node's br
  • toString
  • equals
  • <init>
  • getBroadcastAddress
    Returns the node broadcast address (that is, the IP by which it should be contacted by other peers i
  • setDown
  • setLocationInfo
  • setUp
  • setLocationInfo,
  • setUp,
  • wasJustAdded,
  • setDseGraphEnabled,
  • setDseVersion,
  • setDseWorkload,
  • setTokens,
  • setVersion,
  • getBroadcastSocketAddress

Popular in Java

  • Reactive rest calls using spring rest template
  • setScale (BigDecimal)
  • getExternalFilesDir (Context)
  • onRequestPermissionsResult (Fragment)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now