Skip to content

Commit

Permalink
feat(sumo): support sumo 1.21.0 (eclipse#424)
Browse files Browse the repository at this point in the history
* ci: use SUMO 1.21.0 for testing
* feat(sumo): support SUMO 1.21.0

Added hint, that SUMO_HOME/bin must be present in the PATH variable. Pre-loading some libraries is not required anymore then.
  • Loading branch information
kschrab authored and FunKuchen committed Nov 12, 2024
1 parent 5783b64 commit 3337498
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ kind: Pod
spec:
containers:
- name: maven-sumo
image: eclipsemosaic/mosaic-ci:jdk17-sumo-1.20.0
image: eclipsemosaic/mosaic-ci:jdk17-sumo-1.21.0
command:
- cat
tty: true
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Additional simulators and assessment features are provided by [Fraunhofer FOKUS]

## Related Repositories

* [Eclipse SUMO](https://github.com/eclipse/sumo) is coupled directly using the TraCI interface. We recommend using the SUMO release `1.20.0`.
* [Eclipse SUMO](https://github.com/eclipse/sumo) is coupled directly using the TraCI interface. We recommend using the SUMO release `1.21.0`.
* The coupling to [ns-3](https://www.nsnam.org) is realized by a federate implementation which can be found [in our MOSAIC Addons repository](https://github.com/mosaic-addons/ns3-federate).
We currently support ns-3 version `3.36.1`.
* The coupling to [OMNeT++](https://omnetpp.org) is implemented in a very similar manner. The corresponding federate implementation can be found [in our MOSAIC Addons repository](https://github.com/mosaic-addons/omnetpp-federate).
Expand All @@ -73,7 +73,7 @@ For a successful build you need the following software to be installed:

* **Maven 3.1.x** or higher.
* **Java 17**, or 21 - We recommend using the [Adoptium OpenJDK (aka Eclipse Temurin)](https://adoptium.net/?variant=openjdk17).
* **SUMO 1.20.0** - Older versions > 1.2.0 are most probably supported, but not tested. The environment variable `SUMO_HOME` should be configured properly.
* **SUMO 1.21.0** - Older versions > 1.2.0 are most probably supported, but not tested. The environment variable `SUMO_HOME` should be configured properly.

## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class LibSumoAmbassador extends SumoAmbassador {

private static final String VALID_LIBSUMO_VERSIONS = "1\\.(19|20)\\.";
private static final String VALID_LIBSUMO_VERSIONS = "1\\.(19|20|21)\\.";

public LibSumoAmbassador(AmbassadorParameter ambassadorParameter) {
super(ambassadorParameter);
Expand Down Expand Up @@ -71,34 +71,30 @@ protected void initSumoConnection() throws InternalFederateException {
}

if (new File(libsumoLibrary).exists()) {
// Workaround based on suggestions made in https://github.com/eclipse/sumo/issues/12605
if (operatingSystem == CLocalHost.OperatingSystem.WINDOWS) {
loadQuiet(getFromSumoHome("iconv-2.dll"));
loadQuiet(getFromSumoHome("intl-8.dll"));
loadQuiet(getFromSumoHome("proj_9_0.dll"));
try {
System.load(libsumoLibrary);
} catch (UnsatisfiedLinkError e) {
throw new InternalFederateException("""
The required libsumojni library could be found, but not loaded due to missing dependencies.
Make sure your PATH variable contains the entry "$SUMO_HOME/bin".
""");
}

System.load(libsumoLibrary);

if (incorrectLibSumoVersion()) {
throw new InternalFederateException(
"The loaded Libsumo library at " + libsumoLibrary + " is not compatible with this ambassador. "
+ "Valid versions are: " + VALID_LIBSUMO_VERSIONS);
throw new InternalFederateException("""
The loaded libsumojni library at %s is not compatible with this ambassador. Valid versions are: %s
""".formatted(libsumoLibrary, VALID_LIBSUMO_VERSIONS));
}
} else {
try {
// Workaround based on suggestions made in https://github.com/eclipse/sumo/issues/12605
if (operatingSystem == CLocalHost.OperatingSystem.WINDOWS) {
loadLibraryQuiet("iconv-2");
loadLibraryQuiet("intl-8");
loadLibraryQuiet("proj_9_0");
}

// if no file found, try to load libsumo it directly from java.library.path
System.loadLibrary("libsumojni");
} catch (Throwable e) {
throw new InternalFederateException("The required libsumojni library could not be found in " + libsumoLibrary + ". "
+ "Make sure SUMO_HOME is set properly and that your SUMO installation contains the libsumojni library.");
throw new InternalFederateException("""
The required libsumojni library could not be found in %s.
Make sure SUMO_HOME is set properly and that your SUMO installation contains the libsumojni library.
Furthermore, your PATH variable should contain the entry $SUMO_HOME/bin.
""".formatted(libsumoLibrary));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public enum SumoVersion {
SUMO_1_18_x("1.18.*", TraciVersion.API_20),
SUMO_1_19_x("1.19.*", TraciVersion.API_21),
SUMO_1_20_x("1.20.*", TraciVersion.API_21),
SUMO_1_21_x("1.21.*", TraciVersion.API_21),

/**
* the lowest version supported by this client.
Expand All @@ -54,7 +55,7 @@ public enum SumoVersion {
/**
* the highest version supported by this client.
*/
HIGHEST(SUMO_1_20_x.sumoVersion, SUMO_1_20_x.traciVersion);
HIGHEST(SUMO_1_21_x.sumoVersion, SUMO_1_21_x.traciVersion);

private final String sumoVersion;
private final TraciVersion traciVersion;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<version.slf4j>2.0.12</version.slf4j><!-- 2.0.12 is approved #13344 -->
<version.sqlite-jdbc>3.42.0.0</version.sqlite-jdbc><!-- 3.42.0.0 is approved in #9089 -->
<!-- note, when upgrading, the field LibSumoAmbassador#VALID_LIBSUMO_VERSIONS needs to be changed too -->
<version.libsumo>1.20.0</version.libsumo>
<version.libsumo>1.21.0</version.libsumo>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion test/ci/ci-image-mvn-sumo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ WORKDIR /home/jenkins
RUN apt-get update && \
apt-get install -y --allow-unauthenticated software-properties-common && \
# adjust this output string to bypass potential caches
echo "Installing SUMO 1.20.0" && \
echo "Installing SUMO 1.21.0" && \
add-apt-repository ppa:sumo/stable && \
apt-get install -y sumo
4 changes: 2 additions & 2 deletions test/ci/ci-image-mvn-sumo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ build and tag the docker image with the latest SUMO version. This image should b
and available in the PPA.

```shell script
docker build . -t eclipsemosaic/mosaic-ci:jdk17-sumo-1.20.0
docker build . -t eclipsemosaic/mosaic-ci:jdk17-sumo-1.21.0
docker login
docker push eclipsemosaic/mosaic-ci:jdk17-sumo-1.20.0
docker push eclipsemosaic/mosaic-ci:jdk17-sumo-1.21.0
```

Afterwards, the image should be available here: https://hub.docker.com/r/eclipsemosaic/mosaic-ci/tags
Expand Down

0 comments on commit 3337498

Please sign in to comment.