private int getWeight(Server server, WeightFilterEntity weightFilterEntity) {
Map<String, List<WeightEntity>> weightEntityMap = weightFilterEntity.getWeightEntityMap();
RegionWeightEntity regionWeightEntity = weightFilterEntity.getRegionWeightEntity();
String providerServiceId = server.getMetaInfo().getAppName();
String providerVersion = pluginAdapter.getServerVersion(server);
String providerRegion = pluginAdapter.getServerRegion(server);
String serviceId = pluginAdapter.getServiceId();
int weight = getWeight(serviceId, providerServiceId, providerVersion, weightEntityMap);
if (weight < 0) {
weight = getWeight(StringUtils.EMPTY, providerServiceId, providerVersion, weightEntityMap);
}
if (weight < 0) {
weight = getWeight(providerRegion, regionWeightEntity);
}
if (weight < 0) {
throw new DiscoveryException("Weight isn't configed for serviceId=" + providerServiceId);
}
return weight;
}