FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Wire out a second host for admin connections by AngusDavis · Pull Request #78 · googleapis/java-bigtable-hbase · GitHub

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

Filter by extension

Filter by extension .java  (5) .xml  (2) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions anviltop-client-core/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<alpn.version>7.0.0.v20140317</alpn.version>
<google.api.client.version>1.19.0</google.api.client.version>
<google.anviltop.auth.service.account.enable>false</google.anviltop.auth.service.account.enable>
<google.anviltop.admin.endpoint.host>9f135f0537b12b4b.sandbox.google.com</google.anviltop.admin.endpoint.host>
<google.anviltop.endpoint.host>9f135f0537b12b4b.sandbox.google.com</google.anviltop.endpoint.host>
</properties>
<profiles>
<profile>
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public class AnvilTopOptionsFactory {

public static final String ANVILTOP_PORT_KEY = "google.anviltop.endpoint.port";
public static final int DEFAULT_ANVILTOP_PORT = 443;

public static final String ANVILTOP_ADMIN_HOST_KEY = "google.anviltop.admin.endpoint.host";
public static final String ANVILTOP_HOST_KEY = "google.anviltop.endpoint.host";
public static final String PROJECT_ID_KEY = "google.anviltop.project.id";


/**
* Key to set to enable service accounts to be used, either metadata server-based or P12-based.
* Defaults to enabled.
Expand Down Expand Up @@ -79,6 +80,13 @@ public static AnviltopOptions fromConfiguration(Configuration configuration) thr
String.format("API endpoint host must be supplied via %s", ANVILTOP_HOST_KEY));
optionsBuilder.setHost(host);

String adminHost = configuration.get(ANVILTOP_ADMIN_HOST_KEY);
if (!Strings.isNullOrEmpty(adminHost)) {
optionsBuilder.setAdminHost(adminHost);
} else {
optionsBuilder.setAdminHost(host);
}

int port = configuration.getInt(ANVILTOP_PORT_KEY, DEFAULT_ANVILTOP_PORT);
optionsBuilder.setPort(port);

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ public static class Builder {
private String projectId = "";
private Credential credential;
private String host;
private String adminHost;
private int port;

public Builder setAdminHost(String host) {
this.adminHost = host;
return this;
}

public Builder setHost(String host) {
this.host = host;
return this;
Expand All @@ -54,20 +60,28 @@ public Builder setProjectId(String projectId) {
}

public AnviltopOptions build() {
return new AnviltopOptions(host, port, credential, projectId);
if (Strings.isNullOrEmpty(adminHost)) {
adminHost = host;
}

return new AnviltopOptions(adminHost, host, port, credential, projectId);
}
}

private final String adminHost;
private final String host;
private final int port;
private final Credential credential;
private final String projectId;

public AnviltopOptions(String host, int port, Credential credential, String projectId) {
public AnviltopOptions(String adminHost, String host, int port, Credential credential, String projectId) {
Preconditions.checkArgument(
!Strings.isNullOrEmpty(host), "Host must not be empty or null.");
Preconditions.checkArgument(
!Strings.isNullOrEmpty(adminHost), "Admin host must not be empty or null.");
Preconditions.checkArgument(
!Strings.isNullOrEmpty(projectId), "ProjectId must not be empty or null.");
this.adminHost = adminHost;
this.host = host;
this.port = port;
this.credential = credential;
Expand All @@ -91,4 +105,11 @@ public TransportOptions getTransportOptions() {
host,
port);
}

public TransportOptions getAdminTransportOptions() {
return new TransportOptions(
TransportOptions.AnviltopTransports.HTTP2_NETTY_TLS,
adminHost,
port);
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ public AnvilTopConnection(Configuration conf) throws IOException {
this.options = AnvilTopOptionsFactory.fromConfiguration(conf);
TransportOptions transportOptions = options.getTransportOptions();
ChannelOptions channelOptions = options.getChannelOptions();
TransportOptions adminTransportOptions = options.getAdminTransportOptions();

this.client = getAnviltopClient(
transportOptions,
channelOptions,
batchPool);
this.anviltopAdminClient = getAdminClient(
transportOptions,
adminTransportOptions,
channelOptions,
batchPool);
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ public void testHostIsRequired() throws IOException {
AnvilTopOptionsFactory.fromConfiguration(configuration);
}

@Test
public void testAdminHostKeyIsUsed() throws IOException {
Configuration configuration = new Configuration();
configuration.set(AnvilTopOptionsFactory.PROJECT_ID_KEY, TEST_PROJECT_ID);
configuration.set(AnvilTopOptionsFactory.ANVILTOP_HOST_KEY, TEST_HOST);
configuration.set(AnvilTopOptionsFactory.ANVILTOP_ADMIN_HOST_KEY, TEST_HOST + "-admin");
configuration.setBoolean(AnvilTopOptionsFactory.ANVILTOP_USE_SERVICE_ACCOUNTS_KEY, false);
configuration.setBoolean(AnvilTopOptionsFactory.ANVILTOP_NULL_CREDENTIAL_ENABLE_KEY, true);
AnviltopOptions options = AnvilTopOptionsFactory.fromConfiguration(configuration);
Assert.assertEquals(TEST_HOST + "-admin", options.getAdminTransportOptions().getHost());
}

@Test
public void testOptionsAreConstructedWithValidInput() throws IOException {
Configuration configuration = new Configuration();
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TestAnviltopTable {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
AnviltopOptions options = new AnviltopOptions("testhost", 0, null, TEST_PROJECT);
AnviltopOptions options = new AnviltopOptions("testhost-admin", "testhost", 0, null, TEST_PROJECT);
table = new AnvilTopTable(
TableName.valueOf(TEST_TABLE),
options,
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
</property>
<property>
<name>google.anviltop.endpoint.host</name>
<value>9f135f0537b12b4b.sandbox.google.com</value>
<value>${google.anviltop.endpoint.host}</value>
</property>
<property>
<name>google.anviltop.endpoint.port</name>
<value>443</value>
</property>
<property>
<name>google.anviltop.admin.endpoint.host</name>
<value>${google.anviltop.admin.endpoint.host}</value>
</property>
<property>
<name>google.anviltop.project.id</name>
<value>testproject</value>
Expand Down

Back | FazBrowse Home | New Git URL