Skip to content

Commit a6ccbf7

Browse files
committed
sleep after a failed database connection attempt
1 parent eafc3b1 commit a6ccbf7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

common-tools/clas-detector/src/main/java/org/jlab/detector/calib/utils/ConstantsManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jlab.detector.calib.utils;
22

3+
import java.lang.Thread;
34
import java.util.ArrayList;
45
import java.util.Arrays;
56
import java.util.HashMap;
@@ -19,6 +20,8 @@
1920
*/
2021
public class ConstantsManager {
2122

23+
public static final int DBERROR_SLEEP_SECONDS=3;
24+
2225
private static Logger LOGGER = Logger.getLogger(ConstantsManager.class.getName());
2326

2427
private DatabaseConstantsDescriptor defaultDescriptor = new DatabaseConstantsDescriptor();
@@ -116,6 +119,11 @@ private synchronized void loadConstantsForRun(int run) {
116119
LOGGER.log(Level.SEVERE,
117120
"[ConstantsManager] exceeded maximum requests " + requests + " for run " + run);
118121
}
122+
else if (requests > 1) {
123+
LOGGER.log(Level.SEVERE,"[ConstantsManager] sleeping a bit before trying again ...");
124+
try { Thread.sleep(DBERROR_SLEEP_SECONDS*1000); }
125+
catch (InterruptedException e) {}
126+
}
119127
}
120128

121129
LOGGER.log(Level.INFO, "[ConstantsManager] ---> loading table for run = " + run);

0 commit comments

Comments
 (0)