You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/09/15 08:40:57 UTC

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #1791: Disruptor native support

ppalaga commented on a change in pull request #1791:
URL: https://github.com/apache/camel-quarkus/pull/1791#discussion_r488483156



##########
File path: docs/modules/ROOT/pages/reference/extensions/disruptor.adoc
##########
@@ -28,3 +28,8 @@ Please refer to the above links for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Camel Quarkus limitations
+
+The disruptor-vm provide support for communication across CamelContext instances but since camel-quarkus support a single CamelContext, such component is not available.

Review comment:
       ```suggestion
   The `disruptor-vm` component is not available on Camel Quarkus. This is because it is supposed to provide support for communication across multiple CamelContext instances within a single JVM, but by design, there is always just a single `CamelContext` on Camel Quarkus. Therefore `disruptor-vm` would make no sense.
   ```

##########
File path: extensions/disruptor/deployment/src/main/java/org/apache/camel/quarkus/component/disruptor/deployment/DisruptorProcessor.java
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.camel.quarkus.component.disruptor.deployment;
+
+import com.lmax.disruptor.BlockingWaitStrategy;
+import com.lmax.disruptor.BusySpinWaitStrategy;
+import com.lmax.disruptor.SleepingWaitStrategy;
+import com.lmax.disruptor.YieldingWaitStrategy;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
+import org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilter;
+import org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem;
+
+class DisruptorProcessor {
+    private static final String FEATURE = "camel-disruptor";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    CamelServiceFilterBuildItem excludeDisruptorVM() {
+        // The disruptor-vm provide support for communication across CamelContext instances but
+        // since camel-quarkus support a single CamelContext, the component does not make sense.
+        return new CamelServiceFilterBuildItem(CamelServiceFilter.forComponent("disruptor-vm"));
+    }
+
+    @BuildStep
+    ReflectiveClassBuildItem reflectiveClasses(CombinedIndexBuildItem index) {
+        // Note: this should be kept in sink with org.apache.camel.component.disruptor.DisruptorWaitStrategy
+        return new ReflectiveClassBuildItem(
+                true,
+                false,
+                BlockingWaitStrategy.class,
+                SleepingWaitStrategy.class,
+                BusySpinWaitStrategy.class,
+                YieldingWaitStrategy.class);
+    }
+
+    @BuildStep
+    RuntimeReinitializedClassBuildItem reinitializedRingBufferFields() {
+        // The `com.lmax.disruptor.RingBufferFields` class uses sun.misc.Unsafe behind the scenes to compute some static
+        // fields and that confuses graalvm which emits warnings like:
+        //
+        //   Warning: RecomputeFieldValue.ArrayBaseOffset automatic substitution failed. The automatic substitution
+        //   registration was attempted because a call to jdk.internal.misc.Unsafe.arrayBaseOffset(Class) was detected
+        //   in the static initializer of com.lmax.disruptor.RingBufferFields. Detailed failure reason(s): Could not
+        //   determine the field where the value produced by the call to jdk.internal.misc.Unsafe.arrayBaseOffset(Class)
+        //   for the array base offset computation is stored. The call is not directly followed by a field store or by
+        //   a sign extend node followed directly by a field store.
+        //
+        // Even if this is reported as a warning and the native compilation succeed, some static field are not computed
+        // properly which result in weird result as runtime. For such reason, the static init method need to re-run at
+        // runtime.

Review comment:
       I appreciate the comment!

##########
File path: extensions/disruptor/runtime/pom.xml
##########
@@ -57,6 +57,11 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-disruptor</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.graalvm.nativeimage</groupId>
+            <artifactId>svm</artifactId>
+            <scope>provided</scope>        </dependency>
+

Review comment:
       ```suggestion
               <scope>provided</scope>
           </dependency>
   
   ```

##########
File path: extensions/disruptor/runtime/pom.xml
##########
@@ -87,6 +92,8 @@
                             <version>${quarkus.version}</version>
                         </path>
                     </annotationProcessorPaths>
+                    <source>9</source>
+                    <target>9</target>

Review comment:
       We still support target 1.8. If this is really required, it should be properly explained in the limitations.adoc, IMO. Why is this necessary, BTW? 

##########
File path: integration-tests/disruptor/pom.xml
##########
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.camel.quarkus</groupId>
+        <artifactId>camel-quarkus-integration-tests</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-quarkus-integration-test-disruptor</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: Disruptor</name>
+    <description>Integration tests for Camel Quarkus Disruptor extension</description>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.camel.quarkus</groupId>
+                <artifactId>camel-quarkus-bom-test</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-disruptor</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-jsonb</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy-jsonb</artifactId>
+        </dependency>
+
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.rest-assured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->

Review comment:
       Note to myself: We should perhaps make the regen of these virtual deps a part of the regular build. Otherwise ppl. won't regen them and the CI will fail with strange dependency errors. And yes, the vitual deps are out of sync here.




----------------------------------------------------------------
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.

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