@Override public boolean isValueAcceptable() { return (sProp.get() != null); }
public ChainProperty(HystrixDynamicProperty<T> sProperty, ChainProperty<T> next) { super(next); // setup next pointer sProp = sProperty; sProp.addCallback(new Runnable() { @Override public void run() { logger.debug("Property changed: '{} = {}'", getName(), getValue()); checkAndFlip(); } }); checkAndFlip(); }
@Override public String getName() { return sProp.getName(); }
@Override protected T getValue() { return sProp.get(); }
private ExecutionIsolationStrategyHystrixProperty(ExecutionIsolationStrategy builderOverrideValue, HystrixCommandKey key, String propertyPrefix, ExecutionIsolationStrategy defaultValue, String instanceProperty) { this.defaultValue = defaultValue; String overrideValue = null; if (builderOverrideValue != null) { overrideValue = builderOverrideValue.name(); } property = forString() .add(propertyPrefix + ".command." + key.name() + "." + instanceProperty, overrideValue) .add(propertyPrefix + ".command.default." + instanceProperty, defaultValue.name()) .build(); // initialize the enum value from the property parseProperty(); // use a callback to handle changes so we only handle the parse cost on updates rather than every fetch property.addCallback(new Runnable() { @Override public void run() { // when the property value changes we'll update the value parseProperty(); } }); }
@Override public String getName() { return sProp.getName(); }
private ExecutionIsolationStrategyHystrixProperty(ExecutionIsolationStrategy builderOverrideValue, HystrixCommandKey key, String propertyPrefix, String command, ExecutionIsolationStrategy defaultValue, String instanceProperty) { this.defaultValue = defaultValue; String overrideValue = null; if (builderOverrideValue != null) { overrideValue = builderOverrideValue.name(); } property = forString() .add(propertyPrefix + "." + command + "." + key.name() + "." + instanceProperty, null) .add(propertyPrefix + "." + command + "." + serviceKey(key.name()) + "." + instanceProperty, overrideValue) .add(propertyPrefix + "." + command + "." + typeKey(key.name()) + "." + instanceProperty, defaultValue.name()) .build(); // initialize the enum value from the property parseProperty(); // use a callback to handle changes so we only handle the parse cost // on updates rather than every fetch // when the property value changes we'll update the value property.addCallback(this::parseProperty); }
@SuppressWarnings("unchecked") private static <T> T getPluginImplementationViaProperties(Class<T> pluginClass, HystrixDynamicProperties dynamicProperties) { String classSimpleName = pluginClass.getSimpleName(); // Check Archaius for plugin class. String propertyName = "hystrix.plugin." + classSimpleName + ".implementation"; String implementingClass = dynamicProperties.getString(propertyName, null).get(); if (implementingClass != null) { try { Class<?> cls = Class.forName(implementingClass); // narrow the scope (cast) to the type we're expecting cls = cls.asSubclass(pluginClass); return (T) cls.newInstance(); } catch (ClassCastException e) { throw new RuntimeException(classSimpleName + " implementation is not an instance of " + classSimpleName + ": " + implementingClass); } catch (ClassNotFoundException e) { throw new RuntimeException(classSimpleName + " implementation class not found: " + implementingClass, e); } catch (InstantiationException e) { throw new RuntimeException(classSimpleName + " implementation not able to be instantiated: " + implementingClass, e); } catch (IllegalAccessException e) { throw new RuntimeException(classSimpleName + " implementation not able to be accessed: " + implementingClass, e); } } else { return null; } }
public ChainProperty(HystrixDynamicProperty<T> sProperty, ChainProperty<T> next) { super(next); // setup next pointer sProp = sProperty; sProp.addCallback(new Runnable() { @Override public void run() { logger.debug("Property changed: '{} = {}'", getName(), getValue()); checkAndFlip(); } }); checkAndFlip(); }
@Test public void testDynamicSystemProperties() throws Exception { //On the off chance this is the first test lets not screw up all the other tests HystrixPlugins.getInstance(); System.setProperty("hystrix.plugin.HystrixDynamicProperties.implementation", "com.netflix.hystrix.strategy.properties.HystrixDynamicPropertiesSystemProperties"); HystrixPlugins plugins = setupMockServiceLoader(); assertTrue(plugins.getDynamicProperties() instanceof HystrixDynamicPropertiesSystemProperties); HystrixDynamicProperties p = plugins.getDynamicProperties(); //Some minimum testing of system properties wrapper //this probably should be in its own test class. assertTrue(p.getBoolean("USE_DEFAULT", true).get()); assertEquals("string", p.getString("USE_DEFAULT", "string").get()); assertEquals(1L, p.getLong("USE_DEFAULT", 1L).get().longValue()); assertEquals(1, p.getInteger("USE_DEFAULT", 1).get().intValue()); assertNotNull(p.getString("path.separator", null).get()); assertEvents("[debug: [Created HystrixDynamicProperties instance from System property named \"hystrix.plugin.HystrixDynamicProperties.implementation\". Using class: {}, com.netflix.hystrix.strategy.properties.HystrixDynamicPropertiesSystemProperties]]"); System.clearProperty("hystrix.plugin.HystrixDynamicProperties.implementation"); }
private ExecutionIsolationStrategyHystrixProperty(ExecutionIsolationStrategy builderOverrideValue, HystrixCommandKey key, String propertyPrefix, ExecutionIsolationStrategy defaultValue, String instanceProperty) { this.defaultValue = defaultValue; String overrideValue = null; if (builderOverrideValue != null) { overrideValue = builderOverrideValue.name(); } property = forString() .add(propertyPrefix + ".command." + key.name() + "." + instanceProperty, overrideValue) .add(propertyPrefix + ".command.default." + instanceProperty, defaultValue.name()) .build(); // initialize the enum value from the property parseProperty(); // use a callback to handle changes so we only handle the parse cost on updates rather than every fetch property.addCallback(new Runnable() { @Override public void run() { // when the property value changes we'll update the value parseProperty(); } }); }
private ExecutionIsolationStrategyHystrixProperty(ExecutionIsolationStrategy builderOverrideValue, HystrixCommandKey key, String propertyPrefix, String command, ExecutionIsolationStrategy defaultValue, String instanceProperty) { this.defaultValue = defaultValue; String overrideValue = null; if (builderOverrideValue != null) { overrideValue = builderOverrideValue.name(); } property = forString() .add(propertyPrefix + "." + command + "." + key.name() + "." + instanceProperty, null) .add(propertyPrefix + "." + command + "." + serviceKey(key.name()) + "." + instanceProperty, overrideValue) .add(propertyPrefix + "." + command + "." + typeKey(key.name()) + "." + instanceProperty, defaultValue.name()) .build(); // initialize the enum value from the property parseProperty(); // use a callback to handle changes so we only handle the parse cost // on updates rather than every fetch // when the property value changes we'll update the value property.addCallback(this::parseProperty); }
@Override public boolean isValueAcceptable() { return (sProp.get() != null); }
private ExecutionIsolationStrategyHystrixProperty(ExecutionIsolationStrategy builderOverrideValue, HystrixCommandKey key, String propertyPrefix, String command, ExecutionIsolationStrategy defaultValue, String instanceProperty) { this.defaultValue = defaultValue; String overrideValue = null; if (builderOverrideValue != null) { overrideValue = builderOverrideValue.name(); } property = forString() .add(propertyPrefix + "." + command + "." + key.name() + "." + instanceProperty, null) .add(propertyPrefix + "." + command + "." + serviceKey(key.name()) + "." + instanceProperty, overrideValue) .add(propertyPrefix + "." + command + "." + typeKey(key.name()) + "." + instanceProperty, defaultValue.name()) .build(); // initialize the enum value from the property parseProperty(); // use a callback to handle changes so we only handle the parse cost // on updates rather than every fetch // when the property value changes we'll update the value property.addCallback(this::parseProperty); }
@Override protected T getValue() { return sProp.get(); }