Skip to content

Commit bcd4545

Browse files
committed
resolve comments
1 parent d9f377a commit bcd4545

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
8282
private static final int MAX_MESSAGE_SIZE = 256 * 1024 * 1024;
8383
private static final String SERVER_DEFAULT_APP_PROFILE_ID = "";
8484

85-
// TODO(igorbernstein2): Remove this once DirectPath goes to public beta
86-
// Temporary endpoint for the DirectPath private alpha
87-
private static final String DIRECT_PATH_ENV_VAR = "GOOGLE_CLOUD_ENABLE_DIRECT_PATH";
85+
// TODO(weiranf): Remove this temporary endpoint once DirectPath goes to public beta
8886
private static final String DIRECT_PATH_ENDPOINT = "directpath-bigtable.googleapis.com:443";
8987

9088
private static final Set<Code> IDEMPOTENT_RETRY_CODES =
@@ -229,15 +227,11 @@ public boolean isRefreshingChannel() {
229227

230228
/** Returns a builder for the default ChannelProvider for this service. */
231229
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
232-
InstantiatingGrpcChannelProvider.Builder builder =
233-
BigtableStubSettings.defaultGrpcTransportProviderBuilder()
230+
return BigtableStubSettings.defaultGrpcTransportProviderBuilder()
234231
.setPoolSize(getDefaultChannelPoolSize())
235-
.setMaxInboundMessageSize(MAX_MESSAGE_SIZE);
236-
// TODO(weiranf): Remove this once DirectPath goes to public beta
237-
if (isDirectPathEnabled()) {
238-
builder.setAttemptDirectPath(true);
239-
}
240-
return builder;
232+
.setMaxInboundMessageSize(MAX_MESSAGE_SIZE)
233+
// TODO(weiranf): Set this to true by default once DirectPath goes to public beta
234+
.setAttemptDirectPath(isDirectPathEnabled());
241235
}
242236

243237
// TODO(weiranf): Remove this once DirectPath goes to public beta

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/DirectPathFallbackIT.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
import io.grpc.netty.shaded.io.netty.util.ReferenceCountUtil;
4040
import java.io.IOException;
4141
import java.lang.reflect.Field;
42-
import java.net.Inet4Address;
43-
import java.net.Inet6Address;
4442
import java.net.InetAddress;
4543
import java.net.InetSocketAddress;
4644
import java.net.SocketAddress;
@@ -68,6 +66,8 @@ public class DirectPathFallbackIT {
6866
// This was determined experimentally to account for both gRPC-LB RPCs and Bigtable api RPCs.
6967
private static final int MIN_COMPLETE_READ_CALLS = 40;
7068
private static final int NUM_RPCS_TO_SEND = 20;
69+
70+
// IP address prefixes allocated for DirectPath backends.
7171
private static final String DP_IPV6_PREFIX = "2001:4860:8040";
7272
private static final String DP_IPV4_PREFIX = "34.126";
7373

@@ -233,17 +233,13 @@ public void connect(
233233
if (remoteAddress instanceof InetSocketAddress) {
234234
InetAddress inetAddress = ((InetSocketAddress) remoteAddress).getAddress();
235235
String addr = inetAddress.getHostAddress();
236-
if ((inetAddress instanceof Inet6Address && addr.startsWith(DP_IPV6_PREFIX))
237-
|| (inetAddress instanceof Inet4Address && addr.startsWith(DP_IPV4_PREFIX))) {
238-
isDpAddr = true;
239-
}
236+
isDpAddr = addr.startsWith(DP_IPV6_PREFIX) || addr.startsWith(DP_IPV4_PREFIX);
240237
}
241238

242239
if (!(isDpAddr && blackholeDpAddr.get())) {
243240
super.connect(ctx, remoteAddress, localAddress, promise);
244241
} else {
245242
// Fail the connection fast
246-
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>> Failing connection");
247243
promise.setFailure(new IOException("fake error"));
248244
}
249245
}
@@ -253,7 +249,6 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
253249
boolean dropCall = isDpAddr && blackholeDpAddr.get();
254250

255251
if (dropCall) {
256-
System.out.println(">>>>>>>>>>>>>>>>>>>>>>> Dropping call.");
257252
// Don't notify the next handler and increment counter
258253
numBlocked.incrementAndGet();
259254
ReferenceCountUtil.release(msg);

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/test_helpers/env/AbstractTestEnv.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public boolean isInstanceAdminSupported() {
7575
}
7676

7777
public boolean isDirectPathEnabled() {
78-
return "bigtable".equals(System.getenv("GOOGLE_CLOUD_ENABLE_DIRECT_PATH"));
78+
return Boolean.getBoolean("bigtable.attempt-directpath");
7979
}
8080

8181
public String getPrimaryZone() {

0 commit comments

Comments
 (0)