Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a ceiling on ExponentialBackoffRetry
Trying to avoid pulling in a newer netflix curator Adds lein-junit and junit dependencies with test. Adds new configurable maximum ceiling for the retry interval, defaults to 30s.
- Loading branch information
Derek Dagit
committed
Feb 17, 2013
1 parent
e34feda
commit 330b8bd
Showing
5 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package backtype.storm.utils; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
import java.util.ArrayList; | ||
import java.util.Map; | ||
import java.util.HashMap; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import com.netflix.curator.CuratorZookeeperClient; | ||
import com.netflix.curator.framework.CuratorFramework; | ||
import com.netflix.curator.retry.ExponentialBackoffRetry; | ||
|
||
import backtype.storm.Config; | ||
|
||
public class UtilsTest { | ||
|
||
@Test | ||
public void testNewCuratorUsesBoundedExponentialBackoff() { | ||
@SuppressWarnings("unchecked") | ||
Map<String,Object> conf = (Map<String,Object>)Utils.readDefaultConfig(); | ||
|
||
// Ensure these two values are different. | ||
final int ArbitraryInterval = 24; | ||
final int ArbitraryRetries = 4; | ||
conf.put(Config.STORM_ZOOKEEPER_RETRY_INTERVAL, ArbitraryInterval); | ||
conf.put(Config.STORM_ZOOKEEPER_RETRY_TIMES, ArbitraryRetries); | ||
|
||
List<String> servers = new ArrayList<String>(); | ||
servers.add("bogus_server"); | ||
Object port = new Integer(42); | ||
CuratorFramework cf = Utils.newCurator(conf, servers, port); | ||
|
||
assertTrue(cf.getZookeeperClient().getRetryPolicy() | ||
instanceof ExponentialBackoffRetry); | ||
|
||
ExponentialBackoffRetry retry = | ||
(ExponentialBackoffRetry)cf.getZookeeperClient().getRetryPolicy(); | ||
assertEquals(retry.getBaseSleepTimeMs(), ArbitraryInterval); | ||
assertEquals(retry.getN(), ArbitraryRetries); | ||
} | ||
} |