commit | 71582edbe7b2dba19128a7e7a55a2218291521f5 | [log] [tgz] |
---|---|---|
author | Madan Jampani <madan@onlab.us> | Tue Nov 18 10:06:01 2014 -0800 |
committer | Pavlin Radoslavov <pavlin@onlab.us> | Wed Nov 19 15:39:30 2014 -0800 |
tree | a2d68944a312c3ace6cc33139c2df465f6cb5c20 | |
parent | 78bcbc1227e65fcba618852650d3ac687fa2a938 [diff] [blame] |
1. DatabaseManager activate will attempt to listTables to ensure store is in good shape. 2. lock and tryLock can now throw InterruptedExceptions. Change-Id: Ifa766ad441f677a4071b68d8f6caa564cf320869 Change-Id: I318ff762a96b261737831f6bd7c200b384c638e9 Change-Id: I0f509703520b3187931fa3669cd8213a91e85c96
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 37e75cf..af3f6ac 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
@@ -179,6 +179,11 @@ } client.waitForLeader(); + + // Try and list the tables to verify database manager is + // in a state where it can serve requests. + tryTableListing(); + log.info("Started."); } @@ -214,6 +219,24 @@ } } + private void tryTableListing() { + int retries = 0; + do { + try { + listTables(); + return; + } 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); + retries++; + } + } + } while (true); + } + @Override public boolean createTable(String name) { return client.createTable(name);