Commit d1844149 authored by George Tziavas's avatar George Tziavas
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

Documentation.md

0 → 100644
+24 −0
Original line number Diff line number Diff line
# Metrics Collector System (METCO)

## Definitions of the problem
Services (& resources) created through OSL provide a vast amount of data and metrics. The data can be used to perform actions on the said services. Up until now (OSL v1.0) external tools are used to leverage those data.



The goal of this feature is to create a mechanism that, through OSL, can retrieve the data and return them to the services (and/or resources) they are associated with. 

This goal creates challenges on multiple levels:
* How does OSL retrieves data that come from multiple, non-homogenous environments?
* How does OSL associates the data with their respective services?
* How the services receive the data that were retrieved by the MDAS?
* What mechanisms are trigered to perform actions based on the data recieved?

Most of the above challenges can be split in further tecnhical and technology challenges.

## High Level Design


## Tools used 


pom.xml

0 → 100644
+320 −0
Original line number Diff line number Diff line
<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.0.0-SNAPSHOT</version>
		<relativePath>../org.etsi.osl.main</relativePath>
	</parent>


	<artifactId>org.etsi.osl.metco</artifactId>
	<name>org.etsi.osl.metco</name>
	<url>http://openslice.io</url>



	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<spring.boot-version>3.2.2</spring.boot-version>
		
		<spring.boot-version>${spring-boot-version}</spring.boot-version>
		<!-- These versions  work>spring.boot.fabric8-version>3.0.5</spring.boot.fabric8-version -->
		<!-- x>fabric8.version>6.6.2</fabric8.version -->
		
		<camel.version>4.0.0-RC1</camel.version>
		<slf4j-api.version>1.7.5</slf4j-api.version>
		<slf4j-simple.version>1.7.28</slf4j-simple.version>
	</properties>

	<repositories>
		<repository>
			<id>gitlab-maven</id>
			<url>https://labs.etsi.org/rep/api/v4/groups/260/-/packages/maven</url>
		</repository>
	</repositories>
	<!-- <distributionManagement>
		<repository>
			<id>gitlab-maven</id>
			<url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
		</repository>
		<snapshotRepository>
			<id>gitlab-maven</id>
			<url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
		</snapshotRepository>
	</distributionManagement> -->

	<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>

<!--			&lt;!&ndash; Camel BOM &ndash;&gt;-->
<!--			<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>

		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</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>-->

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</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-stream</artifactId>
		</dependency> -->
		

		<!-- slf4j -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
		</dependency>

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
		</dependency>


		<!-- Testing -->
		<!-- <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-engine</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.junit.platform</groupId>
			<artifactId>junit-platform-commons</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.junit.platform</groupId>
			<artifactId>junit-platform-runner</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.activemq</groupId>
			<artifactId>activemq-broker</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>javax.annotation</groupId>
			<artifactId>javax.annotation-api</artifactId>
			<version>1.3.2</version>
		</dependency>

		<dependency>
			<groupId>io.swagger.core.v3</groupId>
			<artifactId>swagger-annotations</artifactId>
			<version>2.1.11</version>
		</dependency>

		<dependency>
			<groupId>jakarta.validation</groupId>
			<artifactId>jakarta.validation-api</artifactId>
			<version>3.0.0</version>
		</dependency>

		<dependency>
			<groupId>org.openapitools</groupId>
			<artifactId>jackson-databind-nullable</artifactId>
			<version>0.2.1</version>
		</dependency>

		<dependency>
			<groupId>javax.jms</groupId>
			<artifactId>javax.jms-api</artifactId>
			<version>2.0.1</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.15.1</version>
			<scope>test</scope>
		</dependency> -->
<!--		<dependency>-->
<!--			<groupId>org.springframework</groupId>-->
<!--			<artifactId>spring-web</artifactId>-->
<!--			<version>6.1.5</version>-->
<!--		</dependency>-->
	</dependencies>

	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-maven-plugin</artifactId>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<configuration>
						<source>17</source>
						<target>17</target>
						<annotationProcessorPaths>
							<path>
								<groupId>org.projectlombok</groupId>
								<artifactId>lombok</artifactId>
								<version>1.18.28</version>
							</path>
						</annotationProcessorPaths>
					</configuration>
				</plugin>
				<plugin>
					<!-- run mvn license:update-file-header to manually update all headers 
						everywhere -->
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>license-maven-plugin</artifactId>
					<version>${maven-license-plugin.version}</version>
					<configuration>
						<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
						<processStartTag>========================LICENSE_START=================================</processStartTag>
						<processEndTag>=========================LICENSE_END==================================</processEndTag>
						<excludes>*.json</excludes>
					</configuration>
					<executions>
						<execution>
							<id>generate-license-headers</id>
							<goals>
								<goal>update-file-header</goal>
							</goals>
							<phase>process-sources</phase>
							<configuration>
								<licenseName>${license.licenseName}</licenseName>

							</configuration>
						</execution>
						<execution>
							<id>download-licenses</id>
							<goals>
								<goal>download-licenses</goal>
							</goals>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>${spring-boot-version}</version>
				<configuration>
					<classifier>exec</classifier>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

		</plugins>

	</build>



</project>
+21 −0
Original line number Diff line number Diff line
package org.etsi.osl.metco;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MetcoController {

    private static final Logger logger = LoggerFactory.getLogger(MetcoController.class);

    @GetMapping("/live")
    public ResponseEntity<String> livenessCheck() {
        return new ResponseEntity<>("Application is running", HttpStatus.OK);
    }

}
+51 −0
Original line number Diff line number Diff line
package org.etsi.osl.metco;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;


@SpringBootApplication
public class MetcoSpringBoot implements CommandLineRunner {

  private static final Logger logger =
          LoggerFactory.getLogger(MetcoSpringBoot.class.getSimpleName());


  @Override
  public void run(String... arg0) {
    if (arg0.length > 0 && arg0[0].equals("exitcode")) {
      throw new ExitException();
    }
  }

  public static void main(String[] args) {
    logger.info("=========== STARTING METCO ==============================");
    ApplicationContext applicationContext = new SpringApplication(MetcoSpringBoot.class).run(args);
  }

  static class ExitException extends RuntimeException implements ExitCodeGenerator {
    private static final long serialVersionUID = 1L;
    @Override
    public int getExitCode() {
      return 10;
    }
  }

}

@Configuration
@EnableScheduling
@ConditionalOnProperty(name = "scheduling.enabled", matchIfMissing = true)
class SchedulingConfiguration {
}
 No newline at end of file
+36 −0
Original line number Diff line number Diff line
spring:
  config:
    activate:
      on-profile: "default"
  application:
    name: metco
  main:
    web-application-type: servlet
#   activemq:
#     brokerUrl: tcp://localhost:61616?jms.watchTopicAdvisories=false
#     user: artemis
#     password: artemis
#     pool:
#       enabled: true
#       max-connections: 100
#     packages:
#       trust-all: true

server:
  port: 8030
  
   
logging:
  level:
    org.etsi.osl.mdas: DEBUG
    root: INFO
    org.springframework: INFO
    org.apache.camel: INFO
    reactor.netty.tcp.TcpClient: INFO
    reactor.netty.http.client.HttpClient: DEBUG
  pattern:
    console: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
    file: "%d %p %c{1.} [%t] %m%n"
    
scheduling.enabled: true
 No newline at end of file