-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PipelineController Changes for Cassandra (#2086)
- Loading branch information
1 parent
2caf29c
commit 67efa9f
Showing
11 changed files
with
478 additions
and
44 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
33 changes: 33 additions & 0 deletions
33
...to-spanner/src/main/java/com/google/cloud/teleport/v2/source/reader/IoWrapperFactory.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.google.cloud.teleport.v2.source.reader; | ||
|
||
import com.google.cloud.teleport.v2.source.reader.io.IoWrapper; | ||
import java.util.List; | ||
import org.apache.beam.sdk.transforms.Wait; | ||
|
||
/** Factory to provide the {@link IoWrapper}. */ | ||
public interface IoWrapperFactory { | ||
|
||
/** | ||
* Create an {@link IoWrapper} instance for a list of SourceTables. | ||
* | ||
* @param sourceTables | ||
* @param waitOnSignal | ||
* @return | ||
*/ | ||
IoWrapper getIOWrapper(List<String> sourceTables, Wait.OnSignal<?> waitOnSignal); | ||
} |
55 changes: 55 additions & 0 deletions
55
...gle/cloud/teleport/v2/source/reader/io/cassandra/iowrapper/CassandraIOWrapperFactory.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.google.cloud.teleport.v2.source.reader.io.cassandra.iowrapper; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.cloud.teleport.v2.options.SourceDbToSpannerOptions; | ||
import com.google.cloud.teleport.v2.source.reader.IoWrapperFactory; | ||
import com.google.cloud.teleport.v2.source.reader.io.IoWrapper; | ||
import com.google.common.base.Preconditions; | ||
import java.util.List; | ||
import org.apache.beam.sdk.transforms.Wait.OnSignal; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
@AutoValue | ||
public abstract class CassandraIOWrapperFactory implements IoWrapperFactory { | ||
|
||
/** GCS Path for Cassandra Driver Config. */ | ||
public abstract String gcsConfigPath(); | ||
|
||
private static CassandraIOWrapperFactory create(String gcsConfigPath) { | ||
return new AutoValue_CassandraIOWrapperFactory(gcsConfigPath); | ||
} | ||
|
||
public static CassandraIOWrapperFactory fromPipelineOptions(SourceDbToSpannerOptions options) { | ||
String gcsPath = options.getSourceConfigURL(); | ||
// Implementation Details. the pipeline options are strings. | ||
Preconditions.checkArgument( | ||
options.getSourceDbDialect().equals(SourceDbToSpannerOptions.CASSANDRA_SOURCE_DIALECT), | ||
"Unexpected Dialect " + options.getSourceDbDialect() + " for Cassandra Source"); | ||
Preconditions.checkArgument( | ||
StringUtils.startsWith(gcsPath, "gs://"), | ||
"GCS path Expected in place of `" + gcsPath + "`."); | ||
return CassandraIOWrapperFactory.create(options.getSourceConfigURL()); | ||
} | ||
|
||
/** Create an {@link IoWrapper} instance for a list of SourceTables. */ | ||
@Override | ||
public IoWrapper getIOWrapper(List<String> sourceTables, OnSignal<?> waitOnSignal) { | ||
/** TODO(vardhanvthigle@) */ | ||
return null; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...db-to-spanner/src/main/java/com/google/cloud/teleport/v2/templates/DbConfigContainer.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.google.cloud.teleport.v2.templates; | ||
|
||
import com.google.cloud.teleport.v2.source.reader.io.IoWrapper; | ||
import com.google.cloud.teleport.v2.spanner.migrations.schema.ISchemaMapper; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.annotation.Nullable; | ||
import org.apache.beam.sdk.transforms.Wait; | ||
|
||
/** | ||
* Container for DB Configuration. Implementations should encapsulate the relevant source | ||
* configuration to help with invoking sharded or non-sharded migration. | ||
*/ | ||
public interface DbConfigContainer { | ||
|
||
/** | ||
* Get a Unique id for the physical data source. For Non-sharded migration, the id can be returned | ||
* as null. | ||
* | ||
* @return Unique id. | ||
*/ | ||
@Nullable | ||
String getShardId(); | ||
|
||
/** | ||
* For the spanner tables that contain the shard id column, returns the source table to | ||
* shardColumn. For non-Sharded Migration, return empty Map. | ||
* | ||
* @param schemaMapper | ||
* @param spannerTables | ||
* @return | ||
*/ | ||
Map<String, String> getSrcTableToShardIdColumnMap( | ||
ISchemaMapper schemaMapper, List<String> spannerTables); | ||
|
||
/** | ||
* Create an {@link IoWrapper} instance for a list of SourceTables. | ||
* | ||
* @param sourceTables | ||
* @param waitOnSignal | ||
* @return | ||
*/ | ||
IoWrapper getIOWrapper(List<String> sourceTables, Wait.OnSignal<?> waitOnSignal); | ||
} |
52 changes: 52 additions & 0 deletions
52
...er/src/main/java/com/google/cloud/teleport/v2/templates/DbConfigContainerDefaultImpl.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.google.cloud.teleport.v2.templates; | ||
|
||
import com.google.cloud.teleport.v2.source.reader.IoWrapperFactory; | ||
import com.google.cloud.teleport.v2.source.reader.io.IoWrapper; | ||
import com.google.cloud.teleport.v2.spanner.migrations.schema.ISchemaMapper; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.apache.beam.sdk.transforms.Wait.OnSignal; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** Default Implementation for {@link DbConfigContainer} for non-Sharded sources. */ | ||
public final class DbConfigContainerDefaultImpl implements DbConfigContainer { | ||
private IoWrapperFactory ioWrapperFactory; | ||
|
||
public DbConfigContainerDefaultImpl(IoWrapperFactory ioWrapperFactory) { | ||
this.ioWrapperFactory = ioWrapperFactory; | ||
} | ||
|
||
/** Create an {@link IoWrapper} instance for a list of SourceTables. */ | ||
@Override | ||
public IoWrapper getIOWrapper(List<String> sourceTables, OnSignal<?> waitOnSignal) { | ||
return this.ioWrapperFactory.getIOWrapper(sourceTables, waitOnSignal); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getShardId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getSrcTableToShardIdColumnMap( | ||
ISchemaMapper schemaMapper, List<String> spannerTables) { | ||
return new HashMap<>(); | ||
} | ||
} |
Oops, something went wrong.