From 78ca14e426ed3e66fda9e4cb3189bdb27320ead9 Mon Sep 17 00:00:00 2001 From: Lai Jiang Date: Thu, 10 Nov 2022 10:46:11 -0500 Subject: [PATCH] Remove JpaDemoPipeline (#1848) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change is [Reviewable](https://reviewable.io/reviews/google/nomulus/1848) --- core/build.gradle | 3 - .../registry/beam/common/JpaDemoPipeline.java | 74 ------------------- 2 files changed, 77 deletions(-) delete mode 100644 core/src/main/java/google/registry/beam/common/JpaDemoPipeline.java diff --git a/core/build.gradle b/core/build.gradle index 017e2cb8d..7041faf21 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -703,9 +703,6 @@ createToolTask( 'google.registry.tools.DevTool', sourceSets.nonprod) -createToolTask( - 'jpaDemoPipeline', 'google.registry.beam.common.JpaDemoPipeline') - createToolTask( 'createSyntheticDomainHistories', 'google.registry.tools.javascrap.CreateSyntheticDomainHistoriesPipeline') diff --git a/core/src/main/java/google/registry/beam/common/JpaDemoPipeline.java b/core/src/main/java/google/registry/beam/common/JpaDemoPipeline.java deleted file mode 100644 index ce8e0631b..000000000 --- a/core/src/main/java/google/registry/beam/common/JpaDemoPipeline.java +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2020 The Nomulus Authors. All Rights Reserved. -// -// 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 google.registry.beam.common; - -import static com.google.common.base.Verify.verify; -import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; - -import google.registry.model.contact.Contact; -import google.registry.persistence.transaction.CriteriaQueryBuilder; -import google.registry.persistence.transaction.JpaTransactionManager; -import java.io.Serializable; -import org.apache.beam.sdk.Pipeline; -import org.apache.beam.sdk.metrics.Counter; -import org.apache.beam.sdk.metrics.Metrics; -import org.apache.beam.sdk.options.PipelineOptionsFactory; -import org.apache.beam.sdk.transforms.DoFn; -import org.apache.beam.sdk.transforms.ParDo; - -/** - * Toy pipeline that demonstrates how to use {@link JpaTransactionManager} in BEAM pipelines. - * - *

This pipeline may also be used as an integration test for {@link RegistryJpaIO.Read} in a - * project with realistic data. - */ -public class JpaDemoPipeline implements Serializable { - - public static void main(String[] args) { - RegistryPipelineOptions options = - PipelineOptionsFactory.fromArgs(args).withValidation().as(RegistryPipelineOptions.class); - RegistryPipelineOptions.validateRegistryPipelineOptions(options); - - Pipeline pipeline = Pipeline.create(options); - pipeline - .apply( - "Read contacts", - RegistryJpaIO.read( - () -> CriteriaQueryBuilder.create(Contact.class).build(), Contact::getRepoId)) - .apply( - "Count Contacts", - ParDo.of( - new DoFn() { - private Counter counter = Metrics.counter("Contacts", "Read"); - - @ProcessElement - public void processElement() { - int result = - (Integer) - jpaTm() - .transact( - () -> - jpaTm() - .getEntityManager() - .createNativeQuery("select 1;") - .getSingleResult()); - verify(result == 1, "Expecting 1, got %s.", result); - counter.inc(); - } - })); - - pipeline.run(); - } -}