Search in sources :

Example 6 with RouteStrategy

use of com.ctrip.platform.dal.dao.datasource.cluster.strategy.RouteStrategy in project dal by ctripcorp.

the class MultiHostClusterPropertiesAdapterTest method setUp.

@Before
public void setUp() throws Exception {
    mgrRouteStrategyConfig = new ClusterRouteStrategyConfig() {

        @Override
        public RouteStrategy generate() {
            return doGenerate(routeStrategyName());
        }

        @Override
        public String routeStrategyName() {
            return RouteStrategyEnum.WRITE_ORDERED.name();
        }

        @Override
        public boolean multiMaster() {
            return true;
        }

        @Override
        public CaseInsensitiveProperties routeStrategyProperties() {
            return null;
        }
    };
    obRouteStrategyConfig = new ClusterRouteStrategyConfig() {

        @Override
        public RouteStrategy generate() {
            return doGenerate(routeStrategyName());
        }

        @Override
        public String routeStrategyName() {
            return RouteStrategyEnum.WRITE_CURRENT_ZONE_FIRST.getAlias();
        }

        @Override
        public boolean multiMaster() {
            return true;
        }

        @Override
        public CaseInsensitiveProperties routeStrategyProperties() {
            return null;
        }
    };
    customRouteStrategyConfig = new ClusterRouteStrategyConfig() {

        @Override
        public RouteStrategy generate() {
            return doGenerate(routeStrategyName());
        }

        @Override
        public String routeStrategyName() {
            return CUSTOM_STRATEGY;
        }

        @Override
        public boolean multiMaster() {
            return false;
        }

        @Override
        public CaseInsensitiveProperties routeStrategyProperties() {
            return null;
        }
    };
}
Also used : CaseInsensitiveProperties(com.ctrip.framework.dal.cluster.client.util.CaseInsensitiveProperties) ClusterRouteStrategyConfig(com.ctrip.framework.dal.cluster.client.multihost.ClusterRouteStrategyConfig) RouteStrategy(com.ctrip.platform.dal.dao.datasource.cluster.strategy.RouteStrategy) Before(org.junit.Before)

Aggregations

RouteStrategy (com.ctrip.platform.dal.dao.datasource.cluster.strategy.RouteStrategy)6 HostSpec (com.ctrip.framework.dal.cluster.client.base.HostSpec)2 DalRuntimeException (com.ctrip.platform.dal.exceptions.DalRuntimeException)2 Test (org.junit.Test)2 ClusterRouteStrategyConfig (com.ctrip.framework.dal.cluster.client.multihost.ClusterRouteStrategyConfig)1 CaseInsensitiveProperties (com.ctrip.framework.dal.cluster.client.util.CaseInsensitiveProperties)1 ConnectionFactoryAware (com.ctrip.platform.dal.dao.datasource.cluster.strategy.ConnectionFactoryAware)1 HostConnectionValidatorHolder (com.ctrip.platform.dal.dao.datasource.cluster.strategy.HostConnectionValidatorHolder)1 ValidatingConnectionValidatorHolder (com.ctrip.platform.dal.dao.datasource.cluster.strategy.ValidatingConnectionValidatorHolder)1 MGRStrategy (com.ctrip.platform.dal.dao.datasource.cluster.strategy.multi.mgr.MGRStrategy)1 OBStrategy (com.ctrip.platform.dal.dao.datasource.cluster.strategy.multi.ob.OBStrategy)1 HostValidatorAware (com.ctrip.platform.dal.dao.datasource.cluster.strategy.multi.validator.HostValidatorAware)1 Map (java.util.Map)1 Set (java.util.Set)1 Before (org.junit.Before)1