Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/disk/BackoffGenerator.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.disk; | |
2 | |
3 import java.util.Random; | |
4 | |
5 import java.util.logging.Level; | |
6 | |
7 import net.jini.config.ConfigurationException; | |
8 | |
9 import org.dancres.blitz.config.ConfigurationFactory; | |
10 | |
11 public class BackoffGenerator { | |
12 private static final String LOAD_BACKOFF = "loadBackoff"; | |
13 | |
14 private static int BACKOFF_BASE; | |
15 private static int BACKOFF_JITTER; | |
16 | |
17 static { | |
18 try { | |
19 int[] myBackoff = | |
20 (int[]) ConfigurationFactory.getEntry(LOAD_BACKOFF, | |
21 int[].class, | |
22 new int[]{50, 50}); | |
23 | |
24 BACKOFF_BASE = myBackoff[0]; | |
25 BACKOFF_JITTER = myBackoff[1]; | |
26 } catch (ConfigurationException aCE) { | |
27 RetryingUpdate.theLogger.log(Level.SEVERE, | |
28 "Failed to load backoff config", aCE); | |
29 } | |
30 } | |
31 | |
32 private static Random theBackoffGenerator = new Random(); | |
33 | |
34 public static void pause() { | |
35 try { | |
36 Thread.sleep((long) (BACKOFF_BASE + | |
37 theBackoffGenerator.nextInt(BACKOFF_JITTER))); | |
38 } catch (InterruptedException anIE) { | |
39 } | |
40 } | |
41 } |