mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Enhance RandomDataSourceSelector
1. shorten the checking interval when validate failed 2. provide some parameters in higher level 3. add a sleep before validation (default 0) 4. validate the DataSource concurrently
This commit is contained in:
+5
-3
@@ -30,8 +30,10 @@ public class RandomDataSourceSelectorWithValidationTest {
|
||||
|
||||
@Test
|
||||
public void testOneDataSourceFailAndRecover() throws Exception {
|
||||
((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector()).getValidateThread().setSleepSeconds(3);
|
||||
((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector()).getRecoverThread().setSleepSeconds(3);
|
||||
RandomDataSourceSelector selector = ((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector());
|
||||
selector.setCheckingIntervalSeconds(3);
|
||||
selector.getRecoverThread().setSleepSeconds(3);
|
||||
selector.init();
|
||||
|
||||
Thread.sleep(30 * 1000);
|
||||
|
||||
@@ -57,7 +59,7 @@ public class RandomDataSourceSelectorWithValidationTest {
|
||||
|
||||
@Test
|
||||
public void testAllDataSourceFail() throws Exception {
|
||||
((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector()).getValidateThread().setSleepSeconds(3);
|
||||
((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector()).getValidateThread().setCheckingIntervalSeconds(3);
|
||||
((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector()).getRecoverThread().setSleepSeconds(3);
|
||||
|
||||
Thread.sleep(30 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user