You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/10/23 13:42:45 UTC

[camel-quarkus] branch camel-master updated (0afa405 -> e67c949)

This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a change to branch camel-master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git.


    from 0afa405  Fix of MockResource due to recent changes in camel master.
     new 7c5e474  LevelDB extension does not compile with Camel 3.7.0-SNAPSHOT #1948
     new e67c949  Generated changes in doc

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../ROOT/pages/reference/extensions/leveldb.adoc   | 12 +++-
 .../zipkin.adoc => components/atlasmap.adoc}       |  0
 .../zipkin.adoc => dataformats/json-jsonb.adoc}    |  0
 .../{others/zipkin.adoc => languages/joor.adoc}    |  0
 .../others/{zipkin.adoc => leveldb-legacy.adoc}    |  0
 .../leveldb/runtime/src/main/doc/limitations.adoc  | 12 +++-
 .../component/leveldb/ObjectCodecSubstitute.java   | 64 -------------------
 .../QuarkusLevelDBAggregationRepository.java       | 71 ++++++++++++++++++++++
 .../component/leveldb/it/LeveldbRouteBuilder.java  | 10 +--
 .../quarkus/component/leveldb/it/LeveldbIT.java    |  4 --
 .../quarkus/component/leveldb/it/LeveldbTest.java  | 14 +----
 11 files changed, 96 insertions(+), 91 deletions(-)
 copy docs/modules/ROOT/partials/reference/{others/zipkin.adoc => components/atlasmap.adoc} (100%)
 copy docs/modules/ROOT/partials/reference/{others/zipkin.adoc => dataformats/json-jsonb.adoc} (100%)
 copy docs/modules/ROOT/partials/reference/{others/zipkin.adoc => languages/joor.adoc} (100%)
 copy docs/modules/ROOT/partials/reference/others/{zipkin.adoc => leveldb-legacy.adoc} (100%)
 delete mode 100644 extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/ObjectCodecSubstitute.java
 create mode 100644 extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/QuarkusLevelDBAggregationRepository.java


[camel-quarkus] 02/02: Generated changes in doc

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch camel-master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit e67c949d74097fe40ed40b4c01125a28160cb640
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Fri Oct 23 13:44:28 2020 +0200

    Generated changes in doc
---
 docs/modules/ROOT/partials/reference/components/atlasmap.adoc    | 1 +
 docs/modules/ROOT/partials/reference/dataformats/json-jsonb.adoc | 1 +
 docs/modules/ROOT/partials/reference/languages/joor.adoc         | 1 +
 docs/modules/ROOT/partials/reference/others/leveldb-legacy.adoc  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/docs/modules/ROOT/partials/reference/components/atlasmap.adoc b/docs/modules/ROOT/partials/reference/components/atlasmap.adoc
new file mode 100644
index 0000000..a509c1d
--- /dev/null
+++ b/docs/modules/ROOT/partials/reference/components/atlasmap.adoc
@@ -0,0 +1 @@
+// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page
diff --git a/docs/modules/ROOT/partials/reference/dataformats/json-jsonb.adoc b/docs/modules/ROOT/partials/reference/dataformats/json-jsonb.adoc
new file mode 100644
index 0000000..a509c1d
--- /dev/null
+++ b/docs/modules/ROOT/partials/reference/dataformats/json-jsonb.adoc
@@ -0,0 +1 @@
+// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page
diff --git a/docs/modules/ROOT/partials/reference/languages/joor.adoc b/docs/modules/ROOT/partials/reference/languages/joor.adoc
new file mode 100644
index 0000000..a509c1d
--- /dev/null
+++ b/docs/modules/ROOT/partials/reference/languages/joor.adoc
@@ -0,0 +1 @@
+// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page
diff --git a/docs/modules/ROOT/partials/reference/others/leveldb-legacy.adoc b/docs/modules/ROOT/partials/reference/others/leveldb-legacy.adoc
new file mode 100644
index 0000000..a509c1d
--- /dev/null
+++ b/docs/modules/ROOT/partials/reference/others/leveldb-legacy.adoc
@@ -0,0 +1 @@
+// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page


[camel-quarkus] 01/02: LevelDB extension does not compile with Camel 3.7.0-SNAPSHOT #1948

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch camel-master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 7c5e474c1d5b457fc2bc32ed0ed2f0a400490712
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Fri Oct 23 12:52:14 2020 +0200

    LevelDB extension does not compile with Camel 3.7.0-SNAPSHOT #1948
---
 .../ROOT/pages/reference/extensions/leveldb.adoc   | 12 +++-
 .../leveldb/runtime/src/main/doc/limitations.adoc  | 12 +++-
 .../component/leveldb/ObjectCodecSubstitute.java   | 64 -------------------
 .../QuarkusLevelDBAggregationRepository.java       | 71 ++++++++++++++++++++++
 .../component/leveldb/it/LeveldbRouteBuilder.java  | 10 +--
 .../quarkus/component/leveldb/it/LeveldbIT.java    |  4 --
 .../quarkus/component/leveldb/it/LeveldbTest.java  | 14 +----
 7 files changed, 96 insertions(+), 91 deletions(-)

diff --git a/docs/modules/ROOT/pages/reference/extensions/leveldb.adoc b/docs/modules/ROOT/pages/reference/extensions/leveldb.adoc
index 6d1a5e8..e85afba 100644
--- a/docs/modules/ROOT/pages/reference/extensions/leveldb.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/leveldb.adoc
@@ -38,8 +38,14 @@ In native mode the extension uses a port of LevelDB written in Java (https://git
 which is within 10% of the performance of the C++ original. Please upvote https://github.com/apache/camel-quarkus/issues/1911[this issue]
 if you do not like the present state.
 
-This extension does not support binary payloads in native mode since object serialization is https://github.com/oracle/graal/issues/460[not supported] on GraalVM. To work around this limitation, the extension instead uses Jackson serializaton / deserialization.
+Serialization is https://github.com/oracle/graal/issues/460[not supported] on GraalVM. Extension has to use serializationization based
+on Jackson. Aggregation repository in native has to be constructed in one of the following ways:
+
+* Use class `QuarkusLevelDBAggregationRepository` instead of `LevelDBAggregationRepository`.
+* Configure jackson serializer on `LevelDBAggregationRepository` by calling `repo.setSerializer(new JacksonLevelDBSerializer());`
+
+Jackson serializer has limitation towards binary content. If payload object contains binary data (does not concern payloads which are completely binary), Jackson serialization and deserialization won't work correctly.
+To avoid this, define your own jackson serializer/deserealizer via `Module` and provide it to the aggragation repository
+(you can use for example the constructor of `QuarkusLevelDBAggregationRepository`).
 
-The problem will be solved when the camel-leveldb component is refactored to use Jackson and custom
-serializers (see https://issues.apache.org/jira/browse/CAMEL-15679[issue])
 
diff --git a/extensions/leveldb/runtime/src/main/doc/limitations.adoc b/extensions/leveldb/runtime/src/main/doc/limitations.adoc
index e7ebff9..9b74c99 100644
--- a/extensions/leveldb/runtime/src/main/doc/limitations.adoc
+++ b/extensions/leveldb/runtime/src/main/doc/limitations.adoc
@@ -2,7 +2,13 @@ In native mode the extension uses a port of LevelDB written in Java (https://git
 which is within 10% of the performance of the C++ original. Please upvote https://github.com/apache/camel-quarkus/issues/1911[this issue]
 if you do not like the present state.
 
-This extension does not support binary payloads in native mode since object serialization is https://github.com/oracle/graal/issues/460[not supported] on GraalVM. To work around this limitation, the extension instead uses Jackson serializaton / deserialization.
+Serialization is https://github.com/oracle/graal/issues/460[not supported] on GraalVM. Extension has to use serializationization based
+on Jackson. Aggregation repository in native has to be constructed in one of the following ways:
+
+* Use class `QuarkusLevelDBAggregationRepository` instead of `LevelDBAggregationRepository`.
+* Configure jackson serializer on `LevelDBAggregationRepository` by calling `repo.setSerializer(new JacksonLevelDBSerializer());`
+
+Jackson serializer has limitation towards binary content. If payload object contains binary data (does not concern payloads which are completely binary), Jackson serialization and deserialization won't work correctly.
+To avoid this, define your own jackson serializer/deserealizer via `Module` and provide it to the aggragation repository
+(you can use for example the constructor of `QuarkusLevelDBAggregationRepository`).
 
-The problem will be solved when the camel-leveldb component is refactored to use Jackson and custom
-serializers (see https://issues.apache.org/jira/browse/CAMEL-15679[issue])
diff --git a/extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/ObjectCodecSubstitute.java b/extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/ObjectCodecSubstitute.java
deleted file mode 100644
index 8ab38a4..0000000
--- a/extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/ObjectCodecSubstitute.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.leveldb;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.oracle.svm.core.annotate.Inject;
-import com.oracle.svm.core.annotate.Substitute;
-import com.oracle.svm.core.annotate.TargetClass;
-import org.apache.camel.support.DefaultExchangeHolder;
-import org.fusesource.hawtbuf.codec.ObjectCodec;
-
-/**
- * This os workaround for serialization of DefaultExchangeHolder.
- * Once serialization is implemented in graalVM (see https://github.com/oracle/graal/issues/460), this substitution
- * could
- * be removed.
- */
-@TargetClass(value = ObjectCodec.class)
-final class ObjectCodecSubstitute {
-
-    @Inject
-    private ObjectMapper objectMapper;
-
-    @Substitute
-    public void encode(Object object, DataOutput dataOut) throws IOException {
-        if (objectMapper == null) {
-            objectMapper = new ObjectMapper();
-            objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
-            objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
-        }
-        objectMapper.writeValue(dataOut, object);
-    }
-
-    @Substitute
-    public Object decode(DataInput dataIn) throws IOException {
-        if (objectMapper == null) {
-            objectMapper = new ObjectMapper();
-            objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
-            objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
-        }
-        return objectMapper.readValue(dataIn, DefaultExchangeHolder.class);
-    }
-
-}
diff --git a/extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/QuarkusLevelDBAggregationRepository.java b/extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/QuarkusLevelDBAggregationRepository.java
new file mode 100644
index 0000000..7e930ec
--- /dev/null
+++ b/extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/QuarkusLevelDBAggregationRepository.java
@@ -0,0 +1,71 @@
+/*
+ * 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.leveldb;
+
+import com.fasterxml.jackson.databind.Module;
+import org.apache.camel.component.leveldb.LevelDBAggregationRepository;
+import org.apache.camel.component.leveldb.LevelDBFile;
+import org.apache.camel.component.leveldb.serializer.JacksonLevelDBSerializer;
+
+public class QuarkusLevelDBAggregationRepository extends LevelDBAggregationRepository {
+
+    public QuarkusLevelDBAggregationRepository() {
+        initSerializer(null);
+    }
+
+    public QuarkusLevelDBAggregationRepository(String repositoryName) {
+        super(repositoryName);
+        initSerializer(null);
+    }
+
+    public QuarkusLevelDBAggregationRepository(String repositoryName, String persistentFileName) {
+        super(repositoryName, persistentFileName);
+        initSerializer(null);
+    }
+
+    public QuarkusLevelDBAggregationRepository(String repositoryName, LevelDBFile levelDBFile) {
+        super(repositoryName, levelDBFile);
+        initSerializer(null);
+    }
+
+    //constructor with module
+
+    public QuarkusLevelDBAggregationRepository(Module module) {
+        JacksonLevelDBSerializer serializer = new JacksonLevelDBSerializer(module);
+        initSerializer(module);
+    }
+
+    public QuarkusLevelDBAggregationRepository(String repositoryName, Module module) {
+        super(repositoryName);
+        initSerializer(module);
+    }
+
+    public QuarkusLevelDBAggregationRepository(String repositoryName, String persistentFileName, Module module) {
+        super(repositoryName, persistentFileName);
+        initSerializer(module);
+    }
+
+    public QuarkusLevelDBAggregationRepository(String repositoryName, LevelDBFile levelDBFile, Module module) {
+        super(repositoryName, levelDBFile);
+        initSerializer(module);
+    }
+
+    private void initSerializer(Module module) {
+        JacksonLevelDBSerializer serializer = new JacksonLevelDBSerializer(module);
+        setSerializer(serializer);
+    }
+}
diff --git a/integration-tests/leveldb/src/main/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbRouteBuilder.java b/integration-tests/leveldb/src/main/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbRouteBuilder.java
index ed9674f..a5f7b8b 100644
--- a/integration-tests/leveldb/src/main/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbRouteBuilder.java
+++ b/integration-tests/leveldb/src/main/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbRouteBuilder.java
@@ -24,6 +24,7 @@ import org.apache.camel.AggregationStrategy;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.leveldb.LevelDBAggregationRepository;
+import org.apache.camel.quarkus.component.leveldb.QuarkusLevelDBAggregationRepository;
 
 public class LeveldbRouteBuilder extends RouteBuilder {
     public static final String DIRECT_START = "direct:start";
@@ -39,21 +40,22 @@ public class LeveldbRouteBuilder extends RouteBuilder {
 
     @Override
     public void configure() throws Exception {
-        LevelDBAggregationRepository repo = new LevelDBAggregationRepository("repo", DATA_FOLDER + "leveldb.dat");
+        LevelDBAggregationRepository repo = new QuarkusLevelDBAggregationRepository("repo", DATA_FOLDER + "leveldb.dat");
 
         from(DIRECT_START)
                 .aggregate(header("id"), new MyAggregationStrategy())
                 .completionSize(7).aggregationRepository(repo)
                 .to(MOCK_RESULT);
 
-        LevelDBAggregationRepository repoBinary = new LevelDBAggregationRepository("repo", DATA_FOLDER + "levelBinarydb.dat");
+        LevelDBAggregationRepository repoBinary = new QuarkusLevelDBAggregationRepository("repo",
+                DATA_FOLDER + "levelBinarydb.dat");
 
         from(DIRECT_BINARY)
                 .aggregate(header("id"), new BinaryAggregationStrategy())
                 .completionSize(3).aggregationRepository(repoBinary)
                 .to(MOCK_RESULT);
 
-        LevelDBAggregationRepository repoWithFailure = new LevelDBAggregationRepository("repoWithFailure",
+        LevelDBAggregationRepository repoWithFailure = new QuarkusLevelDBAggregationRepository("repoWithFailure",
                 DATA_FOLDER + "leveldbWithFailure.dat");
 
         repoWithFailure.setUseRecovery(true);
@@ -72,7 +74,7 @@ public class LeveldbRouteBuilder extends RouteBuilder {
                 .to(MOCK_RESULT)
                 .end();
 
-        LevelDBAggregationRepository repoDeadLetter = new LevelDBAggregationRepository("repoDeadLetter",
+        LevelDBAggregationRepository repoDeadLetter = new QuarkusLevelDBAggregationRepository("repoDeadLetter",
                 DATA_FOLDER + "leveldbDeadLetter.dat");
 
         repoDeadLetter.setUseRecovery(true);
diff --git a/integration-tests/leveldb/src/test/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbIT.java b/integration-tests/leveldb/src/test/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbIT.java
index e4fc4ba..743e2ab 100644
--- a/integration-tests/leveldb/src/test/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbIT.java
+++ b/integration-tests/leveldb/src/test/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbIT.java
@@ -20,8 +20,4 @@ import io.quarkus.test.junit.NativeImageTest;
 
 @NativeImageTest
 class LeveldbIT extends LeveldbTest {
-    @Override
-    boolean doeasBinaryDataWork() {
-        return false;
-    }
 }
diff --git a/integration-tests/leveldb/src/test/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbTest.java b/integration-tests/leveldb/src/test/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbTest.java
index 1ffa037..3d473b8 100644
--- a/integration-tests/leveldb/src/test/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbTest.java
+++ b/integration-tests/leveldb/src/test/java/org/apache/camel/quarkus/component/leveldb/it/LeveldbTest.java
@@ -101,19 +101,7 @@ class LeveldbTest {
                 .statusCode(201)
                 .extract().as(Boolean.class);
 
-        if (doeasBinaryDataWork()) {
-            assertTrue(theSame);
-        } else {
-            assertFalse(theSame);
-        }
-    }
-
-    /**
-     * Until binary payload is not supported, in native binary test will fail.
-     * Needs https://issues.apache.org/jira/browse/CAMEL-15679
-     */
-    boolean doeasBinaryDataWork() {
-        return true;
+        assertTrue(theSame);
     }
 
     private Map<String, List<Map<String, Object>>> testAggregate(String path, List<String> messages) {