|
82 | 82 | import org.apache.beam.sdk.values.PCollectionTuple; |
83 | 83 | import org.apache.beam.sdk.values.PCollectionView; |
84 | 84 | import org.apache.beam.sdk.values.TupleTagList; |
85 | | -import org.joda.time.Duration; |
86 | 85 | import org.slf4j.Logger; |
87 | 86 | import org.slf4j.LoggerFactory; |
| 87 | +import org.threeten.bp.Duration; |
88 | 88 |
|
89 | 89 | /** |
90 | 90 | * This pipeline ingests DataStream data from GCS as events. The events are written to Cloud |
@@ -616,6 +616,10 @@ static String getSourceType(Options options) { |
616 | 616 | LOG.error("IOException Occurred: DataStreamClient failed initialization."); |
617 | 617 | throw new IllegalArgumentException("Unable to initialize DatastreamClient: " + e); |
618 | 618 | } |
| 619 | + return getSourceTypeFromConfig(sourceConfig); |
| 620 | + } |
| 621 | + |
| 622 | + static String getSourceTypeFromConfig(SourceConfig sourceConfig) { |
619 | 623 | if (sourceConfig.getMysqlSourceConfig() != null) { |
620 | 624 | return DatastreamConstants.MYSQL_SOURCE_TYPE; |
621 | 625 | } else if (sourceConfig.getOracleSourceConfig() != null) { |
@@ -649,6 +653,10 @@ public static void main(String[] args) { |
649 | 653 | * @return The result of the pipeline execution. |
650 | 654 | */ |
651 | 655 | public static PipelineResult run(Options options) { |
| 656 | + return buildPipeline(options).run(); |
| 657 | + } |
| 658 | + |
| 659 | + static Pipeline buildPipeline(Options options) { |
652 | 660 | long startTime = System.currentTimeMillis(); |
653 | 661 | /* |
654 | 662 | * Stages: |
@@ -682,13 +690,13 @@ public static PipelineResult run(Options options) { |
682 | 690 | .withRpcPriority(ValueProvider.StaticValueProvider.of(options.getSpannerPriority())) |
683 | 691 | .withCommitRetrySettings( |
684 | 692 | RetrySettings.newBuilder() |
685 | | - .setTotalTimeout(org.threeten.bp.Duration.ofMinutes(4)) |
686 | | - .setInitialRetryDelay(org.threeten.bp.Duration.ofMinutes(0)) |
| 693 | + .setTotalTimeout(Duration.ofMinutes(4)) |
| 694 | + .setInitialRetryDelay(Duration.ofMinutes(0)) |
687 | 695 | .setRetryDelayMultiplier(1) |
688 | | - .setMaxRetryDelay(org.threeten.bp.Duration.ofMinutes(0)) |
689 | | - .setInitialRpcTimeout(org.threeten.bp.Duration.ofMinutes(4)) |
| 696 | + .setMaxRetryDelay(Duration.ofMinutes(0)) |
| 697 | + .setInitialRpcTimeout(Duration.ofMinutes(4)) |
690 | 698 | .setRpcTimeoutMultiplier(1) |
691 | | - .setMaxRpcTimeout(org.threeten.bp.Duration.ofMinutes(4)) |
| 699 | + .setMaxRpcTimeout(Duration.ofMinutes(4)) |
692 | 700 | .setMaxAttempts(1) |
693 | 701 | .build()); |
694 | 702 | SpannerConfig shadowTableSpannerConfig = getShadowTableSpannerConfig(options); |
@@ -776,7 +784,8 @@ public static PipelineResult run(Options options) { |
776 | 784 | .withFileReadConcurrency(options.getFileReadConcurrency()) |
777 | 785 | .withoutDatastreamRecordsReshuffle() |
778 | 786 | .withDirectoryWatchDuration( |
779 | | - Duration.standardMinutes(options.getDirectoryWatchDurationInMinutes())) |
| 787 | + org.joda.time.Duration.standardMinutes( |
| 788 | + options.getDirectoryWatchDurationInMinutes())) |
780 | 789 | .withDatastreamSourceType(options.getDatastreamSourceType())); |
781 | 790 | int maxNumWorkers = options.getMaxNumWorkers() != 0 ? options.getMaxNumWorkers() : 1; |
782 | 791 | jsonRecords = |
@@ -855,7 +864,7 @@ public static PipelineResult run(Options options) { |
855 | 864 | LOG.info("Filtered events directory: {}", filterEventsDirectory); |
856 | 865 | transformedRecords |
857 | 866 | .get(DatastreamToSpannerConstants.FILTERED_EVENT_TAG) |
858 | | - .apply(Window.into(FixedWindows.of(Duration.standardMinutes(1)))) |
| 867 | + .apply(Window.into(FixedWindows.of(org.joda.time.Duration.standardMinutes(1)))) |
859 | 868 | .apply( |
860 | 869 | "Write Filtered Events To GCS", |
861 | 870 | TextIO.write().to(filterEventsDirectory).withSuffix(".json").withWindowedWrites()); |
@@ -928,8 +937,7 @@ public static PipelineResult run(Options options) { |
928 | 937 | .withTmpDirectory((options).getDeadLetterQueueDirectory() + "/tmp_severe/") |
929 | 938 | .setIncludePaneInfo(true) |
930 | 939 | .build()); |
931 | | - // Execute the pipeline and return the result. |
932 | | - return pipeline.run(); |
| 940 | + return pipeline; |
933 | 941 | } |
934 | 942 |
|
935 | 943 | static SpannerConfig getShadowTableSpannerConfig(Options options) { |
@@ -968,13 +976,13 @@ static SpannerConfig getShadowTableSpannerConfig(Options options) { |
968 | 976 | .withRpcPriority(ValueProvider.StaticValueProvider.of(options.getSpannerPriority())) |
969 | 977 | .withCommitRetrySettings( |
970 | 978 | RetrySettings.newBuilder() |
971 | | - .setTotalTimeout(org.threeten.bp.Duration.ofMinutes(4)) |
972 | | - .setInitialRetryDelay(org.threeten.bp.Duration.ofMinutes(0)) |
| 979 | + .setTotalTimeout(Duration.ofMinutes(4)) |
| 980 | + .setInitialRetryDelay(Duration.ofMinutes(0)) |
973 | 981 | .setRetryDelayMultiplier(1) |
974 | | - .setMaxRetryDelay(org.threeten.bp.Duration.ofMinutes(0)) |
975 | | - .setInitialRpcTimeout(org.threeten.bp.Duration.ofMinutes(4)) |
| 982 | + .setMaxRetryDelay(Duration.ofMinutes(0)) |
| 983 | + .setInitialRpcTimeout(Duration.ofMinutes(4)) |
976 | 984 | .setRpcTimeoutMultiplier(1) |
977 | | - .setMaxRpcTimeout(org.threeten.bp.Duration.ofMinutes(4)) |
| 985 | + .setMaxRpcTimeout(Duration.ofMinutes(4)) |
978 | 986 | .setMaxAttempts(1) |
979 | 987 | .build()); |
980 | 988 | } |
|
0 commit comments