Merge branch 'master' into bug2823

This commit is contained in:
Udo Wessels
2021-09-20 16:49:01 +02:00
5 changed files with 32 additions and 22 deletions
@@ -26,6 +26,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
@@ -58,6 +59,10 @@ import com.sap.sse.util.LaxRedirectStrategyForAllRedirectResponseCodes;
public class IgtimiConnectionFactoryImpl implements IgtimiConnectionFactory {
private static final Logger logger = Logger.getLogger(IgtimiConnectionFactoryImpl.class.getName());
private static final int CONNECTION_REQUEST_TIMEOUT_MILLIS = 10000;
private static final int CONNECTION_TIMEOUT_MILLIS = 10000;
private final Map<Account, String> accessTokensByAccount;
private final Map<String, Account> accountsByEmail;
private final Map<Account, IgtimiConnection> connectionsByAccount;
@@ -518,7 +523,12 @@ public class IgtimiConnectionFactoryImpl implements IgtimiConnectionFactory {
}
public HttpClient getHttpClient() {
HttpClient client = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategyForAllRedirectResponseCodes()).build();
HttpClient client = HttpClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom()
.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT_MILLIS)
.setConnectTimeout(CONNECTION_TIMEOUT_MILLIS)
.build())
.setRedirectStrategy(new LaxRedirectStrategyForAllRedirectResponseCodes()).build();
return client;
}
@@ -82,13 +82,11 @@ CREATE TABLE SAILING."RaceStats" (
"elapsedTimeInSeconds" DOUBLE,
"avgCrossTrackErrorInMeters" DOUBLE,
"absoluteAvgCrossTrackErrorInMeters" DOUBLE,
"numberOfTacks" INTEGER,
"numberOfGybes" INTEGER,
"numberOfPenaltyCircles" INTEGER,
"startDelayInSeconds" DOUBLE,
"distanceFromStartLineInMetersAtStart" DOUBLE,
"speedWhenCrossingStartLineInKnots" DOUBLE,
"startTack" NVARCHAR(20),
"rank90sAfterStart" INTEGER,
PRIMARY KEY ("race", "regatta", "competitorId"),
FOREIGN KEY ("competitorId") REFERENCES SAILING."Competitor" ("id"),
FOREIGN KEY ("race", "regatta") REFERENCES SAILING."Race" ("name", "regatta")
@@ -6,18 +6,19 @@ import java.util.NavigableSet;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.base.Waypoint;
import com.sap.sailing.domain.common.ManeuverType;
import com.sap.sailing.domain.common.NoWindException;
import com.sap.sailing.domain.common.Tack;
import com.sap.sailing.domain.tracking.Maneuver;
import com.sap.sailing.domain.tracking.MarkPassing;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sailing.hanaexport.jaxrs.api.InsertRaceStatsStatement.TrackedRaceWithCompetitorAndStartWaypoint;
import com.sap.sse.common.Duration;
import com.sap.sse.common.Speed;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
public class InsertRaceStatsStatement extends AbstractPreparedInsertStatement<TrackedRaceWithCompetitorAndStartWaypoint> {
private static final Duration DURATION_AFTER_START_TO_DECIDE_START_WINNER = Duration.ONE_SECOND.times(90);
static class TrackedRaceWithCompetitorAndStartWaypoint {
private final TimePoint now;
private final Waypoint startWaypoint;
@@ -44,14 +45,13 @@ public class InsertRaceStatsStatement extends AbstractPreparedInsertStatement<Tr
return trackedRace;
}
}
protected InsertRaceStatsStatement(Connection connection) throws SQLException {
super(connection.prepareStatement(
"INSERT INTO SAILING.\"RaceStats\" (\"race\", \"regatta\", \"competitorId\", \"rankOneBased\", \"distanceSailedInMeters\", \"elapsedTimeInSeconds\", "+
"\"avgCrossTrackErrorInMeters\", \"absoluteAvgCrossTrackErrorInMeters\", \"numberOfTacks\", "+
"\"numberOfGybes\", \"numberOfPenaltyCircles\", \"startDelayInSeconds\", \"distanceFromStartLineInMetersAtStart\", "+
"\"speedWhenCrossingStartLineInKnots\", \"startTack\") "+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
"\"avgCrossTrackErrorInMeters\", \"absoluteAvgCrossTrackErrorInMeters\", \"startDelayInSeconds\", \"distanceFromStartLineInMetersAtStart\", "+
"\"speedWhenCrossingStartLineInKnots\", \"startTack\", \"rank90sAfterStart\") "+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
}
@Override
@@ -67,10 +67,6 @@ public class InsertRaceStatsStatement extends AbstractPreparedInsertStatement<Tr
setDouble(6, secondsOr0ForNull(trackedRace.getTimeSailedSinceRaceStart(competitor, now)));
setDouble(7, metersOr0ForNull(trackedRace.getAverageSignedCrossTrackError(competitor, now, /* waitForLatest */ false)));
setDouble(8, metersOr0ForNull(trackedRace.getAverageAbsoluteCrossTrackError(competitor, now, /* waitForLatest */ false)));
final Iterable<Maneuver> maneuvers = trackedRace.getManeuvers(competitor, /* waitForLatest */ false);
getPreparedStatement().setInt(9, Util.size(Util.filter(maneuvers, m->m.getType() == ManeuverType.TACK)));
getPreparedStatement().setInt(10, Util.size(Util.filter(maneuvers, m->m.getType() == ManeuverType.JIBE)));
getPreparedStatement().setInt(11, Util.size(Util.filter(maneuvers, m->m.getType() == ManeuverType.PENALTY_CIRCLE)));
final TimePoint startOfRace = trackedRace.getStartOfRace();
final double startDelay;
Tack startTack;
@@ -98,15 +94,16 @@ public class InsertRaceStatsStatement extends AbstractPreparedInsertStatement<Tr
startDelay = 0;
startTack = null;
}
setDouble(12, startDelay);
setDouble(9, startDelay);
if (startOfRace != null) {
setDouble(13, metersOr0ForNull(trackedRace.getDistanceToStartLine(competitor, startOfRace)));
setDouble(10, metersOr0ForNull(trackedRace.getDistanceToStartLine(competitor, startOfRace)));
final Speed speedWhenCrossingStartLine = trackedRace.getSpeedWhenCrossingStartLine(competitor);
setDouble(14, speedWhenCrossingStartLine==null?0:speedWhenCrossingStartLine.getKnots());
getPreparedStatement().setString(15, startTack==null?null:startTack.name());
setDouble(11, speedWhenCrossingStartLine==null?0:speedWhenCrossingStartLine.getKnots());
getPreparedStatement().setString(12, startTack==null?null:startTack.name());
getPreparedStatement().setInt(13, trackedRace.getRank(competitor, startOfRace.plus(DURATION_AFTER_START_TO_DECIDE_START_WINNER)));
} else {
setDouble(13, 0);
setDouble(14, 0);
setDouble(10, 0);
setDouble(11, 0);
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ source.. = src/,\
output.. = bin/
bin.includes = META-INF/,\
.,\
./.well-known/,\
.well-known/,\
WEB-INF/web.xml,\
index.html,\
release_notes.css,\
@@ -23,6 +23,11 @@
<div class="mainContent">
<h2 class="releaseHeadline">Release Notes - Administration Console</h2>
<div class="innerContent">
<h2 class="articleSubheadline">September 2021</h2>
<ul class="bulletList">
<li>Let Igtimi connections that search devices while holding locks time out after 10s.
This avoids rare deadlock issues in case the Igtimi servers may not deliver an answer.</li>
</ul>
<h2 class="articleSubheadline">August 2021</h2>
<ul class="bulletList">
<li>Added boat classes iQFOil Men/Women/Youth</li>