use of com.ctrip.framework.dal.cluster.client.cluster.RouteStrategyEnum 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);
}
use of com.ctrip.framework.dal.cluster.client.cluster.RouteStrategyEnum in project dal by ctripcorp.
the class ClusterConfigXMLParser method getRouteStrategyNodes.
protected List<Node> getRouteStrategyNodes(Node routeStrategiesNode) {
List<Node> strategyNodes = new ArrayList<>();
for (RouteStrategyEnum readStrategyEnum : RouteStrategyEnum.values()) {
Node node = getChildNode(routeStrategiesNode, readStrategyEnum.name());
if (node != null && !strategyNodes.contains(node))
strategyNodes.add(node);
node = getChildNode(routeStrategiesNode, readStrategyEnum.getAlias());
if (node != null && !strategyNodes.contains(node))
strategyNodes.add(node);
}
return strategyNodes;
}
Aggregations