use of com.ctrip.platform.dal.dao.datasource.cluster.strategy.ReadStrategy in project dal by ctripcorp.
the class ReadSlavesFirstStrategy method dalHintsRoute.
protected HostSpec dalHintsRoute(DalHints dalHints) {
RouteStrategyEnum strategyEnum = dalHints.getRouteStrategy();
dalHints.cleanRouteStrategy();
if (routeStrategies.get(strategyEnum) == null) {
synchronized (routeStrategies) {
if (routeStrategies.get(strategyEnum) == null) {
try {
ReadStrategy tempRouteStrategy = (ReadStrategy) Class.forName(strategyEnum.getClazz()).newInstance();
tempRouteStrategy.init(hostSpecs, strategyProperties);
routeStrategies.put(strategyEnum, tempRouteStrategy);
} catch (Throwable e) {
}
}
}
}
return routeStrategies.get(strategyEnum).pickRead(dalHints);
}
Aggregations