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

Initial commit of boilerplate of change stream pipeline for bigtable #25153

Merged
merged 1 commit into from
Jan 26, 2023
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 @@ -37,16 +37,19 @@
@SuppressWarnings({
"nullness" // TODO(https://github.com/apache/beam/issues/20497)
})
abstract class BigtableConfig implements Serializable {
public abstract class BigtableConfig implements Serializable {

/** Returns the project id being written to. */
abstract @Nullable ValueProvider<String> getProjectId();
public abstract @Nullable ValueProvider<String> getProjectId();

/** Returns the instance id being written to. */
abstract @Nullable ValueProvider<String> getInstanceId();
public abstract @Nullable ValueProvider<String> getInstanceId();

/** Returns the table being read from. */
abstract @Nullable ValueProvider<String> getTableId();
public abstract @Nullable ValueProvider<String> getTableId();

/** Returns the app profile being read from. */
public abstract @Nullable ValueProvider<String> getAppProfileId();

/**
* Returns the Google Cloud Bigtable instance being written to, and other parameters.
Expand Down Expand Up @@ -84,6 +87,8 @@ abstract static class Builder {

abstract Builder setTableId(ValueProvider<String> tableId);

abstract Builder setAppProfileId(ValueProvider<String> appProfileId);

/** @deprecated will be replaced by bigtable options configurator. */
@Deprecated
abstract Builder setBigtableOptions(BigtableOptions options);
Expand All @@ -100,46 +105,51 @@ abstract Builder setBigtableOptionsConfigurator(
abstract BigtableConfig build();
}

BigtableConfig withProjectId(ValueProvider<String> projectId) {
public BigtableConfig withProjectId(ValueProvider<String> projectId) {
checkArgument(projectId != null, "Project Id of BigTable can not be null");
return toBuilder().setProjectId(projectId).build();
}

BigtableConfig withInstanceId(ValueProvider<String> instanceId) {
public BigtableConfig withInstanceId(ValueProvider<String> instanceId) {
checkArgument(instanceId != null, "Instance Id of BigTable can not be null");
return toBuilder().setInstanceId(instanceId).build();
}

BigtableConfig withTableId(ValueProvider<String> tableId) {
public BigtableConfig withTableId(ValueProvider<String> tableId) {
checkArgument(tableId != null, "tableId can not be null");
return toBuilder().setTableId(tableId).build();
}

public BigtableConfig withAppProfileId(ValueProvider<String> appProfileId) {
checkArgument(appProfileId != null, "tableId can not be null");
return toBuilder().setAppProfileId(appProfileId).build();
}

/** @deprecated will be replaced by bigtable options configurator. */
@Deprecated
BigtableConfig withBigtableOptions(BigtableOptions options) {
public BigtableConfig withBigtableOptions(BigtableOptions options) {
checkArgument(options != null, "Bigtable options can not be null");
return toBuilder().setBigtableOptions(options).build();
}

BigtableConfig withBigtableOptionsConfigurator(
public BigtableConfig withBigtableOptionsConfigurator(
SerializableFunction<BigtableOptions.Builder, BigtableOptions.Builder> configurator) {
checkArgument(configurator != null, "configurator can not be null");
return toBuilder().setBigtableOptionsConfigurator(configurator).build();
}

BigtableConfig withValidate(boolean isEnabled) {
public BigtableConfig withValidate(boolean isEnabled) {
return toBuilder().setValidate(isEnabled).build();
}

@VisibleForTesting
BigtableConfig withBigtableService(BigtableService bigtableService) {
public BigtableConfig withBigtableService(BigtableService bigtableService) {
checkArgument(bigtableService != null, "bigtableService can not be null");
return toBuilder().setBigtableService(bigtableService).build();
}

@VisibleForTesting
BigtableConfig withEmulator(String emulatorHost) {
public BigtableConfig withEmulator(String emulatorHost) {
checkArgument(emulatorHost != null, "emulatorHost can not be null");
return toBuilder().setEmulatorHost(emulatorHost).build();
}
Expand Down Expand Up @@ -173,6 +183,9 @@ void populateDisplayData(DisplayData.Builder builder) {
.addIfNotNull(
DisplayData.item("instanceId", getInstanceId()).withLabel("Bigtable Instance Id"))
.addIfNotNull(DisplayData.item("tableId", getTableId()).withLabel("Bigtable Table Id"))
.addIfNotNull(
DisplayData.item("appProfileId", getAppProfileId())
.withLabel("Bigtable App Profile Id"))
.add(DisplayData.item("withValidation", getValidate()).withLabel("Check is table exists"));

if (getBigtableOptions() != null) {
Expand Down Expand Up @@ -250,6 +263,7 @@ public final String toString() {
.add("projectId", getProjectId())
.add("instanceId", getInstanceId())
.add("tableId", getTableId())
.add("appProfileId", getAppProfileId())
.add(
"bigtableOptionsConfigurator",
getBigtableOptionsConfigurator() == null
Expand Down
Loading