camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] git commit: Fix for CAMEL-7516 Expose the component options for Camel HDFS
Date Tue, 17 Jun 2014 13:16:44 GMT
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 <kevin@kevinearls.com>
Authored: Tue Jun 17 14:30:41 2014 +0200
Committer: Kevin Earls <kevin@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);
+    }
+
+}


Mime
View raw message