Mercurial > hg > blitz_condensed
view src/org/dancres/blitz/disk/BackoffGenerator.java @ 33:0b9265358617
Added tag 2.1.1 for changeset a77f0a9ed93c
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 12 Jun 2010 10:52:10 +0100 |
parents | 3dc0c5604566 |
children |
line wrap: on
line source
package org.dancres.blitz.disk; import java.util.Random; import java.util.logging.Level; import net.jini.config.ConfigurationException; import org.dancres.blitz.config.ConfigurationFactory; public class BackoffGenerator { private static final String LOAD_BACKOFF = "loadBackoff"; private static int BACKOFF_BASE; private static int BACKOFF_JITTER; static { try { int[] myBackoff = (int[]) ConfigurationFactory.getEntry(LOAD_BACKOFF, int[].class, new int[]{50, 50}); BACKOFF_BASE = myBackoff[0]; BACKOFF_JITTER = myBackoff[1]; } catch (ConfigurationException aCE) { RetryingUpdate.theLogger.log(Level.SEVERE, "Failed to load backoff config", aCE); } } private static Random theBackoffGenerator = new Random(); public static void pause() { try { Thread.sleep((long) (BACKOFF_BASE + theBackoffGenerator.nextInt(BACKOFF_JITTER))); } catch (InterruptedException anIE) { } } }