Add method to set reordering window for static keys.

This commit is contained in:
akwizgran
2019-04-17 09:58:36 +01:00
parent f72ff9f812
commit 6b24eeb84c
2 changed files with 32 additions and 0 deletions

View File

@@ -691,6 +691,14 @@ interface Database<T> {
void setReorderingWindow(T txn, TransportKeySetId k, TransportId t,
long timePeriod, long base, byte[] bitmap) throws DbException;
/**
* Sets the reordering window for the given static key set and transport in
* the given time period.
*/
void setStaticReorderingWindow(T txn, StaticTransportKeySetId k,
TransportId t, long timePeriod, long base, byte[] bitmap)
throws DbException;
/**
* Marks the given transport keys as usable for outgoing streams.
*/

View File

@@ -3222,6 +3222,30 @@ abstract class JdbcDatabase implements Database<Connection> {
}
}
@Override
public void setStaticReorderingWindow(Connection txn,
StaticTransportKeySetId k, TransportId t, long timePeriod,
long base, byte[] bitmap) throws DbException {
PreparedStatement ps = null;
try {
String sql = "UPDATE incomingStaticKeys SET base = ?, bitmap = ?"
+ " WHERE transportId = ? AND keySetId = ?"
+ " AND timePeriod = ?";
ps = txn.prepareStatement(sql);
ps.setLong(1, base);
ps.setBytes(2, bitmap);
ps.setString(3, t.getString());
ps.setInt(4, k.getInt());
ps.setLong(5, timePeriod);
int affected = ps.executeUpdate();
if (affected < 0 || affected > 1) throw new DbStateException();
ps.close();
} catch (SQLException e) {
tryToClose(ps, LOG, WARNING);
throw new DbException(e);
}
}
@Override
public void setTransportKeysActive(Connection txn, TransportId t,
TransportKeySetId k) throws DbException {