DatabaseManager: workaround for larger ONOS cluster
- sleep before retrying if listTable failed due to non-Timeout error
- do not throw exception even if retry max reached
Change-Id: I5764894f0830c11b07d63aefbd0bbb10fe41af74
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
index dd0b379..2c0ff14 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
@@ -66,6 +66,10 @@
@Service
public class DatabaseManager implements DatabaseService, DatabaseAdminService {
+ private static final int RETRY_MS = 500;
+
+ private static final int ACTIVATE_MAX_RETRIES = 100;
+
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -234,18 +238,23 @@
}
}
- private void tryTableListing() {
+ private void tryTableListing() throws InterruptedException {
int retries = 0;
do {
try {
listTables();
return;
+ } catch (DatabaseException.Timeout e) {
+ log.debug("Failed to listTables. Will retry...", e);
} catch (DatabaseException e) {
- if (retries == 10) {
- log.error("Failed to listTables after multiple attempts. Giving up.", e);
- throw e;
- } else {
- log.debug("Failed to listTables. Will retry...", e);
+ log.debug("Failed to listTables. Will retry later...", e);
+ Thread.sleep(RETRY_MS);
+ } finally {
+ if (retries == ACTIVATE_MAX_RETRIES) {
+ log.error("Failed to listTables after multiple attempts. Giving up.");
+ // Exiting hoping things will be fixed by the time
+ // others start using the service
+ return;
}
}
retries++;