Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Resolver implementations with library solution #354

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import com.datastax.oss.driver.api.core.metadata.EndPoint;
import com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint;
import com.datastax.oss.driver.internal.core.resolver.Resolver;
import com.datastax.oss.driver.internal.core.resolver.ResolverProvider;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableSet;
import com.datastax.oss.driver.shaded.guava.common.collect.Sets;
import java.net.InetAddress;
Expand All @@ -37,7 +35,6 @@
/** Utility class to handle the initial contact points passed to the driver. */
public class ContactPoints {
private static final Logger LOG = LoggerFactory.getLogger(ContactPoints.class);
private static Resolver RESOLVER = ResolverProvider.getResolver(ContactPoints.class);

public static Set<EndPoint> merge(
Set<EndPoint> programmaticContactPoints, List<String> configContactPoints, boolean resolve) {
Expand Down Expand Up @@ -75,7 +72,7 @@ private static Set<InetSocketAddress> extract(String spec, boolean resolve) {
return ImmutableSet.of(InetSocketAddress.createUnresolved(host, port));
} else {
try {
InetAddress[] inetAddresses = RESOLVER.getAllByName(host);
InetAddress[] inetAddresses = InetAddress.getAllByName(host);
if (inetAddresses.length > 1) {
LOG.info(
"Contact point {} resolves to multiple addresses, will use them all ({})",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import com.datastax.oss.driver.api.core.addresstranslation.AddressTranslator;
import com.datastax.oss.driver.api.core.context.DriverContext;
import com.datastax.oss.driver.internal.core.resolver.Resolver;
import com.datastax.oss.driver.internal.core.resolver.ResolverProvider;
import com.datastax.oss.driver.internal.core.util.Loggers;
import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -59,8 +57,6 @@
public class Ec2MultiRegionAddressTranslator implements AddressTranslator {

private static final Logger LOG = LoggerFactory.getLogger(Ec2MultiRegionAddressTranslator.class);
private static Resolver RESOLVER =
ResolverProvider.getResolver(Ec2MultiRegionAddressTranslator.class);

private final DirContext ctx;
private final String logPrefix;
Expand Down Expand Up @@ -98,7 +94,7 @@ public InetSocketAddress translate(@NonNull InetSocketAddress socketAddress) {
return socketAddress;
}

InetAddress translatedAddress = RESOLVER.getByName(domainName);
InetAddress translatedAddress = InetAddress.getByName(domainName);
LOG.debug("[{}] Resolved {} to {}", logPrefix, address, translatedAddress);
return new InetSocketAddress(translatedAddress, socketAddress.getPort());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import com.datastax.oss.driver.internal.core.metrics.SessionMetricUpdater;
import com.datastax.oss.driver.internal.core.protocol.FrameDecoder;
import com.datastax.oss.driver.internal.core.protocol.FrameEncoder;
import com.datastax.oss.driver.internal.core.resolver.Resolver;
import com.datastax.oss.driver.internal.core.resolver.ResolverProvider;
import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
Expand All @@ -70,8 +68,6 @@ public class ChannelFactory {

private static final Logger LOG = LoggerFactory.getLogger(ChannelFactory.class);

private static Resolver RESOLVER = ResolverProvider.getResolver(ChannelFactory.class);

/**
* A value for {@link #productType} that indicates that we are connected to DataStax Cloud. This
* value matches the one defined at DSE DB server side at {@code ProductType.java}.
Expand Down Expand Up @@ -208,7 +204,7 @@ private void connect(

nettyOptions.afterBootstrapInitialized(bootstrap);

ChannelFuture connectFuture = bootstrap.connect(RESOLVER.resolve(endPoint.resolve()));
ChannelFuture connectFuture = bootstrap.connect(endPoint.resolve());

connectFuture.addListener(
cf -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package com.datastax.oss.driver.internal.core.metadata;

import com.datastax.oss.driver.api.core.metadata.EndPoint;
import com.datastax.oss.driver.internal.core.resolver.Resolver;
import com.datastax.oss.driver.internal.core.resolver.ResolverProvider;
import com.datastax.oss.driver.shaded.guava.common.primitives.UnsignedBytes;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.net.InetAddress;
Expand All @@ -32,7 +30,6 @@

public class SniEndPoint implements EndPoint {
private static final AtomicLong OFFSET = new AtomicLong();
private static Resolver RESOLVER = ResolverProvider.getResolver(SniEndPoint.class);

private final InetSocketAddress proxyAddress;
private final String serverName;
Expand All @@ -58,7 +55,7 @@ public String getServerName() {
@Override
public InetSocketAddress resolve() {
try {
InetAddress[] aRecords = RESOLVER.getAllByName(proxyAddress.getHostName());
InetAddress[] aRecords = InetAddress.getAllByName(proxyAddress.getHostName());
if (aRecords.length == 0) {
// Probably never happens, but the JDK docs don't explicitly say so
throw new IllegalArgumentException(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading