com.datastax.driver.core.policies.AddressTranslator Java Examples

The following examples show how to use com.datastax.driver.core.policies.AddressTranslator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReaperApplication.java    From cassandra-reaper with Apache License 2.0 5 votes vote down vote up
private void initializeJmx(ReaperApplicationConfiguration config, Cryptograph cryptograph) {
  if (context.jmxConnectionFactory == null) {
    LOG.info("no JMX connection factory given in context, creating default");
    context.jmxConnectionFactory = new JmxConnectionFactory(context, cryptograph);

    // read jmx host/port mapping from config and provide to jmx con.factory
    Map<String, Integer> jmxPorts = config.getJmxPorts();
    if (jmxPorts != null) {
      LOG.debug("using JMX ports mapping: {}", jmxPorts);
      context.jmxConnectionFactory.setJmxPorts(jmxPorts);
    }
    if (config.useAddressTranslator()) {
      context.jmxConnectionFactory.setAddressTranslator(new EC2MultiRegionAddressTranslator());
    }
    if (config.getJmxAddressTranslator().isPresent()) {
      AddressTranslator addressTranslator = config.getJmxAddressTranslator().get().build();
      context.jmxConnectionFactory.setAddressTranslator(addressTranslator);
    }
  }

  if (config.getJmxmp() != null) {
    if (config.getJmxmp().isEnabled()) {
      LOG.info("JMXMP enabled");
    }
    context.jmxConnectionFactory.setJmxmp(config.getJmxmp());
  }

  JmxCredentials jmxAuth = config.getJmxAuth();
  if (jmxAuth != null) {
    LOG.debug("using specified JMX credentials for authentication");
    context.jmxConnectionFactory.setJmxAuth(jmxAuth);
  }

  Map<String, JmxCredentials> jmxCredentials = config.getJmxCredentials();
  if (jmxCredentials != null) {
    LOG.debug("using specified JMX credentials per cluster for authentication");
    context.jmxConnectionFactory.setJmxCredentials(jmxCredentials);
  }
}
 
Example #2
Source File: JmxProxyImpl.java    From cassandra-reaper with Apache License 2.0 5 votes vote down vote up
/**
 * @see #connect(String, int, Optional, AddressTranslator, int, MetricRegistry, Cryptograph)
 */
static JmxProxy connect(
    String host,
    Optional<JmxCredentials> jmxCredentials,
    final AddressTranslator addressTranslator,
    int connectionTimeout,
    MetricRegistry metricRegistry,
    Cryptograph cryptograph,
    Jmxmp jmxmp)
    throws ReaperException, InterruptedException {

  if (host == null) {
    throw new ReaperException("Null host given to JmxProxy.connect()");
  }

  final HostAndPort hostAndPort = HostAndPort.fromString(host);

  return connect(
      hostAndPort.getHost(),
      hostAndPort.getPortOrDefault(Cluster.DEFAULT_JMX_PORT),
      jmxCredentials,
      addressTranslator,
      connectionTimeout,
      metricRegistry,
      cryptograph,
      jmxmp);
}
 
Example #3
Source File: DataSource.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    fetchSize = (Integer)in.readObject();
    readConsistency = (ConsistencyLevel)in.readObject();
    writeConsistency = (ConsistencyLevel)in.readObject();
    user = U.readString(in);
    pwd = U.readString(in);
    port = (Integer)in.readObject();
    contactPoints = (List<InetAddress>)in.readObject();
    contactPointsWithPorts = (List<InetSocketAddress>)in.readObject();
    maxSchemaAgreementWaitSeconds = (Integer)in.readObject();
    protoVer = (Integer)in.readObject();
    compression = U.readString(in);
    useSSL = (Boolean)in.readObject();
    collectMetrix = (Boolean)in.readObject();
    jmxReporting = (Boolean)in.readObject();
    creds = (Credentials)in.readObject();
    loadBalancingPlc = (LoadBalancingPolicy)readObject(in);
    reconnectionPlc = (ReconnectionPolicy)readObject(in);
    addrTranslator = (AddressTranslator)readObject(in);
    speculativeExecutionPlc = (SpeculativeExecutionPolicy)readObject(in);
    authProvider = (AuthProvider)readObject(in);
    sslOptions = (SSLOptions)readObject(in);
    poolingOptions = (PoolingOptions)readObject(in);
    sockOptions = (SocketOptions)readObject(in);
    nettyOptions = (NettyOptions)readObject(in);
}
 
Example #4
Source File: JmxConnectionFactory.java    From cassandra-reaper with Apache License 2.0 4 votes vote down vote up
public final void setAddressTranslator(AddressTranslator addressTranslator) {
  this.addressTranslator = addressTranslator;
}
 
Example #5
Source File: MultiIpPerNodeAddressTranslatorFactory.java    From cassandra-reaper with Apache License 2.0 4 votes vote down vote up
@Override
public AddressTranslator build() {
  return new MultiIpPerNodeAddressTranslator(addressTranslations);
}
 
Example #6
Source File: DataSource.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Sets address translator.
 *
 * @param translator Address translator.
 */
public void setAddressTranslator(AddressTranslator translator) {
    addrTranslator = translator;

    invalidate();
}
 
Example #7
Source File: EC2MultiRegionAddressTranslatorFactory.java    From dropwizard-cassandra with Apache License 2.0 4 votes vote down vote up
@Override
public AddressTranslator build() {
    return new EC2MultiRegionAddressTranslator();
}
 
Example #8
Source File: AddressTranslatorFactory.java    From dropwizard-cassandra with Apache License 2.0 votes vote down vote up
AddressTranslator build();