You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/06/17 15:16:44 UTC
[1/3] git commit: Fix for CAMEL-7516 Expose the component options for
Camel HDFS
Repository: camel
Updated Branches:
refs/heads/master 7c825d12e -> 79729b10f
Fix for CAMEL-7516 Expose the component options for Camel HDFS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6a47e9bd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6a47e9bd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6a47e9bd
Branch: refs/heads/master
Commit: 6a47e9bd5ed1dfa0c47a42b3d5d1ef916c6262d8
Parents: 7c825d1
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Tue Jun 17 14:30:41 2014 +0200
Committer: Kevin Earls <ke...@kevinearls.com>
Committed: Tue Jun 17 14:30:41 2014 +0200
----------------------------------------------------------------------
.../camel/component/hdfs/HdfsComponent.java | 7 ++-
.../camel/component/hdfs/HdfsConfiguration.java | 27 +++++++++
.../camel/component/hdfs/HdfsEndpoint.java | 4 ++
...ponentConfigurationAndDocumentationTest.java | 58 ++++++++++++++++++++
4 files changed, 93 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6a47e9bd/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
index 1920e1c..22aab6e 100644
--- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
+++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
@@ -22,21 +22,22 @@ import javax.security.auth.login.Configuration;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class HdfsComponent extends DefaultComponent {
+public class HdfsComponent extends UriEndpointComponent {
private static final Logger LOG = LoggerFactory.getLogger(HdfsComponent.class);
public HdfsComponent() {
+ super(HdfsEndpoint.class);
initHdfs();
}
public HdfsComponent(CamelContext context) {
- super(context);
+ super(context, HdfsEndpoint.class);
initHdfs();
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6a47e9bd/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
index 13a1a06..3c87468 100644
--- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
+++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
@@ -22,36 +22,63 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
import org.apache.camel.util.URISupport;
import org.apache.hadoop.io.SequenceFile;
+@UriParams
public class HdfsConfiguration {
private URI uri;
+ @UriParam
private String hostName;
+ @UriParam
private int port = HdfsConstants.DEFAULT_PORT;
+ @UriParam
private String path;
+ @UriParam
private boolean overwrite = true;
+ @UriParam
private boolean append;
+ @UriParam
private boolean wantAppend;
+ @UriParam
private int bufferSize = HdfsConstants.DEFAULT_BUFFERSIZE;
+ @UriParam
private short replication = HdfsConstants.DEFAULT_REPLICATION;
+ @UriParam
private long blockSize = HdfsConstants.DEFAULT_BLOCKSIZE;
+ @UriParam
private SequenceFile.CompressionType compressionType = HdfsConstants.DEFAULT_COMPRESSIONTYPE;
+ @UriParam
private HdfsCompressionCodec compressionCodec = HdfsConstants.DEFAULT_CODEC;
+ @UriParam
private HdfsFileType fileType = HdfsFileType.NORMAL_FILE;
+ @UriParam
private HdfsFileSystemType fileSystemType = HdfsFileSystemType.HDFS;
+ @UriParam
private HdfsWritableFactories.WritableType keyType = HdfsWritableFactories.WritableType.NULL;
+ @UriParam
private HdfsWritableFactories.WritableType valueType = HdfsWritableFactories.WritableType.BYTES;
+ @UriParam
private String openedSuffix = HdfsConstants.DEFAULT_OPENED_SUFFIX;
+ @UriParam
private String readSuffix = HdfsConstants.DEFAULT_READ_SUFFIX;
+ @UriParam
private long initialDelay;
+ @UriParam
private long delay = HdfsConstants.DEFAULT_DELAY;
+ @UriParam
private String pattern = HdfsConstants.DEFAULT_PATTERN;
+ @UriParam
private int chunkSize = HdfsConstants.DEFAULT_BUFFERSIZE;
+ @UriParam
private int checkIdleInterval = HdfsConstants.DEFAULT_CHECK_IDLE_INTERVAL;
private List<HdfsProducer.SplitStrategy> splitStrategies;
+ @UriParam
private boolean connectOnStartup = true;
+ @UriParam
private String owner;
public HdfsConfiguration() {
http://git-wip-us.apache.org/repos/asf/camel/blob/6a47e9bd/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsEndpoint.java b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsEndpoint.java
index 52f199f..b20ffd0 100644
--- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsEndpoint.java
+++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsEndpoint.java
@@ -24,9 +24,13 @@ import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+@UriEndpoint(scheme = "hdfs", consumerClass = HdfsConsumer.class)
public class HdfsEndpoint extends DefaultEndpoint {
+ @UriParam
private final HdfsConfiguration config;
@SuppressWarnings("deprecation")
http://git-wip-us.apache.org/repos/asf/camel/blob/6a47e9bd/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsComponentConfigurationAndDocumentationTest.java b/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..e25e7aa
--- /dev/null
+++ b/components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsComponentConfigurationAndDocumentationTest.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.camel.component.hdfs;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HdfsComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testComponentConfiguration() throws Exception {
+ HdfsComponent comp = context.getComponent("hdfs", HdfsComponent.class);
+ EndpointConfiguration conf = comp.createConfiguration("hdfs://localhost/tmp/simple-file?" +
+ "fileSystemType=LOCAL&fileType=SEQUENCE_FILE&initialDelay=0");
+
+ assertEquals("LOCAL", conf.getParameter("fileSystemType"));
+ assertEquals("SEQUENCE_FILE", conf.getParameter("fileType"));
+ assertEquals("0", conf.getParameter("initialDelay"));
+
+ ComponentConfiguration compConf = comp.createComponentConfiguration();
+ String json = compConf.createParameterJsonSchema();
+ assertNotNull(json);
+
+ assertTrue(json.contains("\"pattern\": { \"type\": \"java.lang.String\" }"));
+ assertTrue(json.contains("\"wantAppend\": { \"type\": \"boolean\" }"));
+ }
+
+ @Test
+ public void testComponentDocumentation() throws Exception {
+ CamelContext context = new DefaultCamelContext();
+ String html = context.getComponentDocumentation("hdfs");
+ assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+ }
+
+}
[3/3] git commit: Merge branch 'CAMEL-7517' of
https://github.com/kevinearls/camel
Posted by da...@apache.org.
Merge branch 'CAMEL-7517' of https://github.com/kevinearls/camel
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/79729b10
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/79729b10
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/79729b10
Branch: refs/heads/master
Commit: 79729b10fa295d9deab6ee5609b02ac01b3be16c
Parents: 6a47e9b 8579307
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jun 17 15:16:23 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jun 17 15:16:23 2014 +0200
----------------------------------------------------------------------
.../camel/component/hdfs2/HdfsComponent.java | 7 ++-
.../component/hdfs2/HdfsConfiguration.java | 27 +++++++++
.../camel/component/hdfs2/HdfsEndpoint.java | 4 ++
...ponentConfigurationAndDocumentationTest.java | 58 ++++++++++++++++++++
4 files changed, 93 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
[2/3] git commit: Fix for CAMEL-7517 Expose the component options for
Camel HDFS2
Posted by da...@apache.org.
Fix for CAMEL-7517 Expose the component options for Camel HDFS2
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8579307e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8579307e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8579307e
Branch: refs/heads/master
Commit: 8579307e1592c695aa9c0229104eb67d9ead4394
Parents: 7c825d1
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Tue Jun 17 14:52:39 2014 +0200
Committer: Kevin Earls <ke...@kevinearls.com>
Committed: Tue Jun 17 14:52:39 2014 +0200
----------------------------------------------------------------------
.../camel/component/hdfs2/HdfsComponent.java | 7 ++-
.../component/hdfs2/HdfsConfiguration.java | 27 +++++++++
.../camel/component/hdfs2/HdfsEndpoint.java | 4 ++
...ponentConfigurationAndDocumentationTest.java | 58 ++++++++++++++++++++
4 files changed, 93 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8579307e/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsComponent.java b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsComponent.java
index 52a8888..1b05c35 100644
--- a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsComponent.java
+++ b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsComponent.java
@@ -22,21 +22,22 @@ import javax.security.auth.login.Configuration;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class HdfsComponent extends DefaultComponent {
+public class HdfsComponent extends UriEndpointComponent {
private static final Logger LOG = LoggerFactory.getLogger(HdfsComponent.class);
public HdfsComponent() {
+ super(HdfsEndpoint.class);
initHdfs();
}
public HdfsComponent(CamelContext context) {
- super(context);
+ super(context, HdfsEndpoint.class);
initHdfs();
}
http://git-wip-us.apache.org/repos/asf/camel/blob/8579307e/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
index cdb8531..6110059 100644
--- a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
+++ b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
@@ -22,36 +22,63 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
import org.apache.camel.util.URISupport;
import org.apache.hadoop.io.SequenceFile;
+@UriParams
public class HdfsConfiguration {
private URI uri;
+ @UriParam
private String hostName;
+ @UriParam
private int port = HdfsConstants.DEFAULT_PORT;
+ @UriParam
private String path;
+ @UriParam
private boolean overwrite = true;
+ @UriParam
private boolean append;
+ @UriParam
private boolean wantAppend;
+ @UriParam
private int bufferSize = HdfsConstants.DEFAULT_BUFFERSIZE;
+ @UriParam
private short replication = HdfsConstants.DEFAULT_REPLICATION;
+ @UriParam
private long blockSize = HdfsConstants.DEFAULT_BLOCKSIZE;
+ @UriParam
private SequenceFile.CompressionType compressionType = HdfsConstants.DEFAULT_COMPRESSIONTYPE;
+ @UriParam
private HdfsCompressionCodec compressionCodec = HdfsConstants.DEFAULT_CODEC;
+ @UriParam
private HdfsFileType fileType = HdfsFileType.NORMAL_FILE;
+ @UriParam
private HdfsFileSystemType fileSystemType = HdfsFileSystemType.HDFS;
+ @UriParam
private HdfsWritableFactories.WritableType keyType = HdfsWritableFactories.WritableType.NULL;
+ @UriParam
private HdfsWritableFactories.WritableType valueType = HdfsWritableFactories.WritableType.BYTES;
+ @UriParam
private String openedSuffix = HdfsConstants.DEFAULT_OPENED_SUFFIX;
+ @UriParam
private String readSuffix = HdfsConstants.DEFAULT_READ_SUFFIX;
+ @UriParam
private long initialDelay;
+ @UriParam
private long delay = HdfsConstants.DEFAULT_DELAY;
+ @UriParam
private String pattern = HdfsConstants.DEFAULT_PATTERN;
+ @UriParam
private int chunkSize = HdfsConstants.DEFAULT_BUFFERSIZE;
+ @UriParam
private int checkIdleInterval = HdfsConstants.DEFAULT_CHECK_IDLE_INTERVAL;
private List<HdfsProducer.SplitStrategy> splitStrategies;
+ @UriParam
private boolean connectOnStartup = true;
+ @UriParam
private String owner;
public HdfsConfiguration() {
http://git-wip-us.apache.org/repos/asf/camel/blob/8579307e/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsEndpoint.java b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsEndpoint.java
index 87a3ac8..2f3cf55 100644
--- a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsEndpoint.java
+++ b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsEndpoint.java
@@ -24,9 +24,13 @@ import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+@UriEndpoint(scheme = "hdfs2", consumerClass = HdfsConsumer.class)
public class HdfsEndpoint extends DefaultEndpoint {
+ @UriParam
private final HdfsConfiguration config;
@SuppressWarnings("deprecation")
http://git-wip-us.apache.org/repos/asf/camel/blob/8579307e/components/camel-hdfs2/src/test/java/org/apache/camel/component/hdfs2/HdfsComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs2/src/test/java/org/apache/camel/component/hdfs2/HdfsComponentConfigurationAndDocumentationTest.java b/components/camel-hdfs2/src/test/java/org/apache/camel/component/hdfs2/HdfsComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..bfa7e3d
--- /dev/null
+++ b/components/camel-hdfs2/src/test/java/org/apache/camel/component/hdfs2/HdfsComponentConfigurationAndDocumentationTest.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.camel.component.hdfs2;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HdfsComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testComponentConfiguration() throws Exception {
+ HdfsComponent comp = context.getComponent("hdfs2", HdfsComponent.class);
+ EndpointConfiguration conf = comp.createConfiguration("hdfs2://localhost/tmp/simple-file?" +
+ "splitStrategy=IDLE:1000,BYTES:5&fileSystemType=LOCAL&fileType=ARRAY_FILE&initialDelay=0");
+
+ assertEquals("LOCAL", conf.getParameter("fileSystemType"));
+ assertEquals("ARRAY_FILE", conf.getParameter("fileType"));
+ assertEquals("0", conf.getParameter("initialDelay"));
+
+ ComponentConfiguration compConf = comp.createComponentConfiguration();
+ String json = compConf.createParameterJsonSchema();
+ assertNotNull(json);
+
+ assertTrue(json.contains("\"initialDelay\": { \"type\": \"long\" }"));
+ assertTrue(json.contains("\"checkIdleInterval\": { \"type\": \"int\" }"));
+ }
+
+ @Test
+ public void testComponentDocumentation() throws Exception {
+ CamelContext context = new DefaultCamelContext();
+ String html = context.getComponentDocumentation("hdfs2");
+ assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+ }
+
+}