Skip to content

Commit

Permalink
Merge pull request #48 from abes-esr/develop
Browse files Browse the repository at this point in the history
Merge develop dans main
  • Loading branch information
SamuelQuetin authored Oct 24, 2024
2 parents 0276784 + b962a7b commit ceea923
Show file tree
Hide file tree
Showing 26 changed files with 399 additions and 695 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ WORKDIR /app/
COPY --from=build-image /build/target/*.jar /app/logskbart-api.jar
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["java","-jar","/app/logskbart-api.jar"]
COPY ./docker/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
59 changes: 59 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

export SPRING_ELASTICSEARCH_URIS=${SPRING_ELASTICSEARCH_URIS:='http://localhost:9200'}

curl -X PUT "$SPRING_ELASTICSEARCH_URIS/logkbart" -H 'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"ID": {
"type": "text"
},
"PACKAGE_NAME": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"TIMESTAMP": {
"type": "date"
},
"THREAD": {
"type": "text"
},
"LEVEL": {
"type": "text"
},
"LOGGER_NAME": {
"type": "text"
},
"MESSAGE": {
"type": "text"
},
"END_OF_BATCH": {
"type": "boolean"
},
"LOGGER_FQCN": {
"type": "text"
},
"THREAD_ID": {
"type": "integer"
},
"THREAD_PRIORITY": {
"type": "integer"
},
"NB_LINE": {
"type": "integer"
}
}
}
}'

java -jar /app/logskbart-api.jar
52 changes: 16 additions & 36 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.4</version>
<version>3.2.8</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>fr.abes</groupId>
Expand Down Expand Up @@ -76,28 +76,25 @@
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<exclusions>
<exclusion>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- BDD -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.9.0.0</version>
</dependency>

<!-- === Logging === -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -114,12 +111,11 @@
</exclusion>
</exclusions>
</dependency>

<!-- === Mapping === -->
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.3.5</version>
<version>3.1.1</version>
</dependency>

<dependency>
Expand All @@ -135,11 +131,6 @@
</dependency>

<!-- Utilitaires -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
Expand All @@ -150,18 +141,7 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
</dependency>

<!-- gestion des LocalDateTime -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.12.6</version>
<version>2.3.0</version>
</dependency>

<!-- TEST -->
Expand All @@ -171,9 +151,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
25 changes: 0 additions & 25 deletions src/main/java/fr/abes/logskbart/configuration/AbstractConfig.java

This file was deleted.

34 changes: 27 additions & 7 deletions src/main/java/fr/abes/logskbart/configuration/KafkaConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.abes.logskbart.configuration;

import fr.abes.logskbart.kafka.WorkInProgress;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -9,28 +10,37 @@
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.listener.ContainerProperties;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;

@Configuration
@EnableKafka
public class KafkaConfig {
@Value("${spring.kafka.consumer.bootstrap-servers}")
@Value("${abes.kafka.bootstrap-servers}")
private String bootstrapAddress;

@Value("${topic.groupid.source}")
private String groupId;
@Value("${abes.nbThread}")
private int nbThread;


@Bean
public ConsumerFactory<String, String> consumerLogsFactory() {
Map<String, Object> props = new HashMap<>();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
props.put(ConsumerConfig.GROUP_INSTANCE_ID_CONFIG,("SchedulerCoordinator"+ UUID.randomUUID()));
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, true);
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 100);
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 60000);
return new DefaultKafkaConsumerFactory<>(props);
}

Expand All @@ -44,7 +54,17 @@ public ConsumerFactory<String, String> consumerLogsFactory() {
}

@Bean
public Map<String, Timestamp> lastTimeStampByFilename() {
return new HashMap<>();
public Map<String, WorkInProgress> workInProgressMap() {
return new ConcurrentHashMap<>();
}

@Bean
public Executor executor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(nbThread);
executor.setMaxPoolSize(nbThread);
executor.setQueueCapacity(500);
executor.initialize();
return executor;
}
}
54 changes: 0 additions & 54 deletions src/main/java/fr/abes/logskbart/configuration/LogsBdConfig.java

This file was deleted.

This file was deleted.

Loading

0 comments on commit ceea923

Please sign in to comment.