@Override protected void configure() { DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory.getInstance(); bind(DynamicPropertyFactory.class).toInstance(configInstance); // the default impl of EurekaInstanceConfig is CloudInstanceConfig, which we only want in an AWS // environment. Here we override that by binding MyDataCenterInstanceConfig to EurekaInstanceConfig. bind(EurekaInstanceConfig.class).to(MyDataCenterInstanceConfig.class); // (DiscoveryClient optional bindings) bind the optional event bus // bind(EventBus.class).to(EventBusImpl.class).in(Scopes.SINGLETON); } })
@Override public String resolveDeploymentContextBasedVipAddresses(String vipAddressMacro) { if (vipAddressMacro == null) { return null; } String result = vipAddressMacro; Matcher matcher = VIP_ATTRIBUTES_PATTERN.matcher(result); while (matcher.find()) { String key = matcher.group(1); String value = DynamicPropertyFactory.getInstance().getStringProperty(key, "").get(); logger.debug("att:{}", matcher.group()); logger.debug(", att key:{}", key); logger.debug(", att value:{}", value); logger.debug(""); result = result.replaceAll("\\$\\{" + key + "\\}", value); matcher = VIP_ATTRIBUTES_PATTERN.matcher(result); } return result; } }
public DynamicBooleanProperty getDynamicBooleanProperty(String name, Boolean defaultValue) { DynamicBooleanProperty prop = (DynamicBooleanProperty) fastPropMap.get(name); if (prop != null) return prop; prop = DynamicPropertyFactory.getInstance().getBooleanProperty(name, defaultValue); fastPropMap.put(name, prop); return prop; }
public DynamicIntProperty getDynamicIntProperty(String name, int defaultValue) { DynamicIntProperty prop = (DynamicIntProperty) fastPropMap.get(name); if (prop != null) return prop; prop = DynamicPropertyFactory.getInstance().getIntProperty(name, defaultValue); fastPropMap.put(name, prop); return prop; }
public DynamicStringProperty getDynamicStringProperty(String name, String defaultValue) { DynamicStringProperty prop = (DynamicStringProperty) fastPropMap.get(name); if (prop != null) return prop; prop = DynamicPropertyFactory.getInstance().getStringProperty(name, defaultValue); fastPropMap.put(name, prop); return prop; }
public DynamicLongProperty getDynamicLongProperty(String name, long defaultValue) { DynamicLongProperty prop = (DynamicLongProperty) fastPropMap.get(name); if (prop != null) return prop; prop = DynamicPropertyFactory.getInstance().getLongProperty(name, defaultValue); fastPropMap.put(name, prop); return prop; }
public ResultsLog( Tracker tracker ) throws IOException { this.tracker = tracker; File defaultFile = File.createTempFile( tracker.getTestClass().getCanonicalName(), "log" ); LOG.info( "Default results log file path = {}", defaultFile.getAbsolutePath() ); resultsFile = DynamicPropertyFactory.getInstance(). getStringProperty( RESULTS_FILE_KEY, defaultFile.getAbsolutePath() ); LOG.info( "Actual results log file path = {}", resultsFile.get() ); waitTime = DynamicPropertyFactory.getInstance().getLongProperty( WAIT_TIME_KEY, 200 ); prettyPrint = DynamicPropertyFactory.getInstance().getBooleanProperty( Constants.PRETTY_PRINT_RESULTS, true ); }
public static DynamicPropertyFactory initConfig(String configName) { DynamicPropertyFactory configInstance = DynamicPropertyFactory.getInstance(); DynamicStringProperty EUREKA_PROPS_FILE = configInstance.getStringProperty("eureka.client.props", configName); String env = ConfigurationManager.getConfigInstance().getString(EUREKA_ENVIRONMENT, "test"); ConfigurationManager.getConfigInstance().setProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT, env); String eurekaPropsFile = EUREKA_PROPS_FILE.get(); try { ConfigurationManager.loadCascadedPropertiesFromResources(eurekaPropsFile); } catch (IOException e) { logger.warn( "Cannot find the properties specified : {}. This may be okay if there are other environment " + "specific properties or the configuration is installed with a different mechanism.", eurekaPropsFile); } return configInstance; } }
public static void main(String[] args) { DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory.getInstance(); ApplicationInfoManager applicationInfoManager = initializeApplicationInfoManager(new MyDataCenterInstanceConfig()); EurekaClient eurekaClient = initializeEurekaClient(applicationInfoManager, new DefaultEurekaClientConfig()); ExampleServiceBase exampleServiceBase = new ExampleServiceBase(applicationInfoManager, eurekaClient, configInstance); try { exampleServiceBase.start(); } finally { // the stop calls shutdown on eurekaClient exampleServiceBase.stop(); } } }
public int getConnectionTimeout() { DynamicIntProperty property = DynamicPropertyFactory.getInstance() .getIntProperty("servicecomb.service.registry.client.timeout.connection", DEFAULT_TIMEOUT_IN_MS); int timeout = property.get(); return timeout < 0 ? DEFAULT_TIMEOUT_IN_MS : timeout; }
public boolean isRegistryAutoDiscovery() { DynamicBooleanProperty property = DynamicPropertyFactory.getInstance() .getBooleanProperty("servicecomb.service.registry.autodiscovery", false); return property.get(); }
public int getResendHeartBeatTimes() { DynamicIntProperty property = DynamicPropertyFactory.getInstance() .getIntProperty("servicecomb.service.registry.instance.healthCheck.times", DEFAULT_CHECK_TIMES); int times = property.get(); return times < 0 ? DEFAULT_CHECK_TIMES : times; }
public boolean isEmptyInstanceProtectionEnabled() { DynamicBooleanProperty property = DynamicPropertyFactory.getInstance() .getBooleanProperty("servicecomb.service.registry.instance.empty.protection", true); return property.get(); }
public static int getHttp2ConnectionMaxPoolSize() { return DynamicPropertyFactory.getInstance().getIntProperty("servicecomb.rest.client.http2.maxPoolSize", HttpClientOptions.DEFAULT_HTTP2_MAX_POOL_SIZE) .get(); }
public static boolean getUseAlpn() { return DynamicPropertyFactory.getInstance() .getBooleanProperty("servicecomb.rest.client.http2.useAlpnEnabled", true) .get(); }
public static String getAddress() { DynamicStringProperty address = DynamicPropertyFactory.getInstance().getStringProperty("servicecomb.rest.address", null); return address.get(); }
public static boolean getCompressed() { return DynamicPropertyFactory.getInstance() .getBooleanProperty("servicecomb.rest.server.compression", DEFAULT_SERVER_COMPRESSION_SUPPORT) .get(); }
public static int getMaxHeaderSize() { return DynamicPropertyFactory.getInstance() .getIntProperty("servicecomb.rest.server.maxHeaderSize", DEFAULT_SERVER_MAX_HEADER_SIZE) .get(); }
public static String getCorsAllowedOrigin() { return DynamicPropertyFactory.getInstance() .getStringProperty(SERVICECOMB_CORS_CONFIG_BASE + ".origin", "*") .get(); }
public MetricsBootstrapConfig() { msPollInterval = DynamicPropertyFactory.getInstance().getIntProperty(METRICS_WINDOW_TIME, DEFAULT_METRICS_WINDOW_TIME).get(); if (msPollInterval < 1000) { msPollInterval = 1000; } }