@Override public String getValue(ContextKey key) { if (delegate == null) { System.out.println("Configuration not yet initialized. Returning 'null' for " + key); return null; } return delegate.getValue(key); }
@Override public void initWithNiwsConfig(IClientConfig niwsClientConfig) { super.initWithNiwsConfig(niwsClientConfig); if (ConfigurationManager.getDeploymentContext() != null) { this.zone = ConfigurationManager.getDeploymentContext().getValue( ContextKey.zone); } }
public static void setDeploymentContext(DeploymentContext context) { ConfigurationManager.context = context; if (getConfigInstance() == null) { return; } for (DeploymentContext.ContextKey key: DeploymentContext.ContextKey.values()) { String value = context.getValue(key); if (value != null) { instance.setProperty(key.getKey(), value); } } }
public static void setDeploymentContext(DeploymentContext context) { ConfigurationManager.context = context; if (getConfigInstance() == null) { return; } for (DeploymentContext.ContextKey key: DeploymentContext.ContextKey.values()) { String value = context.getValue(key); if (value != null) { instance.setProperty(key.getKey(), value); } } }
@Override public PollResult poll(boolean initial, Object checkPoint) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); for(PropertyWithDeploymentContext prop: tableCache.getProperties()){ if(prop.getContextKey() == contextKey && prop.getContextValue() == null){ map.put(prop.getPropertyName(), prop.getPropertyValue()); } else if(prop.getContextKey() == contextKey && prop.getContextValue().equalsIgnoreCase(deploymentContext.getValue(contextKey))){ map.put(prop.getPropertyName(), prop.getPropertyValue()); } } return PollResult.createFull(map); } }
@PostConstruct public void preprocess() { String zone = ConfigurationManager.getDeploymentContext() .getValue(ContextKey.zone); if (this.clientConfig != null && StringUtils.isEmpty(zone)) { if (this.approximateZoneFromHostname && this.eurekaConfig != null) {
@Override public void initWithNiwsConfig(IClientConfig niwsClientConfig) { String sZoneAffinity = "" + niwsClientConfig.getProperty(CommonClientConfigKey.EnableZoneAffinity, false); if (sZoneAffinity != null){ zoneAffinity = Boolean.parseBoolean(sZoneAffinity); logger.debug("ZoneAffinity is set to {}", zoneAffinity); } String sZoneExclusive = "" + niwsClientConfig.getProperty(CommonClientConfigKey.EnableZoneExclusivity, false); if (sZoneExclusive != null){ zoneExclusive = Boolean.parseBoolean(sZoneExclusive); } if (ConfigurationManager.getDeploymentContext() != null) { zone = ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone); } activeReqeustsPerServerThreshold = DynamicPropertyFactory.getInstance().getDoubleProperty(niwsClientConfig.getClientName() + "." + niwsClientConfig.getNameSpace() + ".zoneAffinity.maxLoadPerServer", 0.6d); logger.debug("activeReqeustsPerServerThreshold: {}", activeReqeustsPerServerThreshold.get()); blackOutServerPercentageThreshold = DynamicPropertyFactory.getInstance().getDoubleProperty(niwsClientConfig.getClientName() + "." + niwsClientConfig.getNameSpace() + ".zoneAffinity.maxBlackOutServesrPercentage", 0.8d); logger.debug("blackOutServerPercentageThreshold: {}", blackOutServerPercentageThreshold.get()); availableServersThreshold = DynamicPropertyFactory.getInstance().getIntProperty(niwsClientConfig.getClientName() + "." + niwsClientConfig.getNameSpace() + ".zoneAffinity.minAvailableServers", 2); logger.debug("availableServersThreshold: {}", availableServersThreshold.get()); overrideCounter = Monitors.newCounter("ZoneAffinity_OverrideCounter"); Monitors.registerObject("NIWSServerListFilter_" + niwsClientConfig.getClientName()); }