reinit MC with last observed state

pull/53/head
Zlatin Balevsky 2020-10-24 11:32:14 +01:00
parent 8a4a2a75c4
commit 340ff339b3
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 6 additions and 4 deletions

View File

@ -177,7 +177,7 @@ class H2HostCache extends HostCache {
"'${String.format(Locale.US, "%.6f",ffd)}'" +
")")
def newProfile = sql.firstRow("select * from HOST_PROFILES where DESTINATION=${d.toBase64()}")
profiles.put(d, new HostMCProfile(newProfile))
profiles.put(d, new HostMCProfile(newProfile, status))
log.fine("profile updated ${d.toBase32()} ${profiles.get(d)}")
sql.execute("delete from HOST_ATTEMPTS where DESTINATION=${d.toBase64()} and TSTAMP not in "+
@ -313,7 +313,7 @@ class H2HostCache extends HostCache {
def fromDB = sql.firstRow("select * from HOST_PROFILES where DESTINATION=${dest.toBase64()}")
def profile = new HostMCProfile()
if (fromDB != null)
profile = new HostMCProfile(fromDB)
profile = new HostMCProfile(fromDB, ConnectionAttemptStatus.SUCCESSFUL)
profiles.put(dest, profile)
allHosts.add(dest)
log.fine("Loaded profile for ${dest.toBase32()} $profile")

View File

@ -35,7 +35,7 @@ class HostMCProfile {
private final String toString
// start with S
ConnectionAttemptStatus state = ConnectionAttemptStatus.SUCCESSFUL
ConnectionAttemptStatus state
boolean hasHistory
boolean successfulAttempt
@ -45,6 +45,7 @@ class HostMCProfile {
*/
HostMCProfile() {
this.hasHistory = false
this.state = ConnectionAttemptStatus.SUCCESSFUL
S = new Probability[3]
R = new Probability[3]
F = new Probability[3]
@ -84,7 +85,8 @@ class HostMCProfile {
/**
* historical predictor loaded from database
*/
HostMCProfile(def fromDB) {
HostMCProfile(def fromDB, ConnectionAttemptStatus currentStatus) {
state = currentStatus
hasHistory = true
S = new Probability[3]