use of com.ctrip.framework.dal.cluster.client.base.HostSpec in project dal by ctripcorp.
the class RoundRobinAccessStrategyTest method pickNode_3_exceptionNode.
@Test
public void pickNode_3_exceptionNode() throws InterruptedException {
RouteStrategy strategy = getRouteStrategy();
strategy.init(shardMeta.configuredHosts(), caseInsensitiveProperties);
routeStrategy.interceptException(new SQLException("test"), new DefaultHostConnection(null, HostSpecOY_1));
HostSpec hostSpec1 = strategy.pickNode(dalHints);
HostSpec hostSpec2 = strategy.pickNode(dalHints);
Assert.assertEquals(HostSpecOY_2, hostSpec1);
Assert.assertEquals(HostSpecOY_2, hostSpec2);
TimeUnit.MILLISECONDS.sleep(custom_black_list_timeout + 1);
// remove from black list
hostSpec1 = strategy.pickNode(dalHints);
hostSpec2 = strategy.pickNode(dalHints);
Assert.assertNotEquals(hostSpec1, hostSpec2);
strategy.dispose();
}
use of com.ctrip.framework.dal.cluster.client.base.HostSpec in project dal by ctripcorp.
the class ShardMetaGenerator method addXY.
protected void addXY() {
hostSpecs.add(new HostSpec(SHAXY_IP1, SHAXY_PORT1, SHAXY, true));
hostSpecs.add(new HostSpec(SHAXY_IP2, SHAXY_PORT2, SHAXY, true));
}
use of com.ctrip.framework.dal.cluster.client.base.HostSpec in project dal by ctripcorp.
the class ShardMetaGenerator method addRB.
protected void addRB() {
hostSpecs.add(new HostSpec(SHARB_IP1, SHARB_PORT1, SHARB, true));
hostSpecs.add(new HostSpec(SHARB_IP2, SHARB_PORT2, SHARB, true));
}
use of com.ctrip.framework.dal.cluster.client.base.HostSpec in project dal by ctripcorp.
the class CompositeRoundRobinAccessStrategyTest method pickNode.
@Test
public void pickNode() throws SQLException {
HostSpec hostSpec = routeStrategy.pickNode(dalHints);
// pick from local
Assert.assertEquals(getRequestZone(), hostSpec.zone());
HostSpec hostSpec1 = routeStrategy.pickNode(dalHints);
// pick from local
Assert.assertEquals(getRequestZone(), hostSpec1.zone());
// round robin, so not equal
Assert.assertNotEquals(hostSpec, hostSpec1);
// test request zone is down
if (routeStrategy.isWrapperFor(Map.class)) {
RouteStrategy localRouteStrategy = (RouteStrategy) routeStrategy.unwrap(Map.class).remove(SHAXY);
Assert.assertNotNull(localRouteStrategy);
}
hostSpec = routeStrategy.pickNode(dalHints);
// not pick from local
Assert.assertNotEquals(getRequestZone(), hostSpec.zone());
}
use of com.ctrip.framework.dal.cluster.client.base.HostSpec in project dal by ctripcorp.
the class MGRStrategyTest method pickNode.
@Test
public void pickNode() {
HostSpec hostSpec1 = routeStrategy.pickNode(dalHints);
// pick from first
Assert.assertEquals(getRequestZone(), hostSpec1.zone());
HostSpec hostSpec2 = routeStrategy.pickNode(dalHints);
// pick from first
Assert.assertEquals(getRequestZone(), hostSpec2.zone());
Assert.assertEquals(hostSpec1, hostSpec2);
routeStrategy.dispose();
}
Aggregations