Skip to content

Commit fc0de48

Browse files
authored
Merge pull request #32 from HSLdevcom/develop
1.0.4
2 parents 612e104 + 7b88c41 commit fc0de48

File tree

9 files changed

+95
-178
lines changed

9 files changed

+95
-178
lines changed

.github/workflows/test-and-build.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Test and create Docker image
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Set up JDK 1.8
11+
uses: actions/setup-java@v1
12+
with:
13+
java-version: 1.8
14+
- name: Cache Maven packages
15+
uses: actions/cache@v2
16+
with:
17+
path: ~/.m2
18+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
19+
restore-keys: ${{ runner.os }}-m2
20+
- name: Build with Maven
21+
run: mvn --file pom.xml clean install
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
- name: Upload .jar file
25+
uses: actions/upload-artifact@v2
26+
with:
27+
name: transitdata-pubtrans-source.jar
28+
path: target/transitdata-pubtrans-source.jar
29+
build-develop-docker-image:
30+
needs: test
31+
runs-on: ubuntu-latest
32+
# Run only on develop branch
33+
if: github.ref == 'refs/heads/develop'
34+
steps:
35+
- uses: actions/checkout@v2
36+
- name: Download .jar file
37+
uses: actions/download-artifact@v2
38+
with:
39+
name: transitdata-pubtrans-source.jar
40+
path: target
41+
- name: Build and publish develop Docker image
42+
uses: elgohr/Publish-Docker-Github-Action@master
43+
with:
44+
name: hsldevcom/transitdata-pubtrans-source
45+
username: ${{ secrets.DOCKER_USERNAME }}
46+
password: ${{ secrets.DOCKER_PASSWORD }}
47+
tags: develop
48+
build-release-docker-image:
49+
needs: test
50+
runs-on: ubuntu-latest
51+
# Run only for tagged commits
52+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
53+
steps:
54+
- uses: actions/checkout@v2
55+
- name: Download .jar file
56+
uses: actions/download-artifact@v2
57+
with:
58+
name: transitdata-pubtrans-source.jar
59+
path: target
60+
- name: Build and publish release Docker image
61+
uses: elgohr/Publish-Docker-Github-Action@master
62+
with:
63+
name: hsldevcom/transitdata-pubtrans-source
64+
username: ${{ secrets.DOCKER_USERNAME }}
65+
password: ${{ secrets.DOCKER_PASSWORD }}
66+
tag_semver: true

.travis.yml

-49
This file was deleted.

.travis/check_semver

-34
This file was deleted.

.travis/docker_login_tag_push

-41
This file was deleted.

.travis/docker_login_tag_semver_push

-38
This file was deleted.

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ FROM openjdk:8-jre-slim
22
#Install curl for health check
33
RUN apt-get update && apt-get install -y --no-install-recommends curl
44
ADD target/transitdata-pubtrans-source.jar /usr/app/transitdata-pubtrans-source.jar
5-
ENTRYPOINT ["java", "-jar", "/usr/app/transitdata-pubtrans-source.jar"]
5+
COPY start-application.sh /
6+
RUN chmod +x /start-application.sh
7+
CMD ["/start-application.sh"]

pom.xml

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>fi.hsl.transitdata</groupId>
44
<artifactId>transitdata-pubtrans-source</artifactId>
5-
<version>1.0.3</version>
5+
<version>1.0.4</version>
66
<packaging>jar</packaging>
77

88
<repositories>
9-
<repository>
10-
<id>bintray</id>
11-
<name>bintray</name>
12-
<url>https://dl.bintray.com/hsldevcom/maven</url>
13-
</repository>
9+
<repository>
10+
<id>github</id>
11+
<url>https://maven.pkg.github.com/HSLdevcom/*</url>
12+
</repository>
1413
</repositories>
1514

1615
<properties>
1716
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1817
<maven.compiler.source>1.8</maven.compiler.source>
1918
<maven.compiler.target>1.8</maven.compiler.target>
20-
<common.version>1.3.5</common.version>
19+
<common.version>1.3.24</common.version>
2120
</properties>
2221

2322
<dependencies>

src/main/java/fi/hsl/transitdata/pulsarpubtransconnect/PubtransTableHandler.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ public Queue<TypedMessageBuilder<byte[]>> handleResultSet(ResultSet resultSet) t
8585

8686
final String key = resultSet.getString("IsOnDatedVehicleJourneyId") + resultSet.getString("JourneyPatternSequenceNumber");
8787
final long dvjId = common.getIsOnDatedVehicleJourneyId();
88-
final long jppId = common.getIsTargetedAtJourneyPatternPointGid();
88+
final long scheduledJppId = common.getIsTimetabledAtJourneyPatternPointGid();
89+
final long targetedJppId = common.getIsTargetedAtJourneyPatternPointGid();
8990

90-
Optional<PubtransTableProtos.DOITripInfo> maybeTripInfo = getTripInfo(dvjId, jppId);
91+
Optional<PubtransTableProtos.DOITripInfo> maybeTripInfo = getTripInfo(dvjId, scheduledJppId, targetedJppId);
9192
if (!maybeTripInfo.isPresent()) {
92-
log.warn("Could not find valid DOITripInfo from Redis for dvjId {}, jppId {}. Ignoring this update ", dvjId, jppId);
93+
log.warn("Could not find valid DOITripInfo from Redis for dvjId {}, timetabledJppId {}, targetedJppId {}. Ignoring this update ", dvjId, scheduledJppId, targetedJppId);
9394
}
9495
else {
9596
final byte[] data = createPayload(resultSet, common, maybeTripInfo.get());
@@ -156,14 +157,18 @@ private Optional<Map<String, String>> getTripInfoFields(long dvjId) {
156157
}
157158
}
158159

159-
protected Optional<PubtransTableProtos.DOITripInfo> getTripInfo(long dvjId, long jppId) {
160+
protected Optional<PubtransTableProtos.DOITripInfo> getTripInfo(long dvjId, long scheduledJppId, long targetedJppId) {
160161
try {
161-
Optional<String> maybeStopId = getStopId(jppId);
162+
Optional<String> maybeScheduledStopId = getStopId(scheduledJppId);
163+
Optional<String> maybeTargetedStopId = getStopId(targetedJppId);
162164
Optional<Map<String, String>> maybeTripInfoMap = getTripInfoFields(dvjId);
163165

164-
if (maybeStopId.isPresent() && maybeTripInfoMap.isPresent()) {
166+
if (maybeScheduledStopId.isPresent() && maybeTripInfoMap.isPresent()) {
165167
PubtransTableProtos.DOITripInfo.Builder builder = PubtransTableProtos.DOITripInfo.newBuilder();
166-
builder.setStopId(maybeStopId.get());
168+
169+
builder.setStopId(maybeScheduledStopId.get());
170+
maybeTargetedStopId.ifPresent(builder::setTargetedStopId);
171+
167172
maybeTripInfoMap.ifPresent(map -> {
168173
if (map.containsKey(TransitdataProperties.KEY_DIRECTION))
169174
builder.setDirectionId(Integer.parseInt(map.get(TransitdataProperties.KEY_DIRECTION)));
@@ -178,7 +183,7 @@ protected Optional<PubtransTableProtos.DOITripInfo> getTripInfo(long dvjId, long
178183
return Optional.of(builder.build());
179184
}
180185
else {
181-
log.error("Failed to get data from Redis for dvjId {}, jppId {}", dvjId, jppId);
186+
log.error("Failed to get data from Redis for dvjId {}, timetabledJppId {}", dvjId, scheduledJppId);
182187
return Optional.empty();
183188
}
184189
}

start-application.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
if [[ "${DEBUG_ENABLED}" = true ]]; then
4+
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar /usr/app/transitdata-pubtrans-source.jar
5+
else
6+
java -jar /usr/app/transitdata-pubtrans-source.jar
7+
fi

0 commit comments

Comments
 (0)