mirror of https://github.com/zlatinb/muwire
delete history of attempts when threshold reached, log profile probabilities
parent
cc8e6e312b
commit
ae45570005
|
@ -119,7 +119,9 @@ class H2HostCache extends HostCache {
|
|||
")")
|
||||
def newProfile = sql.firstRow("select * from HOST_PROFILES where DESTINATION=${d.toBase64()}")
|
||||
profiles.put(d, new HostMCProfile(newProfile))
|
||||
log.fine("profile updated")
|
||||
log.fine("profile updated ${d.toBase32()} ${profiles.get(d)}")
|
||||
|
||||
sql.execute("delete from HOST_PROFILES where DESTINATION=${d.toBase64()}")
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -244,6 +246,7 @@ class H2HostCache extends HostCache {
|
|||
profile = new HostMCProfile(fromDB)
|
||||
profiles.put(dest, profile)
|
||||
allHosts.add(dest)
|
||||
log.fine("Loaded profile for ${dest.toBase32()} $profile")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ class HostMCProfile {
|
|||
private final Probability[] S
|
||||
private final Probability[] R
|
||||
private final Probability[] F
|
||||
|
||||
private final String toString
|
||||
|
||||
// start with S
|
||||
ConnectionAttemptStatus state = ConnectionAttemptStatus.SUCCESSFUL
|
||||
|
@ -39,6 +41,16 @@ class HostMCProfile {
|
|||
F[1] = new Probability(0.01, ConnectionAttemptStatus.REJECTED)
|
||||
F[2] = new Probability(0.01, ConnectionAttemptStatus.FAILED)
|
||||
|
||||
toString = "SS:${S[0].probability}," +
|
||||
"SR:${S[1].probability},"+
|
||||
"SF:${S[2].probability},"+
|
||||
"RS:${R[0].probability},"+
|
||||
"RR:${R[1].probability},"+
|
||||
"RF:${R[2].probability},"+
|
||||
"FS:${F[0].probability},"+
|
||||
"FR:${F[1].probability},"+
|
||||
"FF:${F[2].probability}"+
|
||||
|
||||
Arrays.sort(S)
|
||||
S[1].probability += S[0].probability
|
||||
S[2].probability += S[1].probability
|
||||
|
@ -91,6 +103,16 @@ class HostMCProfile {
|
|||
bd.setScale(SCALE, MODE)
|
||||
F[2] = new Probability(bd, ConnectionAttemptStatus.FAILED)
|
||||
|
||||
toString = "SS:${S[0].probability}," +
|
||||
"SR:${S[1].probability},"+
|
||||
"SF:${S[2].probability},"+
|
||||
"RS:${R[0].probability},"+
|
||||
"RR:${R[1].probability},"+
|
||||
"RF:${R[2].probability},"+
|
||||
"FS:${F[0].probability},"+
|
||||
"FR:${F[1].probability},"+
|
||||
"FF:${F[2].probability}"
|
||||
|
||||
Arrays.sort(S)
|
||||
S[1].probability += S[0].probability
|
||||
S[2].probability += S[1].probability
|
||||
|
@ -131,6 +153,11 @@ class HostMCProfile {
|
|||
return state
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
toString
|
||||
}
|
||||
|
||||
private static class Probability implements Comparable<Probability> {
|
||||
|
||||
private BigDecimal probability
|
||||
|
@ -148,5 +175,6 @@ class HostMCProfile {
|
|||
return -1
|
||||
return 1
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue