Skip to content
Closed
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<spanner.version>1.49.1</spanner.version>
<gax.version>1.52.0</gax.version>
<open-census.version>0.24.0</open-census.version>
<bigtable.version>1.5.0</bigtable.version>
<bigtable.version>1.15.0</bigtable.version>
<bigtable-beam-import.version>1.5.0</bigtable-beam-import.version>
<bigquery.version>v2-rev20190917-1.30.3</bigquery.version>
<jackson2.version>1.34.1</jackson2.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.bigtable.v2.Mutation;
import com.google.bigtable.v2.Mutation.SetCell;
import com.google.cloud.bigtable.config.{BigtableOptions, BulkOptions};
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.ByteString;
Expand All @@ -34,6 +35,7 @@
import org.apache.beam.sdk.options.ValueProvider.StaticValueProvider;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.transforms.ParDo;
import org.apache.beam.sdk.transforms.SerializableFunction;
import org.apache.beam.sdk.values.KV;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -86,6 +88,12 @@ public interface Options extends PipelineOptions {

@SuppressWarnings("unused")
void setInputFilePattern(ValueProvider<String> inputFilePattern);

@Description("If true, enable a mechanism that reduces the likelihood that a BulkMutation overloads a cluster")
ValueProvider<Boolean> getEnableBulkMutationThrottling();

@Description("Set the option to throttle bulk mutations")
void setEnableBulkMutationThrottling(ValueProvider<Boolean> enableBulkMutationThrottling);
}

/**
Expand All @@ -107,10 +115,24 @@ public static void main(String[] args) {
public static PipelineResult run(Options options) {
Pipeline pipeline = Pipeline.create(options);

BulkOptions.Builder bulkOptionsBuilder = BulkOptions.newBuilder();
if (options.getEnableBulkMutationThrottling() != null && options.getEnableBulkMutationThrottling().get()) {
bulkOptionsBuilder.enableBulkMutationThrottling();
}

Comment on lines +118 to +122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aananthram - This part runs at graph creation time and not at runtime so whether we enableBulkMutationThrottling will be determined at the template creation and is not going at runtime.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out! how are the args for project, etc, handled below at runtime then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at our SDK, it seems the projectid and instanceid should not be provided[1]

"WARNING: instanceId and projectId should not be provided here and should be provided over withProjectId(org.apache.beam.sdk.options.ValueProvider<java.lang.String>) and withInstanceId(org.apache.beam.sdk.options.ValueProvider<java.lang.String>)."

[1] https://beam.apache.org/releases/javadoc/2.23.0/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.Write.html#withBigtableOptionsConfigurator-org.apache.beam.sdk.transforms.SerializableFunction-

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, i see. so that allows them to be provided at runtime. is there a way to enable bulk mutation at runtime then?

BigtableIO.Write write =
BigtableIO.write()
.withProjectId(options.getBigtableProjectId())
.withInstanceId(options.getBigtableInstanceId())
.withBigtableOptionsConfigurator(
new SerializableFunction<com.google.cloud.bigtable.config.BigtableOptions.Builder, com.google.cloud.bigtable.config.BigtableOptions.Builder>() {
@Override
public com.google.cloud.bigtable.config.BigtableOptions.Builder apply(com.google.cloud.bigtable.config.BigtableOptions.Builder input) {
input
.setProjectId(options.getBigtableProjectId())
.setInstanceId(options.getBigtableInstanceId())
.setBulkOptions(bulkOptionsBuilder.build())
}
}
)
.withTableId(options.getBigtableTableId());

pipeline
Expand Down