[GitHub] [camel] davsclaus commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

2020-04-20 Thread GitBox


davsclaus commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411867389



##
File path: 
components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
##
@@ -0,0 +1,117 @@
+/*
+ * 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.splunkhec;
+
+import java.net.UnknownHostException;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.util.HostUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@UriParams
+public class SplunkHECConfiguration {
+private static final transient Logger LOG = 
LoggerFactory.getLogger(SplunkHECConfiguration.class);
+
+@UriParam(label = "producer")
+private String index = "camel";
+@UriParam(label = "producer")
+private String sourceType = "camel";
+@UriParam(label = "producer")
+private String source = "camel";
+@UriParam(label = "producer")
+private String host;
+@UriParam(label = "producer")
+private boolean skipTlsVerify;
+@UriParam(label = "producer")

Review comment:
   You need to specify default value in @UriParam when it has a value, also 
for the ones that has camel above.

##
File path: 
components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECEndpoint.java
##
@@ -0,0 +1,103 @@
+/*
+ * 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.splunkhec;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The splunk component allows to publish events in Splunk using the HTTP 
Event Collector.
+ */
+@UriEndpoint(firstVersion = "3.3.0", scheme = "splunk-hec", title = "Splunk 
HEC", syntax = "splunk-hec:endpoint/token", label = "log,monitoring")
+public class SplunkHECEndpoint extends DefaultEndpoint {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(SplunkHECEndpoint.class);
+private static final Pattern URI_PARSER = 
Pattern.compile("splunk-hec\\:\\/?\\/?(\\w+):(\\d+)/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})\\??.*");
+
+@UriPath

Review comment:
   @UriPath must match the syntax `splunk-hec:endpoint/token`, eg having 2 
UriPath named `endpoint` and `token`. Otherwise change the syntax to 
`splunk-hec:endpointUri` to match the current @UriParam name.





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:
us...@infra.apache.org




[GitHub] [camel] atoulme commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

2020-04-20 Thread GitBox


atoulme commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411539438



##
File path: core/camel-componentdsl/src/generated/resources/metadata.json
##
@@ -6612,6 +6612,28 @@
 "producerOnly": false,
 "lenientProperties": false
   },
+  "SplunkHecComponentBuilderFactory": {
+"kind": "component",
+"name": "splunk-hec",
+"title": "Splunk HEC",
+"description": "The splunk component allows to publish events in Splunk 
using the HTTP Event Collector.",
+"deprecated": false,
+"deprecationNote": "log,monitoring",
+"firstVersion": "3.2.0",

Review comment:
   Fixed.





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:
us...@infra.apache.org




[GitHub] [camel] atoulme commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

2020-04-20 Thread GitBox


atoulme commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411539558



##
File path: 
components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
##
@@ -0,0 +1,117 @@
+/*
+ * 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.splunkhec;
+
+import java.net.UnknownHostException;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.util.HostUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@UriParams
+public class SplunkHECConfiguration {
+private static final transient Logger LOG = 
LoggerFactory.getLogger(SplunkHECConfiguration.class);
+
+@UriParam(label = "producer")
+private String index = "camel";
+@UriParam(label = "producer")
+private String sourceType = "camel";
+@UriParam(label = "producer")
+private String source = "camel";
+@UriParam(label = "host")
+private String host;
+@UriParam(label = "skiptlsverify")
+private boolean skiptlsverify;

Review comment:
   Sure thing. Fixed!





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:
us...@infra.apache.org




[GitHub] [camel] atoulme commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

2020-04-20 Thread GitBox


atoulme commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411537053



##
File path: 
components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
##
@@ -0,0 +1,122 @@
+/*
+ * 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.splunkhec;
+
+
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.EntityTemplate;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContextBuilder;
+
+/**
+ * The Splunk HEC producer.
+ */
+public class SplunkHECProducer extends DefaultProducer {
+private static final ObjectMapper MAPPER = new ObjectMapper();
+private SplunkHECEndpoint endpoint;
+private CloseableHttpClient httpClient;
+
+
+public SplunkHECProducer(SplunkHECEndpoint endpoint) {
+super(endpoint);
+this.endpoint = endpoint;
+}
+
+@Override
+protected void doStart() throws Exception {
+super.doStart();
+HttpClientBuilder builder = HttpClients.custom().
+setUserAgent("Camel Splunk HEC/" + 
getEndpoint().getCamelContext().getVersion()).
+setMaxConnTotal(10);
+if (endpoint.getConfiguration().isSkiptlsverify()) {
+SSLContextBuilder sslbuilder = new SSLContextBuilder();
+sslbuilder.loadTrustMaterial(null, (chain, authType) -> true);
+SSLConnectionSocketFactory sslsf = new
+SSLConnectionSocketFactory(sslbuilder.build(), 
NoopHostnameVerifier.INSTANCE);
+builder.setSSLSocketFactory(sslsf);
+}
+httpClient = builder.build();
+}
+
+@Override
+public void process(Exchange exchange) throws Exception {
+Map payload = createPayload(exchange.getIn());
+
+HttpPost httppost = new 
HttpPost((endpoint.getConfiguration().isHttps() ? "https" : "http") + "://" + 
endpoint.getSplunkURL() + "/services/collector/event");
+httppost.addHeader("Authorization", " Splunk " + endpoint.getToken());
+
+EntityTemplate entityTemplate = new EntityTemplate(outputStream -> 
MAPPER.writer().writeValue(outputStream, payload));
+
entityTemplate.setContentType(ContentType.APPLICATION_JSON.getMimeType());
+
+httppost.setEntity(entityTemplate);
+try (CloseableHttpResponse response = httpClient.execute(httppost)) {
+if (response.getStatusLine().getStatusCode() != 200) {
+ByteArrayOutputStream output = new ByteArrayOutputStream();
+response.getEntity().writeTo(output);
+
+throw new RuntimeException(response.getStatusLine().toString() 
+ "\n" + new String(output.toByteArray(), StandardCharsets.UTF_8));
+}
+}
+}
+
+@Override
+protected void doStop() throws Exception {
+super.doStop();
+httpClient.close();

Review comment:
   I'm seeing file and seda behave differently there. I think 
`super.doStop()` should be first so it logs the stop operation. If the client 
throws an exception, at least you get the log before.





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:
us...@infra.apache.org




Re: Ideas how to improve Component, Language, Data format, etc. descriptions in Camel Catalog

2020-04-20 Thread Peter Palaga
I have filed https://issues.apache.org/jira/browse/CAMEL-14934 and I am 
starting to work on it. -- P


On 16/04/2020 17:07, Claus Ibsen wrote:

Hi

I have started a thread on making it easier to maintain all this
information in a few single files for all components.
Which could make it faster and easier to update all of this in one place.

See
https://camel.465427.n5.nabble.com/Maintaining-information-for-camel-catalog-in-an-easier-way-for-the-huge-number-of-components-we-have-tp5864516.html

On Thu, Apr 9, 2020 at 9:40 AM Claus Ibsen  wrote:


Hi

Yes I would like to make those short component descriptions better,
especially the ones that just say

Camel support for Foo

I like the idea of making the description focus on the main
functionality and keep it short.
Yes we can sometime leave out the project name as its in the title anyway.

Currently all the titles are in the class javadoc mainly, and for
others in the pom.xml description.
So its a bit of "hunt" to find and update them, but surely go for it.



On Mon, Apr 6, 2020 at 3:54 PM Peter Palaga  wrote:


Hi,

The descriptions of components, languages, data formats, etc. in Camel
catalog currently use several inconsistent styles. I wonder whether we
could agree on some common style?

Here an attempt to describe the current state by roughly classifying the
styles and giving some examples. A common style proposal is below.

= "Copy the title" style:

* A Camel GraphQL Component
* Camel Cron Component


= "What it does" style:

* Bridging Eclipse MicroProfile Health with Camel health checks
* Camel metrics exposed with Eclipse MicroProfile Metrics
* Communicates with OData 4.0 services using Apache Olingo OData API.


= "Component for " style

* Component for communicating with MQTT message brokers using Eclipse
Paho MQTT Client.
* Component for working with documents stored in MongoDB database.


= "For " style

* For calling out to external HTTP servers using Apache HTTP Client 4.x.
* For reading/writing from/to Infinispan distributed key/value store and
data grid.
* For uploading downloading and managing files folders groups
collaborations etc on box DOT com.


= "  is used for " style

* JacksonXML data format is used for unmarshal a XML payload to POJO or
to marshal POJO back to XML payload.
* JSon data format is used for unmarshal a JSon payload to POJO or to
marshal POJO back to JSon payload.


= " using "

* Camel WebSocket using JSR356 (javax)
* Circuit Breaker EIP using Netflix Hystrix
* Distributed tracing using OpenTracing


I think the following basic principles might be useful when trying to
come up with a common style:

(i) Shorter is better. Less/shorter words are faster to read and faster
to understand
(ii) An application of (i): Leave out words and information available
elsewhere in the Catalog record. Esp. do not repeat the title and kind
(component, language, ...) because they are clear from the context. The
same holds for the word "Camel".
(iii) Concentrate on functionality (what it does), because that's what
most users want to know.

"What it does" style seems to be the best match. From the several
flavors, I think the shortest with the plain (imperative) form of the
verb should be prefered - e.g.

new: Unmarshal an XML payload to POJO or marshal a POJO back to XML.

old: JacksonXML data format is used for unmarshal a XML payload to POJO
or to marshal POJO back to XML payload.

The same information, but 6 (~1/3) words less.

WDYT?

Disclaimer: my motivation for this proposal is driven by the fact that
I'd like to re-use the catalog data when scaffolding new Camel Quarkus
extensions, esp. generating pieces of Camel Quarkus documentation and
for generating extension metadata for code.quarkus.io

Thanks,

-- Peter




--
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2








Re: Merge Commits?

2020-04-20 Thread Zoran Regvart
Hi Cameleers,
I recently became aware of the `.asf.yaml` file that we can use to
tweak these settings, so in case someone else also missed it here is
the documentation:

https://cwiki.apache.org/confluence/display/INFRA/.asf.yaml+features+for+git+repositories

zoran

On Fri, Apr 17, 2020 at 11:36 AM Andrea Cosentino
 wrote:
>
> https://issues.apache.org/jira/browse/INFRA-20137
>
> --
> Andrea Cosentino
> --
> Apache Camel PMC Chair
> Apache Karaf Committer
> Apache Servicemix PMC Member
> Email: ancosen1...@yahoo.com
> Twitter: @oscerd2
> Github: oscerd
>
>
>
>
>
>
> On Thursday, April 16, 2020, 06:07:18 PM GMT+2, David Jencks 
>  wrote:
>
>
>
>
>
> Thanks!
> David Jencks
>
> > On Apr 16, 2020, at 8:56 AM, Andrea Cosentino  wrote:
> >
> > This is something only INFRA could setup.
> >
> > I think it's not something critical, I'll raise an issue to INFRA anyway.
> >
> > Il giorno gio 16 apr 2020 alle ore 17:54 David Jencks <
> > david.a.jen...@gmail.com> ha scritto:
> >
> >> Lets not let this drop on the floor and get forgotten…
> >>
> >> The instructions for enabling and requiring rebase-and-merge for PRs are
> >> here:
> >> https://help.github.com/en/github/administering-a-repository/configuring-commit-rebasing-for-pull-requests
> >>
> >> I don’t appear to have the permissions to set this up…. who does?
> >>
> >> Does anyone know if there are equivalent options/settings for the apache
> >> git repo?
> >>
> >> Thanks
> >> David Jencks
> >>
> >>> On Apr 15, 2020, at 10:22 PM, David Jencks 
> >> wrote:
> >>>
> >>> Hi Claus,
> >>>
> >>> I think that sometimes more than one commit is appropriate for a PR.
> >> For instance some of mine recently have consisted of a few lines change of
> >> generation code and hundreds of files changed as a result.  It’s much
> >> clearer if those are two separate commits.  Also, my impression is that the
> >> project settings have the GitHub button be just “merge” without squash.
> >>>
> >>> I’ve been waiting for review of my PRs which means it’s extremely likely
> >> that master will have progressed since my push.  So I think the project
> >> rebase and push setting will be a real help.
> >>>
> >>> Thanks
> >>> David Jencks
> >>>
>  On Apr 15, 2020, at 10:00 PM, Claus Ibsen 
> >> wrote:
> 
>  Hi
> 
>  Yes we should do rebase and merge, or squash and merge style, so its
> >> linear.
>  On github the green button is default for "squash and merge".
> 
>  I always do git pull --rebase from CLI before pushing, so my commits
>  are added on top of the branch.
> 
> 
> 
>  On Wed, Apr 15, 2020 at 10:09 PM Pascal Schumacher
>   wrote:
> >
> > Hi,
> >
> > recently there were several merge commits (especially for merged pull
> > request).
> >
> > I thought the consensus was to avoid merge commits to keep the git
> > history as clean as possible.
> >
> > Should we keep this policy?
> >
> > What do you think?
> >
> > Cheers,
> >
> > Pascal
> >
> >
> 
> 
>  --
>  Claus Ibsen
>  -
>  http://davsclaus.com @davsclaus
>  Camel in Action 2: https://www.manning.com/ibsen2
> >>>
> >>
> >>



-- 
Zoran Regvart


[GitHub] [camel] lburgazzoli opened a new pull request #3762: chore: replace dependencies versions with properties

2020-04-20 Thread GitBox


lburgazzoli opened a new pull request #3762:
URL: https://github.com/apache/camel/pull/3762


   [ ] 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:
us...@infra.apache.org




[GitHub] [camel] lburgazzoli opened a new pull request #3761: CAMEL-14933: Remove dependencies on spring in GenerateConfigurerMojo

2020-04-20 Thread GitBox


lburgazzoli opened a new pull request #3761:
URL: https://github.com/apache/camel/pull/3761


   [ ] 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:
us...@infra.apache.org




[GitHub] [camel] dmvolod commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

2020-04-20 Thread GitBox


dmvolod commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411212681



##
File path: 
components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
##
@@ -0,0 +1,117 @@
+/*
+ * 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.splunkhec;
+
+import java.net.UnknownHostException;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.util.HostUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@UriParams
+public class SplunkHECConfiguration {
+private static final transient Logger LOG = 
LoggerFactory.getLogger(SplunkHECConfiguration.class);
+
+@UriParam(label = "producer")
+private String index = "camel";
+@UriParam(label = "producer")
+private String sourceType = "camel";
+@UriParam(label = "producer")
+private String source = "camel";
+@UriParam(label = "host")
+private String host;
+@UriParam(label = "skiptlsverify")
+private boolean skiptlsverify;

Review comment:
   @atoulme it would be nice to use camel case, however it's a little bit 
tautology for Camel project :) 





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:
us...@infra.apache.org




[GitHub] [camel] omarsmak commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

2020-04-20 Thread GitBox


omarsmak commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411163810



##
File path: 
components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
##
@@ -0,0 +1,122 @@
+/*
+ * 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.splunkhec;
+
+
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.EntityTemplate;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContextBuilder;
+
+/**
+ * The Splunk HEC producer.
+ */
+public class SplunkHECProducer extends DefaultProducer {
+private static final ObjectMapper MAPPER = new ObjectMapper();
+private SplunkHECEndpoint endpoint;
+private CloseableHttpClient httpClient;
+
+
+public SplunkHECProducer(SplunkHECEndpoint endpoint) {
+super(endpoint);
+this.endpoint = endpoint;
+}
+
+@Override
+protected void doStart() throws Exception {
+super.doStart();
+HttpClientBuilder builder = HttpClients.custom().
+setUserAgent("Camel Splunk HEC/" + 
getEndpoint().getCamelContext().getVersion()).
+setMaxConnTotal(10);
+if (endpoint.getConfiguration().isSkiptlsverify()) {
+SSLContextBuilder sslbuilder = new SSLContextBuilder();
+sslbuilder.loadTrustMaterial(null, (chain, authType) -> true);
+SSLConnectionSocketFactory sslsf = new
+SSLConnectionSocketFactory(sslbuilder.build(), 
NoopHostnameVerifier.INSTANCE);
+builder.setSSLSocketFactory(sslsf);
+}
+httpClient = builder.build();
+}
+
+@Override
+public void process(Exchange exchange) throws Exception {
+Map payload = createPayload(exchange.getIn());
+
+HttpPost httppost = new 
HttpPost((endpoint.getConfiguration().isHttps() ? "https" : "http") + "://" + 
endpoint.getSplunkURL() + "/services/collector/event");
+httppost.addHeader("Authorization", " Splunk " + endpoint.getToken());
+
+EntityTemplate entityTemplate = new EntityTemplate(outputStream -> 
MAPPER.writer().writeValue(outputStream, payload));
+
entityTemplate.setContentType(ContentType.APPLICATION_JSON.getMimeType());
+
+httppost.setEntity(entityTemplate);
+try (CloseableHttpResponse response = httpClient.execute(httppost)) {
+if (response.getStatusLine().getStatusCode() != 200) {
+ByteArrayOutputStream output = new ByteArrayOutputStream();
+response.getEntity().writeTo(output);
+
+throw new RuntimeException(response.getStatusLine().toString() 
+ "\n" + new String(output.toByteArray(), StandardCharsets.UTF_8));
+}
+}
+}
+
+@Override
+protected void doStop() throws Exception {
+super.doStop();
+httpClient.close();

Review comment:
   Isn't better to have `httpClient.close` before `super.doStop()`?





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:
us...@infra.apache.org




Re: karaf integration tests

2020-04-20 Thread Andrea Cosentino
Hello,

Actually the integration tests we had we removed and substituted with a
verify phase on all the features.

So you'll need to add your new features under
platform/karaf/features/src/main/resource/features.xml

and run mvn clean install in platform/karaf/features to verify.

The original integration tests were doing the same stuff, so it would be a
duplication.

Il giorno lun 20 apr 2020 alle ore 09:37 Onder SEZGIN 
ha scritto:

> Hi,
>
> After separation of repositories, has there been a change how we add karaf
> integration tests for new components?
>
> Thanks
>


karaf integration tests

2020-04-20 Thread Onder SEZGIN
Hi,

After separation of repositories, has there been a change how we add karaf
integration tests for new components?

Thanks


[GitHub] [camel] oscerd commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

2020-04-20 Thread GitBox


oscerd commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411137346



##
File path: core/camel-componentdsl/src/generated/resources/metadata.json
##
@@ -6612,6 +6612,28 @@
 "producerOnly": false,
 "lenientProperties": false
   },
+  "SplunkHecComponentBuilderFactory": {
+"kind": "component",
+"name": "splunk-hec",
+"title": "Splunk HEC",
+"description": "The splunk component allows to publish events in Splunk 
using the HTTP Event Collector.",
+"deprecated": false,
+"deprecationNote": "log,monitoring",
+"firstVersion": "3.2.0",

Review comment:
   Firstversion is 3.3.0





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:
us...@infra.apache.org