Skip to content
Snippets Groups Projects
Commit e0d6ec6f authored by tranoris's avatar tranoris Committed by trantzas
Browse files

Initial commit

(cherry picked from commit 0ca7c8b9)
parent edb8bba6
No related branches found
No related tags found
1 merge request!2Resolve "Populate main branch with initial commit (Release 0)"
/target/
.project
.classpath
/.settings
FROM ibm-semeru-runtimes:open-17.0.7_7-jdk
MAINTAINER openslice.io
RUN mkdir /opt/shareclasses
RUN mkdir -p /opt/openslice/lib/
COPY target/org.etsi.osl.centrallog.service-1.2.0-SNAPSHOT.jar /opt/openslice/lib/
CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.centrallog.service-1.2.0-SNAPSHOT.jar"]
\ No newline at end of file
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.etsi.osl</groupId>
<artifactId>org.etsi.osl.main</artifactId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../org.etsi.osl.main</relativePath>
</parent>
<artifactId>org.etsi.osl.centrallog.service</artifactId>
<name>org.etsi.osl.centrallog.service</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring.boot-version>${spring-boot-version}</spring.boot-version>
<spring.cloud-consul-version>${spring-cloud-consul-version}</spring.cloud-consul-version>
</properties>
<dependencyManagement>
<dependencies>
<!-- Spring Boot BOM -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Camel BOM -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-dependencies</artifactId>
<version>${camel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-undertow-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.0.2</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency> -->
<!-- activeMQ -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-amqp</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.qpid</groupId>
<artifactId>proton-j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.messaginghub</groupId>
<artifactId>pooled-jms</artifactId>
</dependency>
<!-- Camel -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-activemq</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-service-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-http-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http-common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stream</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- models -->
<dependency>
<groupId>org.etsi.osl</groupId>
<artifactId>org.etsi.osl.model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.etsi.osl</groupId>
<artifactId>org.etsi.osl.tmf.api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package org.etsi.osl.centrallog.service;
/*-
* ========================LICENSE_START=================================
* org.etsi.osl.bugzilla
* %%
* Copyright (C) 2019 openslice.io
* %%
* Licensed 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.
* =========================LICENSE_END==================================
*/
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
/**
* @author ichatzis
*
* based on
* https://github.com/apache/camel/tree/master/examples/camel-example-spring-boot-activemq
* https://github.com/indrabasak/spring-consul-example
*/
// This is equivalent to @Configuration, @EnableAutoConfiguration, and @ComponentScan
@SpringBootApplication
// This annotation is used for consul
@EnableDiscoveryClient
//@EnableRetry
// This is from spring-cloud to allow local configuration application
@RefreshScope
// @EnableAutoConfiguration annotation tells Spring Boot to "guess" how you will want to configure Spring,
// based on the jar dependencies that you have added. For example, If HSQLDB is on your classpath, and you
// have not manually configured any database connection beans, then Spring will auto-configure an in-memory database.
@EnableAutoConfiguration
// This is enabled by default
@EnableConfigurationProperties
public class CentralLogService {
public static void main(String[] args) {
SpringApplication.run( CentralLogService.class, args);
}
}
package org.etsi.osl.centrallog.service;
/*-
* ========================LICENSE_START=================================
* org.etsi.osl.portal.api
* %%
* Copyright (C) 2019 openslice.io
* %%
* Licensed 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.
* =========================LICENSE_END==================================
*/
/**
* @author ichatzis
**/
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties
@ConfigurationProperties
public class CentralLoggerConfig {
private String centrallogurl;
public String getCentrallogurl() {
return centrallogurl;
}
public void setCentrallogurl(String centrallogurl) {
this.centrallogurl = centrallogurl;
}
}
package org.etsi.osl.centrallog.service;
/*-
* ========================LICENSE_START=================================
* org.etsi.osl.portal.api
* %%
* Copyright (C) 2019 openslice.io
* %%
* Licensed 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.
* =========================LICENSE_END==================================
*/
/**
* @author ichatzis
**/
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@Configuration
@Component
public class CentralLoggerRouteBuilder extends RouteBuilder{
private static String CENTRALLOGGERURL = "";
@Autowired
private CentralLoggerConfig centrallogerconfig;
private static final transient Log logger = LogFactory.getLog( CentralLoggerRouteBuilder.class.getName());
public void configure() {
if ( centrallogerconfig.getCentrallogurl() != null) {
CENTRALLOGGERURL = centrallogerconfig.getCentrallogurl();
}
if ( ( CENTRALLOGGERURL == null ) || CENTRALLOGGERURL.equals( "" ) ){
logger.info( "NO CENTRALLOGGERURL ROUTING. ELASTICURL = " + CENTRALLOGGERURL);
return;
}
logger.info( "ENABLED CENTRALLOGGERURL ROUTING. ELASTICURL = " + CENTRALLOGGERURL);
String url = CENTRALLOGGERURL;
from("activemq:queue:centrallogger.log")
.log( "activemq:queue:centrallogger.log package with body ${body} !" )
.setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http.HttpMethods.POST))
.setHeader("Content-Type", constant("application/json"))
.to("log:DEBUG?showBody=true&showHeaders=true")
.doTry()
.toD( url )
.to("log:DEBUG?showBody=true&showHeaders=true")
.doCatch(Exception.class)
.setBody(exceptionMessage().convertToString())
.to("log:DEBUG?showBody=true&showHeaders=true")
.end();
}
}
# For Spring Actuator /info endpoint
info:
artifact: centrallog-service
name: centrallog-service
description: Spring centrallog-service
version: 1.0.0
server:
port: 13013
logging:
level:
org.apache.camel: INFO
file: logs/application-debug.log
pattern:
console: "%d %-5level %logger : %msg%n"
file: "%d %-5level [%thread] %logger : %msg%n"
spring:
config:
activate:
on-profile: "default"
application:
name: centrallog-service
activemq:
brokerUrl: tcp://localhost:61616?jms.watchTopicAdvisories=false
user: artemis
password: artemis
pool:
enabled: true
max-connections: 100
packages:
trust-all: true
centrallogurl: "http://elk_ip:elk_port/index_name/_doc"
<?xml version="1.0" encoding="UTF-8"?>
<!--
========================LICENSE_START=================================
org.etsi.osl.oauth.server
%%
Copyright (C) 2019 openslice.io
%%
Licensed 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.
=========================LICENSE_END==================================
-->
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<springProfile name="default">
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
<springProfile name="prod">
<appender name="FILE-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>app.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>logs/archived/app.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- each archived file, size max 10MB -->
<maxFileSize>10MB</maxFileSize>
<!-- total size of all archive files, if total size > 20GB, it will delete old archived file -->
<totalSizeCap>20GB</totalSizeCap>
<!-- 60 days to keep -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d %p %c{1.} [%t] %m%n</pattern>
</encoder>
</appender>
<logger name="org.springframework" level="INFO"/>
<logger name="portal.api" level="DEBUG"/>
<root level="ERROR">
<appender-ref ref="FILE-ROLLING"/>
</root>
</springProfile>
</configuration>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment