Cleanup in build files.
Handle errors in http route. Some steps towards influx in collector.
This commit is contained in:
parent
9b99e22b8b
commit
94eb0d17f9
|
@ -1,34 +1,21 @@
|
|||
plugins {
|
||||
id 'groovy'
|
||||
id 'application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Use Maven Central for resolving dependencies.
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation 'org.codehaus.groovy:groovy:3.0.7'
|
||||
testImplementation 'org.spockframework:spock-core:2.0-M4-groovy-3.0'
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
testImplementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
testImplementation project(':shared')
|
||||
|
||||
implementation project(':shared')
|
||||
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
implementation "org.slf4j:slf4j-simple:${slf4jVersion}"
|
||||
|
||||
annotationProcessor(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}")
|
||||
implementation group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}"
|
||||
|
||||
implementation group: 'org.apache.camel', name: 'camel-core', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-main', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-http', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-jackson', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-bean', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-timer', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-stream', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-core', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-main', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-http', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-jackson', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-bean', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-timer', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-stream', version: camelVersion
|
||||
}
|
||||
|
||||
application {
|
||||
|
|
|
@ -78,7 +78,11 @@ public class MyRouteBuilder extends RouteBuilder {
|
|||
.process(new MetricProcessor())
|
||||
.marshal().json()
|
||||
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
|
||||
.to("http://127.0.0.1:9925/metrics");
|
||||
.doTry()
|
||||
.to("http://127.0.0.1:9925/metrics")
|
||||
.doCatch(Exception.class)
|
||||
.log("Error sending metric to collector.")
|
||||
.end();
|
||||
|
||||
|
||||
|
||||
|
|
12
build.gradle
12
build.gradle
|
@ -1,14 +1,20 @@
|
|||
subprojects {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'groovy'
|
||||
|
||||
dependencies {
|
||||
testImplementation project(':shared')
|
||||
testImplementation 'org.spockframework:spock-core:2.0-M5-groovy-3.0'
|
||||
testImplementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
|
||||
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
implementation "org.slf4j:slf4j-simple:${slf4jVersion}"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,29 +1,22 @@
|
|||
plugins {
|
||||
id 'groovy'
|
||||
id 'application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Use Maven Central for resolving dependencies.
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation project(':shared')
|
||||
implementation project(':shared')
|
||||
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
implementation "org.slf4j:slf4j-simple:${slf4jVersion}"
|
||||
|
||||
implementation group: 'org.apache.camel', name: 'camel-core', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-rest', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-jetty', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-jackson', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-main', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-bean', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-timer', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-stream', version: '3.7.3'
|
||||
implementation group: 'org.apache.camel', name: 'camel-core', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-rest', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-jetty', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-jackson', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-main', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-bean', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-timer', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-stream', version: camelVersion
|
||||
implementation group: 'org.apache.camel', name: 'camel-influxdb', version: camelVersion
|
||||
}
|
||||
|
||||
|
||||
application {
|
||||
// Define the main class for the application.
|
||||
mainClassName = 'org.sysmon.collector.Application'
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
package org.sysmon.collector;
|
||||
|
||||
import org.apache.camel.main.Main;
|
||||
import org.apache.camel.support.SimpleRegistry;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.InfluxDBFactory;
|
||||
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
InfluxDB influxConnectionBean = InfluxDBFactory.connect("http://localhost:8086", "root", "");
|
||||
|
||||
Main main = new Main();
|
||||
main.bind("myInfluxConnection", influxConnectionBean);
|
||||
main.configure().addRoutesBuilder(CollectorRouteBuilder.class);
|
||||
|
||||
|
||||
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
|
||||
try {
|
||||
main.run(args);
|
||||
|
@ -16,4 +24,5 @@ public class Application {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.sysmon.collector;
|
||||
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.apache.camel.model.rest.RestBindingMode;
|
||||
import org.sysmon.shared.dto.MetricMessageDTO;
|
||||
|
@ -9,6 +8,7 @@ public class CollectorRouteBuilder extends RouteBuilder {
|
|||
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
|
||||
restConfiguration().component("jetty")
|
||||
.bindingMode(RestBindingMode.auto)
|
||||
.host("127.0.0.1")
|
||||
|
@ -28,7 +28,16 @@ public class CollectorRouteBuilder extends RouteBuilder {
|
|||
.type(MetricMessageDTO.class)
|
||||
.route()
|
||||
.to("bean:incomingMetricProcessor")
|
||||
.to("seda:inbound")
|
||||
.endRest();
|
||||
}
|
||||
|
||||
/*
|
||||
from("seda:inbound")
|
||||
.to("influxdb://myInfluxConnection?databaseName=sysmon");
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
pf4jVersion=3.6.0
|
||||
slf4jVersion=1.7.30
|
||||
camelVersion=3.7.3
|
|
@ -3,8 +3,7 @@ subprojects {
|
|||
apply plugin: 'groovy'
|
||||
|
||||
dependencies {
|
||||
|
||||
testImplementation 'org.spockframework:spock-core:2.0-M4-groovy-3.0'
|
||||
testImplementation 'org.spockframework:spock-core:2.0-M5-groovy-3.0'
|
||||
testImplementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
testImplementation project(':shared')
|
||||
|
||||
|
@ -14,7 +13,6 @@ subprojects {
|
|||
}
|
||||
annotationProcessor(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}")
|
||||
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
Loading…
Reference in a new issue