Skip to content

Commit

Permalink
[BEAM-1794] BigtableIO: update user agent computation for new bigtabl…
Browse files Browse the repository at this point in the history
…e-client-core
  • Loading branch information
dhalperi committed Mar 24, 2017
1 parent 5903e69 commit 282c3ff
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ public Read withBigtableOptions(BigtableOptions.Builder optionsBuilder) {
// Set data channel count to one because there is only 1 scanner in this session
BigtableOptions.Builder clonedBuilder = options.toBuilder()
.setDataChannelCount(1);
BigtableOptions optionsWithAgent = clonedBuilder.setUserAgent(getUserAgent()).build();
BigtableOptions optionsWithAgent =
clonedBuilder.setUserAgent(getBeamSdkPartOfUserAgent()).build();

return new Read(optionsWithAgent, tableId, keyRange, filter, bigtableService);
}
Expand Down Expand Up @@ -449,7 +450,8 @@ public Write withBigtableOptions(BigtableOptions.Builder optionsBuilder) {
options.getBulkOptions().toBuilder()
.setUseBulkApi(true)
.build());
BigtableOptions optionsWithAgent = clonedBuilder.setUserAgent(getUserAgent()).build();
BigtableOptions optionsWithAgent =
clonedBuilder.setUserAgent(getBeamSdkPartOfUserAgent()).build();
return new Write(optionsWithAgent, tableId, bigtableService);
}

Expand Down Expand Up @@ -1047,16 +1049,16 @@ public BigtableWriteException(KV<ByteString, Iterable<Mutation>> record, Throwab
}

/**
* A helper function to produce a Cloud Bigtable user agent string.
* A helper function to produce a Cloud Bigtable user agent string. This need only include
* information about the Apache Beam SDK itself, because Bigtable will automatically append
* other relevant system and Bigtable client-specific version information.
*
* @see com.google.cloud.bigtable.config.BigtableVersionInfo
*/
private static String getUserAgent() {
String javaVersion = System.getProperty("java.specification.version");
private static String getBeamSdkPartOfUserAgent() {
ReleaseInfo info = ReleaseInfo.getReleaseInfo();
return String.format(
"%s/%s (%s); %s",
info.getName(),
info.getVersion(),
javaVersion,
"0.3.0" /* TODO get Bigtable client version directly from jar. */);
return
String.format("%s/%s", info.getName(), info.getVersion())
.replace(" ", "_");
}
}

0 comments on commit 282c3ff

Please sign in to comment.