Commit f2dd01ac authored by Deniro StopCovid's avatar Deniro StopCovid

Merge branch 'feature/cockpit-to-batch' into 'develop'

feat: Setting Robert Server Batch

See merge request !90
parents 5591f4dc 0fad823a
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<licenses>
......@@ -110,6 +112,17 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-vault-config-consul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -5,13 +5,14 @@ import org.springframework.stereotype.Component;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* Configuration class of the scoring algorithm
*
*
*/
@Getter
@ToString
@Setter
@Component
@ConfigurationProperties(prefix = "robert.scoring")
......@@ -21,7 +22,7 @@ public class ScoringAlgorithmConfiguration {
private int rssiMax;
// Weighting vector for the # of packets received per window values
private double[] deltas;
private String[] deltas;
// limit power in Db below which the collected value is assumed to be zero
private double p0;
......
......@@ -167,7 +167,7 @@ public class ScoringStrategyV2ServiceImpl implements ScoringStrategyService {
if (np[k] > 0) {
kmax = k;
int dd = Math.min(np[k], configuration.getDeltas().length - 1);
double gamma = (qm[k] - configuration.getP0()) / configuration.getDeltas()[dd];
double gamma = (qm[k] - configuration.getP0()) / Double.parseDouble(configuration.getDeltas()[dd]);
double vrisk = (gamma <= 0.0) ? 0.0 : (gamma >= 1) ? 1.0 : gamma;
if (vrisk > 0) {
nbcontacts++;
......
......@@ -4,8 +4,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@Component
public class PropertyLoader {
......@@ -25,11 +27,11 @@ public class PropertyLoader {
private Integer helloMessageTimeStampTolerance;
@Value("${robert.protocol.contagious-period}")
private Integer contagiousPeriod;
@Value("${robert.scoring.scoring-algo-r0}")
private Double r0ScoringAlgorithm;
@Value("${robert.scoring.batch-mode}")
private Integer contagiousPeriod;
@Value("${robert.scoring.scoring-algo-r0}")
private Double r0ScoringAlgorithm;
@Value("${robert.scoring.batch-mode}")
private String batchMode;
}
#spring.data.mongodb.authentication-database= # Authentication database name.
# Database name.
# spring.data.mongodb.database=${ROBERT_SERVER_DB_NAME:protectedRobertDB}
#spring.data.mongodb.field-naming-strategy= # Fully qualified name of the FieldNamingStrategy to use.
#spring.data.mongodb.grid-fs-database= # GridFS database name.
# spring.data.mongodb.host=${ROBERT_SERVER_DB_HOST:localhost}
# Mongo server host.
#spring.data.mongodb.password= # Login password of the mongo server.
# Mongo server port.
# spring.data.mongodb.port=${ROBERT_SERVER_DB_PORT:27017}
spring.data.mongodb.uri=${ROBERT_SERVER_DB_URI:mongodb\://${ROBERT_SERVER_DB_HOST:localhost}\:${ROBERT_SERVER_DB_PORT:27017}/${ROBERT_SERVER_DB_NAME:protectedRobertDB}}
## Enable Mongo repositories.
# The hostname of the crypto server
robert.crypto.server.host=${ROBERT_CRYPTO_SERVER_HOST:localhost}
# The port of the crypto server
robert.crypto.server.port=${ROBERT_CRYPTO_SERVER_PORT:9090}
# The time start of the server
robert.server.time-start=${ROBERT_SERVER_TIMESTART:20200601}
# RSSI (in dB) at 1 meter used by the scoring algorithm
robert.protocol.scoring-algo-rssi=${ROBERT_PROTOCOL_SCORING_ALGO_RSSI:-40}
# Scoring risk threshold
robert.protocol.risk-threshold=${ROBERT_PROTOCOL_SCORING_THRESHOLD:0.1}
robert.scoring.deltas=${ROBERT_SCORING_DELTAS:39.0,27.0,23.0,21.0,20.0,15.0}
robert.scoring.rssi-max=${ROBERT_SCORING_RSSI_MAX:-35}
robert.scoring.p0=${ROBERT_SCORING_P0:-66.0}
robert.scoring.soft-max-a=${ROBERT_SCORING_SOFT_MAX_A:4.342}
robert.scoring.soft-max-b=${ROBERT_SCORING_SOFT_MAX_B:0.2}
robert.scoring.algo-version=${ROBERT_SCORING_ALGO_VERSION:2}
robert.scoring.scoring-algo-r0=${ROBERT_SCORING_R0:0.0071}
robert.scoring.batch-mode=${ROBERT_SCORING_BATCH_MODE:SCORE_CONTACTS_AND_COMPUTE_RISK}
robert.protocol.hello-message-timestamp-tolerance=${ROBERT_PROTOCOL_HELLO_TOLERANCE:180}
robert.server.country-code=${ROBERT_SERVER_COUNTRY_CODE:0x21}
robert.protocol.contagious-period=${ROBERT_PROTOCOL_CONTAGIOUS_PERIOD:14}
#spring.data.mongodb.authentication-database= # Authentication database name.
# Database name.
# spring.data.mongodb.database=${ROBERT_SERVER_DB_NAME:protectedRobertDB}
#spring.data.mongodb.field-naming-strategy= # Fully qualified name of the FieldNamingStrategy to use.
#spring.data.mongodb.grid-fs-database= # GridFS database name.
# spring.data.mongodb.host=${ROBERT_SERVER_DB_HOST:localhost}
# Mongo server host.
#spring.data.mongodb.password= # Login password of the mongo server.
# Mongo server port.
# spring.data.mongodb.port=${ROBERT_SERVER_DB_PORT:27017}
spring.data.mongodb.uri=${ROBERT_SERVER_DB_URI:mongodb\://${ROBERT_SERVER_DB_HOST:localhost}\:${ROBERT_SERVER_DB_PORT:27017}/${ROBERT_SERVER_DB_NAME:protectedRobertDB}}
## Enable Mongo repositories.
# The hostname of the crypto server
......@@ -21,23 +9,10 @@ robert.crypto.server.port=${ROBERT_CRYPTO_SERVER_PORT:9090}
# The time start of the server
robert.server.time-start=${ROBERT_SERVER_TIMESTART:20200601}
# RSSI (in dB) at 1 meter used by the scoring algorithm
robert.protocol.scoring-algo-rssi=${ROBERT_PROTOCOL_SCORING_ALGO_RSSI:-40}
# Scoring risk threshold
robert.protocol.risk-threshold=${ROBERT_PROTOCOL_SCORING_THRESHOLD:0.1}
robert.scoring.deltas=${ROBERT_SCORING_DELTAS:39.0,27.0,23.0,21.0,20.0,15.0}
robert.scoring.rssi-max=${ROBERT_SCORING_RSSI_MAX:-35}
robert.scoring.p0=${ROBERT_SCORING_P0:-66.0}
robert.scoring.soft-max-a=${ROBERT_SCORING_SOFT_MAX_A:4.342}
robert.scoring.soft-max-b=${ROBERT_SCORING_SOFT_MAX_B:0.2}
robert.scoring.algo-version=${ROBERT_SCORING_ALGO_VERSION:2}
robert.scoring.scoring-algo-r0=${ROBERT_SCORING_R0:0.0071}
robert.scoring.batch-mode=${ROBERT_SCORING_BATCH_MODE:SCORE_CONTACTS_AND_COMPUTE_RISK}
robert.protocol.hello-message-timestamp-tolerance=${ROBERT_PROTOCOL_HELLO_TOLERANCE:180}
robert.server.country-code=${ROBERT_SERVER_COUNTRY_CODE:0x21}
robert.protocol.contagious-period=${ROBERT_PROTOCOL_CONTAGIOUS_PERIOD:14}
spring:
application:
name: robert-batch
profiles:
active: ${SPRING_PROFILES_ACTIVE:dev}
cloud:
consul:
enabled: ${CONSUL_ENABLED:false}
host: ${CONSUL_HOST:localhost}
port: ${CONSUL_PORT:8500}
scheme: ${CONSUL_SCHEME:http}
token: ${ROBERT_SERVER_CONSUL_ACL_TOKEN:token}
config:
enabled: ${CONSUL_CONFIG_ENABLED:false}
watch:
enabled: false
vault:
enabled: ${VAULT_ENABLED:false}
host: ${VAULT_HOST:localhost}
port: ${VAULT_PORT:8200}
token: ${VAULT_TOKEN:token}
scheme: ${VAULT_SCHEME:http}
......@@ -13,23 +13,21 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import fr.gouv.stopc.robert.server.common.utils.TimeUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import fr.gouv.stopc.robert.server.batch.RobertServerBatchApplication;
import fr.gouv.stopc.robert.server.batch.exception.RobertScoringException;
import fr.gouv.stopc.robert.server.batch.service.impl.ScoringStrategyServiceImpl;
import fr.gouv.stopc.robert.server.batch.utils.PropertyLoader;
import fr.gouv.stopc.robert.server.common.service.IServerConfigurationService;
import fr.gouv.stopc.robert.server.common.utils.TimeUtils;
import fr.gouv.stopc.robertserver.database.model.Contact;
import fr.gouv.stopc.robertserver.database.model.HelloMessageDetail;
import lombok.extern.slf4j.Slf4j;
......
......@@ -33,4 +33,3 @@ robert.scoring.batch-mode=${ROBERT_SCORING_BATCH_MODE:SCORE_CONTACTS_AND_COMPUTE
robert.server.time-start=20200601
robert.protocol.contagious-period=14
robert.protocol.hello-message-timestamp-tolerance=180
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment