You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by lc...@apache.org on 2016/04/12 20:06:31 UTC
[1/2] incubator-beam git commit: Add InProcessRegistrar
Repository: incubator-beam
Updated Branches:
refs/heads/master c558a64c3 -> 9f41ddbb3
Add InProcessRegistrar
Adds @AutoService for the InProcessPipelineRunner and
InProcessPipelineOptions
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/ec266465
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/ec266465
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/ec266465
Branch: refs/heads/master
Commit: ec2664652a7c8c47c831b80523b39f7edb23695b
Parents: c558a64
Author: Thomas Groh <tg...@google.com>
Authored: Fri Apr 8 10:03:10 2016 -0700
Committer: Luke Cwik <lc...@google.com>
Committed: Tue Apr 12 10:47:17 2016 -0700
----------------------------------------------------------------------
.../runners/inprocess/InProcessRegistrar.java | 54 +++++++++++++++
.../InProcessPipelineRegistrarTest.java | 73 ++++++++++++++++++++
2 files changed, 127 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/ec266465/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessRegistrar.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessRegistrar.java b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessRegistrar.java
new file mode 100644
index 0000000..e031aa6
--- /dev/null
+++ b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessRegistrar.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.dataflow.sdk.runners.inprocess;
+
+import com.google.auto.service.AutoService;
+import com.google.cloud.dataflow.sdk.options.PipelineOptions;
+import com.google.cloud.dataflow.sdk.options.PipelineOptionsRegistrar;
+import com.google.cloud.dataflow.sdk.runners.PipelineRunner;
+import com.google.cloud.dataflow.sdk.runners.PipelineRunnerRegistrar;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Contains the {@link PipelineRunnerRegistrar} and {@link PipelineOptionsRegistrar} for the
+ * {@link InProcessPipelineRunner}.
+ */
+public class InProcessRegistrar {
+ private InProcessRegistrar() {}
+ /**
+ * Registers the {@link InProcessPipelineRunner}.
+ */
+ @AutoService(PipelineRunnerRegistrar.class)
+ public static class InProcessRunner implements PipelineRunnerRegistrar {
+ @Override
+ public Iterable<Class<? extends PipelineRunner<?>>> getPipelineRunners() {
+ return ImmutableList.<Class<? extends PipelineRunner<?>>>of(InProcessPipelineRunner.class);
+ }
+ }
+
+ /**
+ * Registers the {@link InProcessPipelineOptions}.
+ */
+ @AutoService(PipelineOptionsRegistrar.class)
+ public static class InProcessOptions implements PipelineOptionsRegistrar {
+ @Override
+ public Iterable<Class<? extends PipelineOptions>> getPipelineOptions() {
+ return ImmutableList.<Class<? extends PipelineOptions>>of(InProcessPipelineOptions.class);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/ec266465/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRegistrarTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRegistrarTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRegistrarTest.java
new file mode 100644
index 0000000..2d60052
--- /dev/null
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRegistrarTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.dataflow.sdk.runners.inprocess;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import com.google.cloud.dataflow.sdk.options.PipelineOptionsRegistrar;
+import com.google.cloud.dataflow.sdk.runners.PipelineRunnerRegistrar;
+import com.google.cloud.dataflow.sdk.runners.inprocess.InProcessRegistrar.InProcessRunner;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.util.ServiceLoader;
+
+/** Tests for {@link InProcessRunner}. */
+@RunWith(JUnit4.class)
+public class InProcessPipelineRegistrarTest {
+ @Test
+ public void testCorrectOptionsAreReturned() {
+ assertEquals(
+ ImmutableList.of(InProcessPipelineOptions.class),
+ new InProcessRegistrar.InProcessOptions().getPipelineOptions());
+ }
+
+ @Test
+ public void testCorrectRunnersAreReturned() {
+ assertEquals(
+ ImmutableList.of(InProcessPipelineRunner.class),
+ new InProcessRegistrar.InProcessRunner().getPipelineRunners());
+ }
+
+ @Test
+ public void testServiceLoaderForOptions() {
+ for (PipelineOptionsRegistrar registrar :
+ Lists.newArrayList(ServiceLoader.load(PipelineOptionsRegistrar.class).iterator())) {
+ if (registrar instanceof InProcessRegistrar.InProcessOptions) {
+ return;
+ }
+ }
+ fail("Expected to find " + InProcessRegistrar.InProcessOptions.class);
+ }
+
+ @Test
+ public void testServiceLoaderForRunner() {
+ for (PipelineRunnerRegistrar registrar :
+ Lists.newArrayList(ServiceLoader.load(PipelineRunnerRegistrar.class).iterator())) {
+ if (registrar instanceof InProcessRegistrar.InProcessRunner) {
+ return;
+ }
+ }
+ fail("Expected to find " + InProcessRegistrar.InProcessRunner.class);
+ }
+}
[2/2] incubator-beam git commit: [BEAM-22] This closes #169
Posted by lc...@apache.org.
[BEAM-22] This closes #169
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/9f41ddbb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/9f41ddbb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/9f41ddbb
Branch: refs/heads/master
Commit: 9f41ddbb38d02d85cab9503a2e0d9072a5f1b965
Parents: c558a64 ec26646
Author: Luke Cwik <lc...@google.com>
Authored: Tue Apr 12 10:47:57 2016 -0700
Committer: Luke Cwik <lc...@google.com>
Committed: Tue Apr 12 10:47:57 2016 -0700
----------------------------------------------------------------------
.../runners/inprocess/InProcessRegistrar.java | 54 +++++++++++++++
.../InProcessPipelineRegistrarTest.java | 73 ++++++++++++++++++++
2 files changed, 127 insertions(+)
----------------------------------------------------------------------