You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/09/09 21:52:55 UTC

[GitHub] [beam] kileys opened a new pull request, #23165: Automatically open module/packages for Java 11+

kileys opened a new pull request, #23165:
URL: https://github.com/apache/beam/pull/23165

   **Please** add a meaningful description for your change here
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/get-started-contributing/#make-the-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/workflows/Go%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244159372

   Run seed job


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244615044

   Run Java_Amazon-Web-Services2_IO_Direct Precommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lukecwik commented on a diff in pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
lukecwik commented on code in PR #23165:
URL: https://github.com/apache/beam/pull/23165#discussion_r984980653


##########
sdks/java/container/agent/build.gradle:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+plugins {
+    id 'org.apache.beam.module'
+}
+applyJavaNature(
+        exportJavadoc: false,
+        publish: false
+)
+
+description = "Apache Beam :: SDKs :: Java :: Container :: Agent"
+
+jar {
+    manifest {
+        attributes("Agent-Class": "org.apache.beam.agent.OpenModuleAgent",
+                "Can-Redefine-Classes": true,
+                "Can-Retransform-Classes": true,
+                "Premain-Class": "org.apache.beam.agent.OpenModuleAgent")
+    }
+}
+
+if (project.hasProperty('java11Home')) {
+    javaVersion = "1.11"
+    def java11Home = project.findProperty('java11Home')
+    project.tasks.withType(JavaCompile) {
+        options.fork = true
+        options.forkOptions.javaHome = java11Home as File
+        options.compilerArgs += ['-Xlint:-path']
+    }
+} else if (project.hasProperty('java17Home')) {
+    javaVersion = "1.17"
+    def java17Home = project.findProperty("java17Home")
+    project.tasks.withType(JavaCompile) {

Review Comment:
   Can we share this list of stuff with BeamModulePlugin.groovy?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1242530404

   Run Load Tests Java 17 CoGBK Dataflow V2 Streaming


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1247171300

   Run Java_Amazon-Web-Services2_IO_Direct Precommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1242509693

   Run Load Tests Java 11 CoGBK Dataflow V2 Streaming


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1255083473

   Run Java PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1268923794

   Run Java_GCP_IO_Direct PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1247294151

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1255083745

   Run Python PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1242530458

   Run Load Tests Java 11 CoGBK Dataflow V2 Streaming


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1263083154

   Run Load Tests Java 17 CoGBK Dataflow V2 Batch


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1242521486

   Run Load Tests Java 11 CoGBK Dataflow V2 Streaming


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1242510356

   Run Load Tests Java 17 CoGBK Dataflow V2 Streaming


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244218643

   Run Go Spark ValidatesRunner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] codecov[bot] commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1242544953

   # [Codecov](https://codecov.io/gh/apache/beam/pull/23165?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#23165](https://codecov.io/gh/apache/beam/pull/23165?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (31afad8) into [master](https://codecov.io/gh/apache/beam/commit/ab8a375acf4b2da3e38c1061b4d25af0f50b2e1d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ab8a375) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #23165   +/-   ##
   =======================================
     Coverage   73.58%   73.58%           
   =======================================
     Files         716      716           
     Lines       95301    95301           
   =======================================
     Hits        70132    70132           
     Misses      23873    23873           
     Partials     1296     1296           
   ```
   
   
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
Abacn commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1282509673

   This PR likely breaks beam_Publish_Beam_SDK_Snapshots: https://ci-beam.apache.org/job/beam_Publish_Beam_SDK_Snapshots/4066/


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lukecwik commented on a diff in pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
lukecwik commented on code in PR #23165:
URL: https://github.com/apache/beam/pull/23165#discussion_r984979236


##########
sdks/java/container/agent/src/main/java/org/apache/beam/agent/OpenModuleAgent.java:
##########
@@ -24,26 +24,28 @@
 import java.util.Map;
 import java.util.Set;
 
+/*
+ * Opens all base modules in the JDK to jamm (used to accurately measure object sizes)
+ */
 public class OpenModuleAgent {
   public static void premain(String argument, Instrumentation instrumentation) {
-    Set<Module> automaticModules = new HashSet<>();
     Set<Module> modulesToOpen = new HashSet<>();
+    Module jamm = ModuleLayer.boot().findModule("jamm").orElse(null);

Review Comment:
   ```suggestion
       Optional<Module> jamm = ModuleLayer.boot().findModule("jamm");
       if (!jamm.isPresent()) {
         ... log warning about expected to find jamm module ...
         return;
       }
   ```



##########
sdks/java/container/agent/src/main/java/org/apache/beam/agent/OpenModuleAgent.java:
##########
@@ -24,26 +24,28 @@
 import java.util.Map;
 import java.util.Set;
 
+/*
+ * Opens all base modules in the JDK to jamm (used to accurately measure object sizes)
+ */
 public class OpenModuleAgent {
   public static void premain(String argument, Instrumentation instrumentation) {
-    Set<Module> automaticModules = new HashSet<>();
     Set<Module> modulesToOpen = new HashSet<>();
+    Module jamm = ModuleLayer.boot().findModule("jamm").orElse(null);
     ModuleLayer.boot()
         .modules()
         .forEach(
             module -> {
-              if (module.getDescriptor().isAutomatic()) {
-                automaticModules.add(module);
-              } else if (!module.getDescriptor().isOpen()) {
+              if (!module.getDescriptor().isOpen()) {
                 modulesToOpen.add(module);
               }
             });
 
-    if (!automaticModules.isEmpty()) {
+    if (jamm != null) {
+      Set<Module> openModules = Set.of(jamm);

Review Comment:
   ```suggestion
       Set<Module> openModules = Set.of(jamm.get());
   ```



##########
sdks/java/container/agent/build.gradle:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+plugins {
+    id 'org.apache.beam.module'
+}
+applyJavaNature(
+        exportJavadoc: false,
+        publish: false
+)
+
+description = "Apache Beam :: SDKs :: Java :: Container :: Agent"
+
+jar {
+    manifest {
+        attributes("Agent-Class": "org.apache.beam.agent.OpenModuleAgent",
+                "Can-Redefine-Classes": true,
+                "Can-Retransform-Classes": true,
+                "Premain-Class": "org.apache.beam.agent.OpenModuleAgent")
+    }
+}
+
+if (project.hasProperty('java11Home')) {
+    javaVersion = "1.11"
+    def java11Home = project.findProperty('java11Home')
+    project.tasks.withType(JavaCompile) {
+        options.fork = true
+        options.forkOptions.javaHome = java11Home as File
+        options.compilerArgs += ['-Xlint:-path']
+    }
+} else if (project.hasProperty('java17Home')) {
+    javaVersion = "1.17"
+    def java17Home = project.findProperty("java17Home")
+    project.tasks.withType(JavaCompile) {

Review Comment:
   ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lukecwik commented on a diff in pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
lukecwik commented on code in PR #23165:
URL: https://github.com/apache/beam/pull/23165#discussion_r994958102


##########
sdks/java/container/agent/src/main/java/org/apache/beam/agent/OpenModuleAgent.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.beam.agent;
+
+import java.lang.instrument.Instrumentation;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+/*
+ * Opens all base modules in the JDK to jamm (used to accurately measure object sizes)
+ */
+public class OpenModuleAgent {
+  public static void premain(String argument, Instrumentation instrumentation) {
+    Set<Module> modulesToOpen = new HashSet<>();
+    Optional<Module> jamm = ModuleLayer.boot().findModule("jamm");
+    if (!jamm.isPresent()) {
+      System.out.println("Jamm module expected, but not found");

Review Comment:
   ```suggestion
         System.err.println("Jamm module expected, but not found");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys merged pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys merged PR #23165:
URL: https://github.com/apache/beam/pull/23165


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244226910

   Run Load Tests Java 11 CoGBK Dataflow V2 Batch


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244216281

   Run GoPortable PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244614290

   Run GoPortable PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1242535024

   Run Load Tests Java 11 CoGBK Dataflow V2 Streaming


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1247233274

   Run Java_Kafka_IO_Direct PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1247262228

   R: @lukecwik 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244194926

   Run seed job


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244218052

   Run Go Samza ValidatesRunner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1247167037

   Run Load Tests Java 17 CoGBK Dataflow V2 Batch


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lukecwik commented on a diff in pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
lukecwik commented on code in PR #23165:
URL: https://github.com/apache/beam/pull/23165#discussion_r978796531


##########
sdks/java/container/agent/src/main/java/org/apache/beam/agent/OpenModuleAgent.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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 org.apache.beam.agent;
+
+import java.lang.instrument.Instrumentation;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class OpenModuleAgent {
+  public static void premain(String argument, Instrumentation instrumentation) {
+    Set<Module> automaticModules = new HashSet<>();
+    Set<Module> modulesToOpen = new HashSet<>();
+    ModuleLayer.boot()
+        .modules()
+        .forEach(
+            module -> {
+              if (module.getDescriptor().isAutomatic()) {
+                automaticModules.add(module);
+              } else if (!module.getDescriptor().isOpen()) {
+                modulesToOpen.add(module);
+              }
+            });
+
+    if (!automaticModules.isEmpty()) {
+      for (Module module : modulesToOpen) {
+        Map<String, Set<Module>> addOpens = new HashMap<>();
+        for (String pkg : module.getPackages()) {
+          addOpens.put(pkg, automaticModules);
+        }
+        instrumentation.redefineModule(

Review Comment:
   can we limit this only to jamm?



##########
sdks/java/container/common.gradle:
##########
@@ -86,6 +89,16 @@ task skipPullLicenses(type: Exec) {
     args "-c", "mkdir -p build/target/go-licenses build/target/options build/target/third_party_licenses && touch build/target/third_party_licenses/skip"
 }
 
+task validateJavaHome {
+    if (JavaVersion.VERSION_1_8.compareTo(JavaVersion.current()) >= 0 && imageJavaVersion == "17" || imageJavaVersion == "11") {

Review Comment:
   nit:
   ```suggestion
       if (JavaVersion.VERSION_1_8.compareTo(JavaVersion.current()) >= 0 && imageJavaVersion == "11" || imageJavaVersion == "17") {
   ```



##########
release/src/main/scripts/build_release_candidate.sh:
##########
@@ -135,6 +140,12 @@ if [[ -z "$USER_GITHUB_ID" ]] ; then
   exit 1
 fi
 
+if [[ -z "$JAVA11_HOME" ]] ; then
+  echo 'Please provide Java 11 home'

Review Comment:
   ```suggestion
     echo 'Please provide Java 11 home. Required to build sdks/java/container/agent for Java 11+ containers.'
   ```



##########
sdks/java/container/common.gradle:
##########
@@ -48,6 +48,9 @@ task copyDockerfileDependencies(type: Copy) {
     from configurations.dockerDependency
     rename 'slf4j-api.*', 'slf4j-api.jar'
     rename 'slf4j-jdk14.*', 'slf4j-jdk14.jar'
+    if (imageJavaVersion == "17" || imageJavaVersion == "11") {

Review Comment:
   ```suggestion
       if (imageJavaVersion == "11" || imageJavaVersion == "17") {
   ```



##########
sdks/java/container/agent/build.gradle:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+plugins {
+    id 'org.apache.beam.module'
+}
+applyJavaNature(
+        exportJavadoc: false,

Review Comment:
   nit: spacing



##########
sdks/java/container/Dockerfile:
##########
@@ -31,7 +31,8 @@ ADD target/beam-sdks-java-io-kafka.jar /opt/apache/beam/jars/
 ADD target/kafka-clients.jar /opt/apache/beam/jars/
 
 # Required to use jamm as a javaagent to get accurate object size measuring
-ADD target/jamm.jar /opt/apache/beam/jars/
+# COPY fails if file is not found, so use a wildcard for open-module-agent.jar

Review Comment:
   ```suggestion
   # COPY fails if file is not found, so use a wildcard for open-module-agent.jar since it is only included in Java 9+ containers
   ```



##########
sdks/java/container/agent/build.gradle:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+plugins {
+    id 'org.apache.beam.module'
+}
+applyJavaNature(
+        exportJavadoc: false,
+        publish: false
+)
+
+description = "Apache Beam :: SDKs :: Java :: Container :: Agent"
+
+jar {
+    manifest {
+        attributes("Agent-Class": "org.apache.beam.agent.OpenModuleAgent",
+                "Can-Redefine-Classes": true,
+                "Can-Retransform-Classes": true,
+                "Premain-Class": "org.apache.beam.agent.OpenModuleAgent")
+    }
+}
+
+if (project.hasProperty('java11Home')) {
+    javaVersion = "1.11"
+    def java11Home = project.findProperty('java11Home')
+    project.tasks.withType(JavaCompile) {
+        options.fork = true
+        options.forkOptions.javaHome = java11Home as File
+        options.compilerArgs += ['-Xlint:-path']
+    }
+} else if (project.hasProperty('java17Home')) {
+    javaVersion = "1.17"
+    def java17Home = project.findProperty("java17Home")
+    project.tasks.withType(JavaCompile) {

Review Comment:
   Is there a way to share this logic with BeamModulePlugin.groovy?



##########
website/www/site/content/en/contribute/release-guide.md:
##########
@@ -499,7 +499,7 @@ Consider adding known issues there for minor issues instead of accepting cherry
 * There are no open pull requests to release branch;
 * Originating branch has the version information updated to the new version;
 * Nightly snapshot is in progress (do revisit it continually);
-* Set `JAVA_HOME` to JDK 8 (Example: `export JAVA_HOME=/example/path/to/java/jdk8`).
+* Set `JAVA_HOME` to JDK 8 (Example: `export JAVA_HOME=/example/path/to/java/jdk8`). You'll also need Java 11+ installed.

Review Comment:
   ```suggestion
   * Set `JAVA_HOME` to JDK 8 (Example: `export JAVA_HOME=/example/path/to/java/jdk8`).
   * Have Java 11 installed.
   ```



##########
sdks/java/container/common.gradle:
##########
@@ -86,6 +89,16 @@ task skipPullLicenses(type: Exec) {
     args "-c", "mkdir -p build/target/go-licenses build/target/options build/target/third_party_licenses && touch build/target/third_party_licenses/skip"
 }
 
+task validateJavaHome {
+    if (JavaVersion.VERSION_1_8.compareTo(JavaVersion.current()) >= 0 && imageJavaVersion == "17" || imageJavaVersion == "11") {

Review Comment:
   Why the 1.8 check?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1247167172

   Run Load Tests Java 11 CoGBK Dataflow V2 Batch


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244217391

   Run Go Flink ValidatesRunner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244226192

   Run Load Tests Java 17 CoGBK Dataflow V2 Batch


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1244589689

   Run seed job


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] kileys commented on pull request #23165: Automatically open module/packages for Java 11+

Posted by GitBox <gi...@apache.org>.
kileys commented on PR #23165:
URL: https://github.com/apache/beam/pull/23165#issuecomment-1242521550

   Run Load Tests Java 17 CoGBK Dataflow V2 Streaming


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org