Skip to content

Commit

Permalink
traffic-a22-forecast: add logging, if traffic data is empty/invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Oct 3, 2023
1 parent 4a25d9a commit ec8b9cc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
@Configuration
public class A22ClientConfig {

@Value("${a22.url}")
private String url;
@Value("${a22.url}")
private String url;

@Value("${a22.username}")
private String userName;
@Value("${a22.username}")
private String userName;

@Value("${a22.password}")
private String password;
@Value("${a22.password}")
private String password;

@Bean(name = "a22Client")
WebClient webClient() {
return WebClient.builder()
.defaultHeaders(header -> header.setBasicAuth(userName, password))
.baseUrl(url)
// increase max buffer memory size because /GetCoordinate response is too big
// for default max buffer size of 262144 bytes
.exchangeStrategies(ExchangeStrategies.builder().codecs(
clientCodecConfigurer -> clientCodecConfigurer.defaultCodecs()
.maxInMemorySize(500000))
.build())
.build();
}
@Bean(name = "a22Client")
WebClient webClient() {
return WebClient.builder()
.defaultHeaders(header -> header.setBasicAuth(userName, password))
.baseUrl(url)
// increase max buffer memory size because /GetCoordinate response is too big
// for default max buffer size of 262144 bytes
.exchangeStrategies(ExchangeStrategies.builder().codecs(
clientCodecConfigurer -> clientCodecConfigurer.defaultCodecs()
.maxInMemorySize(500000))
.build())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opendatahub.traffic.a22.forecast.JobScheduler;
import com.opendatahub.traffic.a22.forecast.dto.ForecastDto;
import com.opendatahub.traffic.a22.forecast.dto.ForecastDto.TrafficData;
import com.opendatahub.traffic.a22.forecast.dto.ForecastDto.TrafficDataLine;
Expand All @@ -17,13 +21,23 @@
// example 'Bolzano Sud' -> '09-2023' -> 0,1,0,3
public class ForecastMap extends HashMap<String, Map<Long, TrafficValues>> {

private static final Logger LOG = LoggerFactory.getLogger(ForecastMap.class);

public void add(ForecastDto dto) {
for (TrafficDataLine line : dto.data.trafficDataLines) {
if (line.isValid())
for (TrafficData data : line.data) {
putValues(data.south, data.date, "Sud");
putValues(data.north, data.date, "Nord");
}
else {
if (line.data.isEmpty())
LOG.info("Data is empty. Skipping...");
else
LOG.info("Not valid data for date {}/{}. Skipping...", line.data.get(0).month,
line.data.get(0).year);

}
}
}

Expand Down

0 comments on commit ec8b9cc

Please sign in to comment.