Java Code Examples for org.apache.hadoop.hbase.HConstants#RETRY_BACKOFF
The following examples show how to use
org.apache.hadoop.hbase.HConstants#RETRY_BACKOFF .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReplicationUtils.java From hbase with Apache License 2.0 | 5 votes |
/** * Get the adaptive timeout value when performing a retry */ public static int getAdaptiveTimeout(final int initialValue, final int retries) { int ntries = retries; if (ntries >= HConstants.RETRY_BACKOFF.length) { ntries = HConstants.RETRY_BACKOFF.length - 1; } if (ntries < 0) { ntries = 0; } return initialValue * HConstants.RETRY_BACKOFF[ntries]; }
Example 2
Source File: ConnectionUtils.java From hbase with Apache License 2.0 | 5 votes |
/** * Calculate pause time. Built on {@link HConstants#RETRY_BACKOFF}. * @param pause time to pause * @param tries amount of tries * @return How long to wait after <code>tries</code> retries */ public static long getPauseTime(final long pause, final int tries) { int ntries = tries; if (ntries >= HConstants.RETRY_BACKOFF.length) { ntries = HConstants.RETRY_BACKOFF.length - 1; } if (ntries < 0) { ntries = 0; } long normalPause = pause * HConstants.RETRY_BACKOFF[ntries]; // 1% possible jitter long jitter = (long) (normalPause * ThreadLocalRandom.current().nextFloat() * 0.01f); return normalPause + jitter; }