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/06/24 11:44:23 UTC

[GitHub] [camel] mmelko opened a new pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

mmelko opened a new pull request #3944:
URL: https://github.com/apache/camel/pull/3944


   refactor component to work with newer client
   remove options that were removed in newer clients
   add possibility to specify collection and scope for newer couchbase
   
   [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful subject line and body.
   [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
   Below are the contribution guidelines:
   https://github.com/apache/camel/blob/master/CONTRIBUTING.md


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



[GitHub] [camel] davsclaus commented on a change in pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #3944:
URL: https://github.com/apache/camel/pull/3944#discussion_r445366781



##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
##########
@@ -70,6 +71,12 @@
 
     @UriParam
     private String bucket;
+    //
+    @UriParam(defaultValue = "_default")
+    private String collection = DEFAULT_COLLECTION;

Review comment:
       See my prev comments about default

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java
##########
@@ -16,65 +16,76 @@
  */
 package org.apache.camel.component.couchbase;
 
-import com.couchbase.client.CouchbaseClient;
-import com.couchbase.client.protocol.views.Query;
-import com.couchbase.client.protocol.views.View;
-import com.couchbase.client.protocol.views.ViewResponse;
-import com.couchbase.client.protocol.views.ViewRow;
+import java.util.List;
+
+import com.couchbase.client.java.Bucket;
+import com.couchbase.client.java.Collection;
+import com.couchbase.client.java.Scope;
+import com.couchbase.client.java.view.ViewOptions;
+import com.couchbase.client.java.view.ViewOrdering;
+import com.couchbase.client.java.view.ViewResult;
+import com.couchbase.client.java.view.ViewRow;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.support.DefaultScheduledPollConsumer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_DESIGN_DOCUMENT_NAME;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_ID;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_KEY;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_VIEWNAME;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.*;
 
 public class CouchbaseConsumer extends DefaultScheduledPollConsumer {
 
     private static final Logger LOG = LoggerFactory.getLogger(CouchbaseConsumer.class);
 
     private final CouchbaseEndpoint endpoint;
-    private final CouchbaseClient client;
-    private final View view;
-    private final Query query;
-
-    public CouchbaseConsumer(CouchbaseEndpoint endpoint, CouchbaseClient client, Processor processor) {
+    private final Bucket bucket;
+    private ViewOptions viewOptions;
+    private Collection collection;
 
+    public CouchbaseConsumer(CouchbaseEndpoint endpoint, Bucket client, Processor processor) {
         super(endpoint, processor);
-        this.client = client;
+        this.bucket = client;
         this.endpoint = endpoint;
-        this.view = client.getView(endpoint.getDesignDocumentName(), endpoint.getViewName());
-        this.query = new Query();
+        Scope scope;
+        if (!endpoint.getScope().equals(DEFAULT_SCOPE)) {

Review comment:
       Instead of a default value that is _default. Then why not leave it as null/empty and then use that to know if a custom scope was set or not

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseProducer.java
##########
@@ -149,21 +151,20 @@ private Boolean setDocument(String id, int expiry, Object obj, PersistTo persist
 
     private Boolean setDocument(String id, int expiry, Object obj, int retryAttempts, PersistTo persistTo, ReplicateTo replicateTo) throws Exception {
 
-        OperationFuture<Boolean> result = client.set(id, expiry, obj, persistTo, replicateTo);
+        UpsertOptions options = UpsertOptions.upsertOptions()
+                .expiry(Duration.ofSeconds(expiry))
+                .durability(persistTo, replicateTo)
+                .timeout(Duration.ofMillis(retryAttempts * producerRetryPause))
+                .retryStrategy(BestEffortRetryStrategy.withExponentialBackoff(Duration.ofMillis(producerRetryPause), Duration.ofMillis(producerRetryPause), 1));
+
         try {
-            if (!result.get()) {
-                throw new Exception("Unable to save Document. " + id);
-            }
-            return true;
+            MutationResult result = collection.upsert(id, obj, options);
+            LOG.debug(result.toString());

Review comment:
       if isDebugEnabled

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
##########
@@ -70,6 +71,12 @@
 
     @UriParam
     private String bucket;
+    //

Review comment:
       Remove this

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java
##########
@@ -16,65 +16,76 @@
  */
 package org.apache.camel.component.couchbase;
 
-import com.couchbase.client.CouchbaseClient;
-import com.couchbase.client.protocol.views.Query;
-import com.couchbase.client.protocol.views.View;
-import com.couchbase.client.protocol.views.ViewResponse;
-import com.couchbase.client.protocol.views.ViewRow;
+import java.util.List;
+
+import com.couchbase.client.java.Bucket;
+import com.couchbase.client.java.Collection;
+import com.couchbase.client.java.Scope;
+import com.couchbase.client.java.view.ViewOptions;
+import com.couchbase.client.java.view.ViewOrdering;
+import com.couchbase.client.java.view.ViewResult;
+import com.couchbase.client.java.view.ViewRow;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.support.DefaultScheduledPollConsumer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_DESIGN_DOCUMENT_NAME;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_ID;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_KEY;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_VIEWNAME;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.*;
 
 public class CouchbaseConsumer extends DefaultScheduledPollConsumer {
 
     private static final Logger LOG = LoggerFactory.getLogger(CouchbaseConsumer.class);
 
     private final CouchbaseEndpoint endpoint;
-    private final CouchbaseClient client;
-    private final View view;
-    private final Query query;
-
-    public CouchbaseConsumer(CouchbaseEndpoint endpoint, CouchbaseClient client, Processor processor) {
+    private final Bucket bucket;
+    private ViewOptions viewOptions;
+    private Collection collection;
 
+    public CouchbaseConsumer(CouchbaseEndpoint endpoint, Bucket client, Processor processor) {
         super(endpoint, processor);
-        this.client = client;
+        this.bucket = client;
         this.endpoint = endpoint;
-        this.view = client.getView(endpoint.getDesignDocumentName(), endpoint.getViewName());
-        this.query = new Query();
+        Scope scope;
+        if (!endpoint.getScope().equals(DEFAULT_SCOPE)) {
+            scope = client.scope(endpoint.getScope());
+        } else {
+            scope = client.defaultScope();
+        }
+
+        if (!endpoint.getCollection().equals(DEFAULT_COLLECTION)) {

Review comment:
       The same as for default scope

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
##########
@@ -225,6 +219,28 @@ public void setPort(int port) {
         this.port = port;
     }
 
+    /**
+     * The collection to use
+     */
+    public String getCollection() {
+        return this.collection;
+    }
+
+    public void setCollection(String collection) {
+        this.collection = collection;
+    }
+
+    public String getScope() {
+        return this.scope;
+    }
+
+    /**
+     * The scope to use

Review comment:
       Do we know from couchbase what scopes is possible? If its like an enum then we can specify that via @UriParam so we have that information

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
##########
@@ -434,98 +450,21 @@ public void setConsumerProcessedStrategy(String consumerProcessedStrategy) {
         this.consumerProcessedStrategy = consumerProcessedStrategy;
     }
 
-    public long getOpTimeOut() {
-        return opTimeOut;
+    public long getQueryTimeout() {
+        return queryTimeout;
     }
 
     /**
      * Define the operation timeout

Review comment:
       in milli seconds

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseProducer.java
##########
@@ -149,21 +151,20 @@ private Boolean setDocument(String id, int expiry, Object obj, PersistTo persist
 
     private Boolean setDocument(String id, int expiry, Object obj, int retryAttempts, PersistTo persistTo, ReplicateTo replicateTo) throws Exception {
 
-        OperationFuture<Boolean> result = client.set(id, expiry, obj, persistTo, replicateTo);
+        UpsertOptions options = UpsertOptions.upsertOptions()
+                .expiry(Duration.ofSeconds(expiry))
+                .durability(persistTo, replicateTo)
+                .timeout(Duration.ofMillis(retryAttempts * producerRetryPause))
+                .retryStrategy(BestEffortRetryStrategy.withExponentialBackoff(Duration.ofMillis(producerRetryPause), Duration.ofMillis(producerRetryPause), 1));
+
         try {
-            if (!result.get()) {
-                throw new Exception("Unable to save Document. " + id);
-            }
-            return true;
+            MutationResult result = collection.upsert(id, obj, options);
+            LOG.debug(result.toString());
         } catch (Exception e) {
-            if (retryAttempts <= 0) {
-                throw e;
-            } else {
-                LOG.info("Unable to save Document, retrying in " + producerRetryPause + "ms (" + retryAttempts + ")");
-                Thread.sleep(producerRetryPause);
-                return setDocument(id, expiry, obj, retryAttempts - 1, persistTo, replicateTo);
-            }
+            LOG.error("Unable to save Document");

Review comment:
       Dont log and throw, just throw




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



[GitHub] [camel] davsclaus merged pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
davsclaus merged pull request #3944:
URL: https://github.com/apache/camel/pull/3944


   


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



[GitHub] [camel] davsclaus commented on pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #3944:
URL: https://github.com/apache/camel/pull/3944#issuecomment-648779980


   Looks like you started on this work before the 3.4.0 release and therefore its 3.4.0-SNAPSHOT and not updated to latest junit 5 migration etc.
   
   So do you mind rebasing of master so this is applied on top and therefore up to date.


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



[GitHub] [camel] omarsmak commented on a change in pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #3944:
URL: https://github.com/apache/camel/pull/3944#discussion_r444838616



##########
File path: components/camel-couchbase/pom.xml
##########
@@ -60,13 +60,13 @@
 
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-junit5</artifactId>

Review comment:
       Any reason why not using junit5? We have done a lot of effort on junit5 migration

##########
File path: components/camel-couchbase/pom.xml
##########
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.camel</groupId>
         <artifactId>components</artifactId>
-        <version>3.5.0-SNAPSHOT</version>
+        <version>3.4.0-SNAPSHOT</version>

Review comment:
       master is on `3.5.0-SNAPSHOT`, this should change

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseComponent.java
##########
@@ -1,44 +1,44 @@
-/*
- * 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.component.couchbase;
-
-import java.util.Map;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.spi.annotations.Component;
-import org.apache.camel.support.DefaultComponent;
-
-/**
- * Couchbase component.
- */
-@Component("couchbase")
-public class CouchbaseComponent extends DefaultComponent {
-
-    public CouchbaseComponent() {
-    }
-
-    public CouchbaseComponent(CamelContext context) {
-        super(context);
-    }
-
-    @Override
-    protected CouchbaseEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        CouchbaseEndpoint endpoint = new CouchbaseEndpoint(uri, remaining, this);
-        setProperties(endpoint, parameters);
-        return endpoint;
-    }
-}
+/*

Review comment:
       Formatting here is bit troublesome as it shows it big change meanwhile it is formatting

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
##########
@@ -37,21 +41,7 @@
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.support.ScheduledPollEndpoint;
 
-import static org.apache.camel.component.couchbase.CouchbaseConstants.COUCHBASE_PUT;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.COUCHBASE_URI_ERROR;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_CONSUME_PROCESSED_STRATEGY;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_COUCHBASE_PORT;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_DESIGN_DOCUMENT_NAME;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_MAX_RECONNECT_DELAY;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_OBS_POLL_INTERVAL;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_OBS_TIMEOUT;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_OP_QUEUE_MAX_BLOCK_TIME;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_OP_TIMEOUT;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_PAUSE_BETWEEN_RETRIES;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_PRODUCER_RETRIES;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_READ_BUFFER_SIZE;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_VIEWNAME;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.*;

Review comment:
       Please retain from loading all statics through the wildcard




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



[GitHub] [camel] davsclaus commented on a change in pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #3944:
URL: https://github.com/apache/camel/pull/3944#discussion_r445596259



##########
File path: components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseProducerTest.java
##########
@@ -58,16 +66,21 @@
     private Message msg;
 
     @Mock
-    private OperationFuture<?> response;
+    private MutationResult response;
+//    Observable<String> myStringObservable

Review comment:
       Need to remove this




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



[GitHub] [camel] mmelko commented on pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
mmelko commented on pull request #3944:
URL: https://github.com/apache/camel/pull/3944#issuecomment-648781424


   Thanks for the comments. Yeah it's true I started before 3.4.0 release. I'm already working on refactoring tests to use junit5..


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



[GitHub] [camel] davsclaus commented on a change in pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #3944:
URL: https://github.com/apache/camel/pull/3944#discussion_r445596420



##########
File path: components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseProducerTest.java
##########
@@ -107,111 +120,28 @@ public void testMaximumValuesForPersistToAndRepicateTo() throws Exception {
         producer = new CouchbaseProducer(endpoint, client, 4, 3);
     }
 
+    //

Review comment:
       Remove this




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



[GitHub] [camel] mmelko commented on a change in pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
mmelko commented on a change in pull request #3944:
URL: https://github.com/apache/camel/pull/3944#discussion_r445524750



##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseComponent.java
##########
@@ -1,44 +1,44 @@
-/*
- * 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.component.couchbase;
-
-import java.util.Map;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.spi.annotations.Component;
-import org.apache.camel.support.DefaultComponent;
-
-/**
- * Couchbase component.
- */
-@Component("couchbase")
-public class CouchbaseComponent extends DefaultComponent {
-
-    public CouchbaseComponent() {
-    }
-
-    public CouchbaseComponent(CamelContext context) {
-        super(context);
-    }
-
-    @Override
-    protected CouchbaseEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        CouchbaseEndpoint endpoint = new CouchbaseEndpoint(uri, remaining, this);
-        setProperties(endpoint, parameters);
-        return endpoint;
-    }
-}
+/*
+ * 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.component.couchbase;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+
+/**
+ * Couchbase component.
+ */
+@Component("couchbase")
+public class  CouchbaseComponent extends DefaultComponent {

Review comment:
       Thanks for comments. I'm running it with `sourcecheck` profile. I will recheck my IDE settings. 




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



[GitHub] [camel] mmelko commented on a change in pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
mmelko commented on a change in pull request #3944:
URL: https://github.com/apache/camel/pull/3944#discussion_r445527319



##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java
##########
@@ -16,65 +16,76 @@
  */
 package org.apache.camel.component.couchbase;
 
-import com.couchbase.client.CouchbaseClient;
-import com.couchbase.client.protocol.views.Query;
-import com.couchbase.client.protocol.views.View;
-import com.couchbase.client.protocol.views.ViewResponse;
-import com.couchbase.client.protocol.views.ViewRow;
+import java.util.List;
+
+import com.couchbase.client.java.Bucket;
+import com.couchbase.client.java.Collection;
+import com.couchbase.client.java.Scope;
+import com.couchbase.client.java.view.ViewOptions;
+import com.couchbase.client.java.view.ViewOrdering;
+import com.couchbase.client.java.view.ViewResult;
+import com.couchbase.client.java.view.ViewRow;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.support.DefaultScheduledPollConsumer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_DESIGN_DOCUMENT_NAME;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_ID;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_KEY;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_VIEWNAME;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.*;
 
 public class CouchbaseConsumer extends DefaultScheduledPollConsumer {
 
     private static final Logger LOG = LoggerFactory.getLogger(CouchbaseConsumer.class);
 
     private final CouchbaseEndpoint endpoint;
-    private final CouchbaseClient client;
-    private final View view;
-    private final Query query;
-
-    public CouchbaseConsumer(CouchbaseEndpoint endpoint, CouchbaseClient client, Processor processor) {
+    private final Bucket bucket;
+    private ViewOptions viewOptions;
+    private Collection collection;
 
+    public CouchbaseConsumer(CouchbaseEndpoint endpoint, Bucket client, Processor processor) {
         super(endpoint, processor);
-        this.client = client;
+        this.bucket = client;
         this.endpoint = endpoint;
-        this.view = client.getView(endpoint.getDesignDocumentName(), endpoint.getViewName());
-        this.query = new Query();
+        Scope scope;
+        if (!endpoint.getScope().equals(DEFAULT_SCOPE)) {

Review comment:
       yeah, that's a valid point. Will do. 




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



[GitHub] [camel] mmelko commented on a change in pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
mmelko commented on a change in pull request #3944:
URL: https://github.com/apache/camel/pull/3944#discussion_r445526964



##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
##########
@@ -225,6 +219,28 @@ public void setPort(int port) {
         this.port = port;
     }
 
+    /**
+     * The collection to use
+     */
+    public String getCollection() {
+        return this.collection;
+    }
+
+    public void setCollection(String collection) {
+        this.collection = collection;
+    }
+
+    public String getScope() {
+        return this.scope;
+    }
+
+    /**
+     * The scope to use

Review comment:
       I believe you can create custom scopes with custom name .. so it's definitely not a enum.




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



[GitHub] [camel] oscerd commented on pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
oscerd commented on pull request #3944:
URL: https://github.com/apache/camel/pull/3944#issuecomment-649238558


   We need to have a look to the karaf feature too


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



[GitHub] [camel] omarsmak commented on a change in pull request #3944: CAMEL-14319: upgrade couchbase java client to 3.0.5

Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #3944:
URL: https://github.com/apache/camel/pull/3944#discussion_r445379645



##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConstants.java
##########
@@ -28,6 +28,8 @@
     String COUCHBASE_DELETE = "CCB_DEL";
     String DEFAULT_DESIGN_DOCUMENT_NAME = "beer";
     String DEFAULT_VIEWNAME = "brewery_beers";
+    String  DEFAULT_COLLECTION = "_default";

Review comment:
       here as well

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseComponent.java
##########
@@ -1,44 +1,44 @@
-/*
- * 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.component.couchbase;
-
-import java.util.Map;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.spi.annotations.Component;
-import org.apache.camel.support.DefaultComponent;
-
-/**
- * Couchbase component.
- */
-@Component("couchbase")
-public class CouchbaseComponent extends DefaultComponent {
-
-    public CouchbaseComponent() {
-    }
-
-    public CouchbaseComponent(CamelContext context) {
-        super(context);
-    }
-
-    @Override
-    protected CouchbaseEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        CouchbaseEndpoint endpoint = new CouchbaseEndpoint(uri, remaining, this);
-        setProperties(endpoint, parameters);
-        return endpoint;
-    }
-}
+/*
+ * 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.component.couchbase;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+
+/**
+ * Couchbase component.
+ */
+@Component("couchbase")
+public class  CouchbaseComponent extends DefaultComponent {

Review comment:
       Formatting issues. Can you please take a look at your IDE settings perhaps?

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java
##########
@@ -16,65 +16,76 @@
  */
 package org.apache.camel.component.couchbase;
 
-import com.couchbase.client.CouchbaseClient;
-import com.couchbase.client.protocol.views.Query;
-import com.couchbase.client.protocol.views.View;
-import com.couchbase.client.protocol.views.ViewResponse;
-import com.couchbase.client.protocol.views.ViewRow;
+import java.util.List;
+
+import com.couchbase.client.java.Bucket;
+import com.couchbase.client.java.Collection;
+import com.couchbase.client.java.Scope;
+import com.couchbase.client.java.view.ViewOptions;
+import com.couchbase.client.java.view.ViewOrdering;
+import com.couchbase.client.java.view.ViewResult;
+import com.couchbase.client.java.view.ViewRow;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.support.DefaultScheduledPollConsumer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_DESIGN_DOCUMENT_NAME;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_ID;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_KEY;
-import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_VIEWNAME;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.*;

Review comment:
       wildcard import. Please avoid it

##########
File path: components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
##########
@@ -554,37 +493,32 @@ public void setObsTimeout(long obsTimeout) {
         return uriArray;
     }
 
-    private CouchbaseClient createClient() throws IOException, URISyntaxException {
+    //create from couchbase-client
+    private Bucket createClient() throws IOException, URISyntaxException {
         List<URI> hosts = Arrays.asList(makeBootstrapURI());
+        String connectionString;
 
-        CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
-
-        if (opTimeOut != DEFAULT_OP_TIMEOUT) {
-            cfb.setOpTimeout(opTimeOut);
+        ClusterEnvironment.Builder cfb = ClusterEnvironment.builder();
+        if (queryTimeout != DEFAULT_QUERY_TIMEOUT) {
+            cfb.timeoutConfig().queryTimeout(Duration.ofMillis(queryTimeout));
         }
-        if (timeoutExceptionThreshold != DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD) {
-            cfb.setTimeoutExceptionThreshold(timeoutExceptionThreshold);
-        }
-        if (readBufferSize != DEFAULT_READ_BUFFER_SIZE) {
-            cfb.setReadBufferSize(readBufferSize);
-        }
-        if (shouldOptimize) {
-            cfb.setShouldOptimize(true);
-        }
-        if (maxReconnectDelay != DEFAULT_MAX_RECONNECT_DELAY) {
-            cfb.setMaxReconnectDelay(maxReconnectDelay);
-        }
-        if (opQueueMaxBlockTime != DEFAULT_OP_QUEUE_MAX_BLOCK_TIME) {
-            cfb.setOpQueueMaxBlockTime(opQueueMaxBlockTime);
-        }
-        if (obsPollInterval != DEFAULT_OBS_POLL_INTERVAL) {
-            cfb.setObsPollInterval(obsPollInterval);
-        }
-        if (obsTimeout != DEFAULT_OBS_TIMEOUT) {
-            cfb.setObsTimeout(obsTimeout);
+
+        ClusterEnvironment env = cfb.build();
+
+        String addHosts = hosts.stream()
+                .map(URI::getHost)
+                .collect(Collectors.joining(","));
+
+        if (!"".equals(addHosts)) {

Review comment:
       This meant to check if is an empty string, isn't? Then wouldn't be better something like: 
   `if(!addHosts.isEmpty())`




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