mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Optimize the logic in HA Validation.
This commit is contained in:
@@ -40,6 +40,7 @@ public class RandomDataSourceSelectorTest extends BaseRandomDataSourceSelectorTe
|
||||
|
||||
assertEquals(10, selector.getValidationSleepSeconds());
|
||||
assertEquals(10, selector.getValidateThread().getValidationSleepSeconds());
|
||||
assertEquals(10, selector.getRecoverThread().getValidationSleepSeconds());
|
||||
|
||||
assertEquals(5, selector.getBlacklistThreshold());
|
||||
assertEquals(5, selector.getValidateThread().getBlacklistThreshold());
|
||||
|
||||
+2
-2
@@ -31,13 +31,13 @@ public class RandomDataSourceSelectorWithValidationTest {
|
||||
@Test
|
||||
public void testOneDataSourceFailAndRecover() throws Exception {
|
||||
RandomDataSourceSelector selector = ((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector());
|
||||
selector.setCheckingIntervalSeconds(3);
|
||||
selector.getValidateThread().setCheckingIntervalSeconds(3);
|
||||
selector.getRecoverThread().setSleepSeconds(3);
|
||||
selector.init();
|
||||
|
||||
DruidDataSource dataSource = (DruidDataSource) highAvailableDataSource.getDataSourceMap().get("foo");
|
||||
dataSource.setValidationQuery("select xxx from yyy");
|
||||
Thread.sleep(6 * 1000);
|
||||
Thread.sleep(10 * 1000);
|
||||
assertTrue(dataSource.isTestOnReturn());
|
||||
for (int i = 0; i < 100; i++) {
|
||||
assertNotEquals(dataSource, selector.get());
|
||||
|
||||
Reference in New Issue
Block a user