use of com.ctrip.framework.dal.cluster.client.cluster.ClusterType in project dal by ctripcorp.
the class ClusterDbSqlContext method toMetricTags.
@Override
protected Map<String, String> toMetricTags() {
Map<String, String> tags = super.toMetricTags();
addTag(tags, CLUSTER, cluster.getClusterName());
addTag(tags, SHARD, shard);
addTag(tags, ROLE, role);
addTag(tags, READ_STRATEGY, readStrategy);
addTag(tags, DB_KEY, String.format("%s-%s-%s", cluster, shard, role));
ClusterType type = cluster.getClusterType();
if (type == ClusterType.DRC) {
LocalizationConfig config = cluster.getLocalizationConfig();
if (config != null && config.getLocalizationState() == LocalizationState.ACTIVE)
tags.put(CLUSTER_TYPE, type.getValue() + "_" + config.getLocalizationState().getValue());
else
tags.put(CLUSTER_TYPE, type.getValue() + "_" + LocalizationState.PREPARED.getValue());
if (config != null && config.getUnitStrategyId() != null)
tags.put(UCS_STRATEGY, String.valueOf(config.getUnitStrategyId()));
} else if (type != null)
tags.put(CLUSTER_TYPE, type.getValue());
return tags;
}
use of com.ctrip.framework.dal.cluster.client.cluster.ClusterType in project dal by ctripcorp.
the class ClusterConfigXMLParser method parseCluster.
private ClusterConfig parseCluster(Node clusterNode, DalConfigCustomizedOption customizedOption) throws IOException {
String name = getAttribute(clusterNode, NAME);
if (StringUtils.isEmpty(name))
throw new ClusterConfigException("cluster name undefined");
ClusterType clusterType = ClusterType.NORMAL;
String clusterTypeText = getAttribute(clusterNode, TYPE);
if (!StringUtils.isEmpty(clusterTypeText))
clusterType = ClusterType.parse(clusterTypeText);
DatabaseCategory dbCategory = DatabaseCategory.parse(getAttribute(clusterNode, DB_CATEGORY));
int version = Integer.parseInt(getAttribute(clusterNode, VERSION));
ClusterConfigImpl clusterConfig = new ClusterConfigImpl(name, clusterType, dbCategory, version);
clusterConfig.setCustomizedOption(customizedOption);
Node databaseShardsNode = getChildNode(clusterNode, DATABASE_SHARDS);
if (databaseShardsNode != null) {
List<Node> databaseShardNodes = getChildNodes(databaseShardsNode, DATABASE_SHARD);
for (Node databaseShardNode : databaseShardNodes) parseDatabaseShard(clusterConfig, databaseShardNode);
}
Node shardStrategiesNode = getChildNode(clusterNode, SHARD_STRATEGIES);
if (shardStrategiesNode != null)
parseShardStrategies(clusterConfig, shardStrategiesNode);
Node idGeneratorsNode = getChildNode(clusterNode, ID_GENERATORS);
if (idGeneratorsNode != null)
parseIdGenerators(clusterConfig, idGeneratorsNode);
Node routeStrategiesNode = getChildNode(clusterNode, ROUTE_STRATEGIES);
if (!StringUtils.isEmpty(customizedOption.getRouteStrategy())) {
initRouteStrategy(clusterConfig, customizedOption);
} else if (routeStrategiesNode != null)
parseRouteStrategies(clusterConfig, routeStrategiesNode);
else
initRouteStrategy(clusterConfig);
parseDrcConfig(clusterConfig, clusterNode);
return clusterConfig;
}
Aggregations