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:
[email protected]