Committed by
Yuta Higuchi
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
Showing
1 changed file
with
15 additions
and
6 deletions
... | @@ -66,6 +66,10 @@ import com.google.common.collect.ImmutableList; | ... | @@ -66,6 +66,10 @@ import com.google.common.collect.ImmutableList; |
66 | @Service | 66 | @Service |
67 | public class DatabaseManager implements DatabaseService, DatabaseAdminService { | 67 | public class DatabaseManager implements DatabaseService, DatabaseAdminService { |
68 | 68 | ||
69 | + private static final int RETRY_MS = 500; | ||
70 | + | ||
71 | + private static final int ACTIVATE_MAX_RETRIES = 100; | ||
72 | + | ||
69 | private final Logger log = getLogger(getClass()); | 73 | private final Logger log = getLogger(getClass()); |
70 | 74 | ||
71 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 75 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
... | @@ -234,18 +238,23 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService { | ... | @@ -234,18 +238,23 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService { |
234 | } | 238 | } |
235 | } | 239 | } |
236 | 240 | ||
237 | - private void tryTableListing() { | 241 | + private void tryTableListing() throws InterruptedException { |
238 | int retries = 0; | 242 | int retries = 0; |
239 | do { | 243 | do { |
240 | try { | 244 | try { |
241 | listTables(); | 245 | listTables(); |
242 | return; | 246 | return; |
247 | + } catch (DatabaseException.Timeout e) { | ||
248 | + log.debug("Failed to listTables. Will retry...", e); | ||
243 | } catch (DatabaseException e) { | 249 | } catch (DatabaseException e) { |
244 | - if (retries == 10) { | 250 | + log.debug("Failed to listTables. Will retry later...", e); |
245 | - log.error("Failed to listTables after multiple attempts. Giving up.", e); | 251 | + Thread.sleep(RETRY_MS); |
246 | - throw e; | 252 | + } finally { |
247 | - } else { | 253 | + if (retries == ACTIVATE_MAX_RETRIES) { |
248 | - log.debug("Failed to listTables. Will retry...", e); | 254 | + log.error("Failed to listTables after multiple attempts. Giving up."); |
255 | + // Exiting hoping things will be fixed by the time | ||
256 | + // others start using the service | ||
257 | + return; | ||
249 | } | 258 | } |
250 | } | 259 | } |
251 | retries++; | 260 | retries++; | ... | ... |
-
Please register or login to post a comment