Skip to content
Permalink
Browse files
remove redundant code
  • Loading branch information
nzomkxia committed Jan 30, 2019
1 parent b69fe56 commit 98d1ce44f8a040c597297425f966bdcd8fd2bb20
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 315 deletions.

This file was deleted.

@@ -61,168 +61,12 @@ public void create(Provider provider) {
registry.register(url);
}

// public void enableProvider(String id) {
// if (id == null) {
// throw new IllegalStateException("no provider id");
// }
//
// Provider oldProvider = findProvider(id);
//
// if (oldProvider == null) {
// throw new IllegalStateException("Provider was changed!");
// }
// if (oldProvider.isDynamic()) {
// // Make sure we only have one override configured disable property.
// if (!oldProvider.isEnabled()) {
// Override override = new Override();
// override.setAddress(oldProvider.getAddress());
// override.setService(oldProvider.getService());
// override.setEnabled(true);
// override.setParams(Constants.DISABLED_KEY + "=false");
// overrideService.saveOverride(override);
// return;
// }
// List<Override> oList = overrideService.findByServiceAndAddress(oldProvider.getService(), oldProvider.getAddress());
//
// for (Override o : oList) {
// Map<String, String> params = StringUtils.parseQueryString(o.getParams());
// if (params.containsKey(Constants.DISABLED_KEY)) {
// if (params.get(Constants.DISABLED_KEY).equals("true")) {
// overrideService.deleteOverride(o.getHash());
// }
// }
// }
// } else {
// oldProvider.setEnabled(true);
// updateProvider(oldProvider);
// }
// }

@Override
public String getProviderMetaData(MetadataIdentifier providerIdentifier) {
return metaDataCollector.getProviderMetaData(providerIdentifier);
}

// public void disableProvider(String id) {
// if (id == null) {
// throw new IllegalStateException("no provider id");
// }
//
// Provider oldProvider = findProvider(id);
// if (oldProvider == null) {
// throw new IllegalStateException("Provider was changed!");
// }
//
// if (oldProvider.isDynamic()) {
// // Make sure we only have one override configured disable property.
// if (oldProvider.isEnabled()) {
// Override override = new Override();
// override.setAddress(oldProvider.getAddress());
// override.setService(oldProvider.getService());
// override.setEnabled(true);
// override.setParams(Constants.DISABLED_KEY + "=true");
// overrideService.saveOverride(override);
// return;
// }
// List<Override> oList = overrideService.findByServiceAndAddress(oldProvider.getService(), oldProvider.getAddress());
//
// for (Override o : oList) {
// Map<String, String> params = StringUtils.parseQueryString(o.getParams());
// if (params.containsKey(Constants.DISABLED_KEY)) {
// if (params.get(Constants.DISABLED_KEY).equals("false")) {
// overrideService.deleteOverride(o.getHash());
// }
// }
// }
// } else {
// oldProvider.setEnabled(false);
// updateProvider(oldProvider);
// }
//
// }

// public void doublingProvider(String id) {
// setWeight(id, 2F);
// }
//
// public void halvingProvider(String id) {
// setWeight(id, 0.5F);
// }

// public void setWeight(String id, float factor) {
// if (id == null) {
// throw new IllegalStateException("no provider id");
// }
// Provider oldProvider = findProvider(id);
// if (oldProvider == null) {
// throw new IllegalStateException("Provider was changed!");
// }
// Map<String, String> map = StringUtils.parseQueryString(oldProvider.getParameters());
// String weight = map.get(Constants.WEIGHT_KEY);
// if (oldProvider.isDynamic()) {
// // Make sure we only have one override configured disable property.
// List<Override> overrides = overrideService.findByServiceAndAddress(oldProvider.getService(), oldProvider.getAddress());
// if (overrides == null || overrides.size() == 0) {
// int value = getWeight(weight, factor);
// if (value != Constants.DEFAULT_WEIGHT) {
// Override override = new Override();
// override.setAddress(oldProvider.getAddress());
// override.setService(oldProvider.getService());
// override.setEnabled(true);
// override.setParams(Constants.WEIGHT_KEY + "=" + String.valueOf(value));
// overrideService.saveOverride(override);
// }
// } else {
// for (Override override : overrides) {
// Map<String, String> params = StringUtils.parseQueryString(override.getParams());
// String overrideWeight = params.get(Constants.WEIGHT_KEY);
// if (overrideWeight == null || overrideWeight.length() == 0) {
// overrideWeight = weight;
// }
// int value = getWeight(overrideWeight, factor);
// if (value == getWeight(weight, 1)) {
// params.remove(Constants.WEIGHT_KEY);
// } else {
// params.put(Constants.WEIGHT_KEY, String.valueOf(value));
// }
// if (params.size() > 0) {
// override.setParams(StringUtils.toQueryString(params));
// overrideService.updateOverride(override);
// } else {
// overrideService.deleteOverride(override.getHash());
// }
// }
// }
// } else {
// int value = getWeight(weight, factor);
// if (value == Constants.DEFAULT_WEIGHT) {
// map.remove(Constants.WEIGHT_KEY);
// } else {
// map.put(Constants.WEIGHT_KEY, String.valueOf(value));
// }
// oldProvider.setParameters(StringUtils.toQueryString(map));
// updateProvider(oldProvider);
// }
// }

private int getWeight(String value, float factor) {
int weight = 100;
if (value != null && value.length() > 0) {
weight = Integer.parseInt(value);
}
weight = (int) (weight * factor);
if (weight < 1){
weight = 1;
}
if (weight == 2){
weight = 3;
}

if (weight == 24){
weight = 25;
}
return weight;
}

@Override
public void deleteStaticProvider(String id) {

0 comments on commit 98d1ce4

Please sign in to comment.