Skip to content

Commit

Permalink
Merge branch 'develop' into cvmgr-cimms-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob6838 committed Aug 20, 2024
2 parents ea8bf9b + 34a79ed commit adcb888
Show file tree
Hide file tree
Showing 123 changed files with 2,952 additions and 175 deletions.
102 changes: 91 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,54 @@
FROM maven:3.8-eclipse-temurin-21-alpine as builder
# === BUILDER IMAGE for ACM ===
# FROM alpine:3.12 as builder
FROM amazonlinux:2023 as builder
USER root
WORKDIR /asn1_codec
## add build dependencies
RUN yum install -y cmake g++ make bash automake libtool autoconf flex bison

# Install librdkafka from Confluent repo
RUN rpm --import https://packages.confluent.io/rpm/7.6/archive.key
COPY ./confluent.repo /etc/yum.repos.d
RUN yum clean all
RUN yum install -y librdkafka-devel

# Install pugixml
ADD ./asn1_codec/pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# Build and install asn1c submodule
ADD ./asn1_codec/usdot-asn1c /asn1_codec/asn1c
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
ADD ./asn1_codec/asn1c_combined /asn1_codec/asn1c_combined
RUN cd /asn1_codec/asn1c_combined && bash doIt.sh

# Remove any lingering .asn files
RUN rm -rf /asn1c_codec/asn1c_combined/j2735-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/semi-asn-files

# Remove duplicate files
RUN rm -rf /asn1c_codec/asn1c_combined/generated-files

# add the source and build files
ADD ./asn1_codec/CMakeLists.txt /asn1_codec
ADD ./asn1_codec/config /asn1_codec/config
ADD ./asn1_codec/include /asn1_codec/include
ADD ./asn1_codec/src /asn1_codec/src
ADD ./asn1_codec/kafka-test /asn1_codec/kafka-test
ADD ./asn1_codec/unit-test-data /asn1_codec/unit-test-data
ADD ./asn1_codec/data /asn1_codec/data
ADD ./asn1_codec/run_acm.sh /asn1_codec
ADD ./asn1_codec/data /asn1_codec/data

# Build acm.
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make


# # === Build image for Java ===
FROM maven:3.8-eclipse-temurin-21-alpine as jbuilder

WORKDIR /home

Expand Down Expand Up @@ -37,17 +87,49 @@ RUN mvn clean install -DskipTests
WORKDIR /home/jpo-conflictvisualizer-api

RUN mvn clean package -DskipTests
# ENTRYPOINT ["tail", "-f", "/dev/null"]
FROM eclipse-temurin:21-jre-alpine
ENTRYPOINT ["tail", "-f", "/dev/null"]


# # === RUNTIME IMAGE for Java and ACM ===
# # Use Amazon Corretto Java on Amazon Linum 2023 to match the codec build env
# # FROM alpine:3.12
FROM amazoncorretto:21-al2023

WORKDIR /home

COPY --from=builder /home/jpo-conflictvisualizer-api/src/main/resources/application.yaml /home
COPY --from=builder /home/jpo-conflictvisualizer-api/src/main/resources/logback.xml /home
COPY --from=builder /home/jpo-conflictvisualizer-api/target/jpo-conflictvisualizer-api-0.0.1-SNAPSHOT.jar /home
COPY --from=jbuilder /home/jpo-conflictvisualizer-api/src/main/resources/application.yaml /home
COPY --from=jbuilder /home/jpo-conflictvisualizer-api/src/main/resources/logback.xml /home
COPY --from=jbuilder /home/jpo-conflictvisualizer-api/target/jpo-conflictvisualizer-api.jar /home
# # Copy asn1_codec executable and test files
USER root
WORKDIR /asn1_codec



# # add runtime dependencies
RUN yum install -y bash


# Install librdkafka from Confluent repo
RUN rpm --import https://packages.confluent.io/rpm/7.6/archive.key
COPY ./confluent.repo /etc/yum.repos.d
RUN yum clean all
RUN yum install -y librdkafka-devel

#COPY cert.crt /home/cert.crt
#RUN keytool -import -trustcacerts -keystore /opt/java/openjdk/lib/security/cacerts -storepass changeit -noprompt -alias mycert -file cert.crt
# # copy the built files from the builder
COPY --from=builder /asn1_codec /asn1_codec
COPY --from=builder /build /build

# # Add test data. This changes frequently so keep it low in the file.
ADD ./asn1_codec/docker-test /asn1_codec/docker-test

# # Put workdir back to Java home
WORKDIR /home


# # ENTRYPOINT ["java", "-jar", "/home/asn1-codec-java.jar"]
# # #COPY cert.crt /home/cert.crt
# # #RUN keytool -import -trustcacerts -keystore /opt/java/openjdk/lib/security/cacerts -storepass changeit -noprompt -alias mycert -file cert.crt

ENTRYPOINT ["java", \
"-Djava.rmi.server.hostname=$DOCKER_HOST_IP", \
Expand All @@ -59,6 +141,4 @@ ENTRYPOINT ["java", \
"-Dcom.sun.management.jmxremote.ssl=false", \
"-Dlogback.configurationFile=/home/logback.xml", \
"-jar", \
"/home/jpo-conflictvisualizer-api-0.0.1-SNAPSHOT.jar"]

# ENTRYPOINT ["tail", "-f", "/dev/null"]
"/home/jpo-conflictvisualizer-api.jar"]
1 change: 1 addition & 0 deletions asn1_codec
Submodule asn1_codec added at 3b4076
13 changes: 13 additions & 0 deletions confluent.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Confluent]
name=Confluent repository
baseurl=https://packages.confluent.io/rpm/7.6
gpgcheck=1
gpgkey=https://packages.confluent.io/rpm/7.6/archive.key
enabled=1

[Confluent-Clients]
name=Confluent Clients repository
baseurl=https://packages.confluent.io/clients/rpm/centos/9/x86_64
gpgcheck=1
gpgkey=https://packages.confluent.io/clients/rpm/archive.key
enabled=1
2 changes: 1 addition & 1 deletion jpo-conflictmonitor
Submodule jpo-conflictmonitor updated from 67bec7 to 6cfe9f
31 changes: 22 additions & 9 deletions jpo-conflictvisualizer-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
</parent>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-conflictvisualizer-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jpo-conflictvisualizer-api</name>
<description>Conflict Visualizer</description>
<properties>
Expand Down Expand Up @@ -77,21 +78,27 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- <dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
</dependency> -->
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-ode-core</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<!-- required exclusion to preserve keycloak versions -->
<exclusions>
<exclusion>
Expand All @@ -103,18 +110,23 @@
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-ode-plugins</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-ode-svcs</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-geojsonconverter</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
<classifier>jpo-geojsonconverter</classifier>
</dependency>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-conflictmonitor</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
<classifier>jpo-conflictmonitor</classifier>
</dependency>
<dependency>
Expand All @@ -124,8 +136,8 @@
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.7.0</version>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -211,6 +223,7 @@
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package us.dot.its.jpo.ode.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import us.dot.its.jpo.ode.api.asn1.DecoderManager;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableWebMvc
@SpringBootApplication
@EnableScheduling
@ComponentScan(basePackages = {"us.dot.its.jpo.ode.api", "us.dot.its.jpo.geojsonconverter.validator"})
public class ConflictApiApplication extends SpringBootServletInitializer {

@Autowired DecoderManager manager;

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(ConflictApiApplication.class);
Expand All @@ -21,9 +28,7 @@ public static void main(String[] args) {
SpringApplication.run(ConflictApiApplication.class, args);
System.out.println("Started Conflict Monitor API");
System.out.println("Conflict Monitor API docs page found here: http://localhost:8081/swagger-ui/index.html");
System.out.println("Startup Complete");


System.out.println("Startup Complete");
}

// @Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public interface ConnectionOfTravelAssessmentRepository extends DataLoader<Conne
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<ConnectionOfTravelAssessment> find(Query query);


}

Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
return query;
}


public long getQueryResultCount(Query query) {
return mongoTemplate.count(query, ConnectionOfTravelAssessment.class, collectionName);
}

// Removes the result limit on a count query.
public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, ConnectionOfTravelAssessment.class, collectionName);
query.limit(limit);
return count;
}

public List<ConnectionOfTravelAssessment> find(Query query) {
return mongoTemplate.find(query, ConnectionOfTravelAssessment.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public interface LaneDirectionOfTravelAssessmentRepository extends DataLoader<La
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<LaneDirectionOfTravelAssessment> find(Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import us.dot.its.jpo.conflictmonitor.monitor.models.assessments.LaneDirectionOfTravelAssessment;
import us.dot.its.jpo.ode.api.ConflictMonitorApiProperties;

Expand Down Expand Up @@ -51,13 +52,24 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}else{
query.limit(props.getMaximumResponseSize());
}

return query;
}



public long getQueryResultCount(Query query) {
return mongoTemplate.count(query, LaneDirectionOfTravelAssessment.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, LaneDirectionOfTravelAssessment.class, collectionName);
query.limit(limit);
return count;
}

public List<LaneDirectionOfTravelAssessment> find(Query query) {
return mongoTemplate.find(query, LaneDirectionOfTravelAssessment.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public interface StopLineStopAssessmentRepository extends DataLoader<StopLineSto
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<StopLineStopAssessment> find(Query query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import us.dot.its.jpo.conflictmonitor.monitor.models.assessments.StopLineStopAssessment;
import us.dot.its.jpo.ode.api.ConflictMonitorApiProperties;

Expand Down Expand Up @@ -55,6 +56,14 @@ public long getQueryResultCount(Query query) {
return mongoTemplate.count(query, StopLineStopAssessment.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, StopLineStopAssessment.class, collectionName);
query.limit(limit);
return count;
}

public List<StopLineStopAssessment> find(Query query) {
return mongoTemplate.find(query, StopLineStopAssessment.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public interface SignalStateEventAssessmentRepository extends DataLoader<StopLin

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<StopLinePassageAssessment> find(Query query);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public long getQueryResultCount(Query query) {
return mongoTemplate.count(query, StopLinePassageAssessment.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, StopLinePassageAssessment.class, collectionName);
query.limit(limit);
return count;
}

public List<StopLinePassageAssessment> find(Query query) {
return mongoTemplate.find(query, StopLinePassageAssessment.class, collectionName);
}
Expand Down
Loading

0 comments on commit adcb888

Please sign in to comment.