io.firebus.information.KnownAddressInformation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of firebus-core Show documentation
Show all versions of firebus-core Show documentation
Firebus core functionality
package io.firebus.information;
import io.firebus.Address;
public class KnownAddressInformation {
protected Address address;
protected long lastTry;
protected long nextTry;
protected int failedCount;
public KnownAddressInformation(Address a) {
address = a;
lastTry = 0;
nextTry = 0;
failedCount = 0;
}
public Address getAddress() {
return address;
}
public boolean isDueToTry() {
long now = System.currentTimeMillis();
return now > nextTry;
}
public void connectionFailed() {
failedCount++;
long now = System.currentTimeMillis();
if(failedCount <= 3) {
nextTry = now + 2000;
} else if(failedCount <= 15) {
nextTry = now + (2000 * (failedCount - 3));
} else {
nextTry = now + 30000;
}
}
public void connectionSucceeded() {
failedCount = 0;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy