com.netflix.config.DynamicPropertyFactory Java Examples

The following examples show how to use com.netflix.config.DynamicPropertyFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransportConfigUtils.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
public static int readVerticleCount(String key, String deprecatedKey) {
  int count = DynamicPropertyFactory.getInstance().getIntProperty(key, -1).get();
  if (count > 0) {
    return count;
  }

  count = DynamicPropertyFactory.getInstance().getIntProperty(deprecatedKey, -1).get();
  if (count > 0) {
    LOGGER.warn("{} is ambiguous, and deprecated, recommended to use {}.", deprecatedKey, key);
    return count;
  }

  // default value
  count = Runtime.getRuntime().availableProcessors() > 8 ? 8 : Runtime.getRuntime().availableProcessors();
  LOGGER.info("{} not defined, set to {}.", key, count);
  return count;
}
 
Example #2
Source File: PrometheusPublisher.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Override
public void init(GlobalRegistry globalRegistry, EventBus eventBus, MetricsBootstrapConfig config) {
  this.globalRegistry = globalRegistry;

  //prometheus default port allocation is here : https://github.com/prometheus/prometheus/wiki/Default-port-allocations
  String address =
      DynamicPropertyFactory.getInstance().getStringProperty(METRICS_PROMETHEUS_ADDRESS, "0.0.0.0:9696").get();

  try {
    InetSocketAddress socketAddress = getSocketAddress(address);
    register();
    this.httpServer = new HTTPServer(socketAddress, CollectorRegistry.defaultRegistry, true);

    LOGGER.info("Prometheus httpServer listened : {}.", address);
  } catch (Exception e) {
    throw new ServiceCombException("create http publish server failed,may bad address : " + address, e);
  }
}
 
Example #3
Source File: SSLOption.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
private static boolean getBooleanProperty(ConcurrentCompositeConfiguration configSource, boolean defaultValue,
    String... keys) {
  String property = null;
  for (String key : keys) {
    if (configSource != null) {
      if (configSource.getProperty(key) != null) {
        return configSource.getBoolean(key);
      }
    } else {
      property = DynamicPropertyFactory.getInstance().getStringProperty(key, null).get();
    }
    if (property != null) {
      break;
    }
  }

  if (property != null) {
    return Boolean.parseBoolean(property);
  } else {
    return defaultValue;
  }
}
 
Example #4
Source File: LoadbalanceHandler.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
private void preCheck() {
  // Old configurations check.Just print an error, because configurations may given in dynamic and fail on runtime.

  String policyName = DynamicPropertyFactory.getInstance()
      .getStringProperty("servicecomb.loadbalance.NFLoadBalancerRuleClassName", null)
      .get();
  if (!StringUtils.isEmpty(policyName)) {
    LOGGER.error("[servicecomb.loadbalance.NFLoadBalancerRuleClassName] is not supported anymore." +
        "use [servicecomb.loadbalance.strategy.name] instead.");
  }

  String filterNames = Configuration.getStringProperty(null, "servicecomb.loadbalance.serverListFilters");
  if (!StringUtils.isEmpty(filterNames)) {
    LOGGER.error(
        "Server list implementation changed to SPI. Configuration [servicecomb.loadbalance.serverListFilters]" +
            " is not used any more. For ServiceComb defined filters, you do not need config and can "
            + "remove this configuration safely. If you define your own filter, need to change it to SPI to make it work.");
  }
}
 
Example #5
Source File: ConfigurationBuilderTest.java    From chassis with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void fetchFromArchaius() {
    TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"), new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3 + "-override"));
    TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES.replace(".properties", "." + ENVIRONMENT + ".properties"), filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"));

    configurationBuilder.withApplicationProperties(TEST_APP_CONFIG_PROPERTIES_SPRING_PATH);
    Configuration configuration = configurationBuilder.build();

    Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
    Assert.assertEquals(MODULE_1_VALUE_2 + "-override", configuration.getString(MODULE_1_KEY_2));
    Assert.assertEquals(MODULE_1_VALUE_3 + "-override", configuration.getString(MODULE_1_KEY_3));

    Assert.assertEquals(MODULE_1_VALUE_1, DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_1, null).getValue());
    Assert.assertEquals(MODULE_1_VALUE_2 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_2, null).getValue());
    Assert.assertEquals(MODULE_1_VALUE_3 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_3, null).getValue());

}
 
Example #6
Source File: RouterRuleCache.java    From spring-cloud-huawei with Apache License 2.0 6 votes vote down vote up
/**
 * 每次序列化额外缓存,配置更新时触发回调函数 返回false即初始化规则失败: 1. 规则解析错误 2. 规则为空
 *
 * @param targetServiceName
 * @return
 */
public static boolean doInit(String targetServiceName) {
  if (!isServerContainRule(targetServiceName)) {
    return false;
  }
  if (!serviceInfoCacheMap.containsKey(targetServiceName)) {
    synchronized (servicePool.intern(targetServiceName)) {
      if (serviceInfoCacheMap.containsKey(targetServiceName)) {
        return true;
      }
      //Yaml not thread-safe
      DynamicStringProperty ruleStr = DynamicPropertyFactory.getInstance().getStringProperty(
          String.format(ROUTE_RULE, targetServiceName), null, () -> {
            refresh(targetServiceName);
            DynamicStringProperty tepRuleStr = DynamicPropertyFactory.getInstance()
                .getStringProperty(String.format(ROUTE_RULE, targetServiceName), null);
            addAllRule(targetServiceName, tepRuleStr.get());
          });
      return addAllRule(targetServiceName, ruleStr.get());
    }
  }
  return true;
}
 
Example #7
Source File: ArchaiusConnectionPoolConfiguration.java    From dyno with Apache License 2.0 6 votes vote down vote up
private CompressionStrategy parseCompressionStrategy(String propertyPrefix) {

        CompressionStrategy defaultCompStrategy = super.getCompressionStrategy();

        String cfg = DynamicPropertyFactory
                .getInstance()
                .getStringProperty(propertyPrefix + ".compressionStrategy", defaultCompStrategy.name()).get();

        CompressionStrategy cs = null;
        try {
            cs = CompressionStrategy.valueOf(cfg);
            Logger.info("Dyno configuration: CompressionStrategy = " + cs.name());
        } catch (IllegalArgumentException ex) {
            Logger.warn("Unable to parse CompressionStrategy: " + cfg + ", switching to default: " + defaultCompStrategy.name());
            cs = defaultCompStrategy;
        }

        return cs;

    }
 
Example #8
Source File: ArchaeusPaasConfiguration.java    From staash with Apache License 2.0 5 votes vote down vote up
@Override
public Double getDouble(GenericProperty name) {
    PropertyWrapper<Double> prop = (PropertyWrapper<Double>)parameters.get(name.getName());
    if (prop == null) {
        PropertyWrapper<Double> newProp = DynamicPropertyFactory.getInstance().getDoubleProperty(namespace + name, Double.parseDouble(name.getDefault()));
        prop = (PropertyWrapper<Double>) parameters.putIfAbsent(name.getName(),  newProp);
        if (prop == null)
            prop = newProp;
    }
    return prop.getValue();
}
 
Example #9
Source File: RegistryBean.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
private static String validAppId(String configAppId) {
  if (!StringUtils.isEmpty(configAppId)) {
    return configAppId;
  }
  if (DynamicPropertyFactory.getInstance()
      .getStringProperty(ServiceCombConstants.CONFIG_APPLICATION_ID_KEY, null).get() != null) {
    return DynamicPropertyFactory.getInstance()
        .getStringProperty(ServiceCombConstants.CONFIG_APPLICATION_ID_KEY, null).get();
  }
  return DEFAULT_APPLICATION_ID;
}
 
Example #10
Source File: ServiceRegistryConfigBuilder.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public int getIdleWatchTimeout() {
  // watch idle timeout based on SC PING/PONG interval. SC default value is 30.
  DynamicIntProperty property =
      DynamicPropertyFactory.getInstance()
          .getIntProperty("servicecomb.service.registry.client.timeout.watch",
              ServiceRegistryConfig.DEFAULT_TIMEOUT_IN_SECONDS * 2);
  int timeout = property.get();
  return timeout < 1 ? ServiceRegistryConfig.DEFAULT_TIMEOUT_IN_SECONDS * 2 : timeout;
}
 
Example #11
Source File: PersonService.java    From micro-service with MIT License 5 votes vote down vote up
private void loadConfig() {
	
	logger.info("person.register.pre.day:fix:" + preDayRegisterQuantity);
	logger.info("person.register.pre.day:dynamic:" + getPreDayRegisterQuantity());
	logger.info("person.register.pre.day:netflix:" + ConfigurationManager.getConfigInstance().getInteger("person.register.pre.day", 600));
	logger.info("person.register.pre.day:netflix2:" + DynamicPropertyFactory.getInstance().getIntProperty("person.register.pre.day", 600).get());
	
	logger.info("person.register.total:fix:" + totalRegisterQuantity);
	logger.info("person.register.total:dynamic:" + getTotalRegisterQuantity());
	logger.info("person.register.pre.day:netflix:" + ConfigurationManager.getConfigInstance().getInteger("person.register.total", 20000));
	logger.info("person.register.pre.day:netflix2:" + DynamicPropertyFactory.getInstance().getIntProperty("person.register.total", 20000).get());
	
	logger.info("concurrent.quantity" + ConfigurationManager.getConfigInstance().getInteger("concurrent.quantity", 10));
}
 
Example #12
Source File: ConfigurePropertyUtils.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
/**
 * 获取key包含prefix前缀的所有配置项
 */
public static Map<String, String> getPropertiesWithPrefix(String prefix) {
  Object config = DynamicPropertyFactory.getBackingConfigurationSource();
  if (!Configuration.class.isInstance(config)) {
    return new HashMap<>();
  }

  return getPropertiesWithPrefix((Configuration) config, prefix);
}
 
Example #13
Source File: InitFileProperties.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
public void init() {
    String applicationName = DynamicPropertyFactory.getInstance().getStringProperty(CommonConstant.CONFIG_APPLICATION_NAME_KEY, null).get();
    String propertiesNames = DynamicPropertyFactory.getInstance().getStringProperty(CommonConstant.PROPERTIES_RESOURCES_NAME_KEY, null).get();

    if (Check.NuNObj(propertiesNames)) {
        return;
    }

    String[] propertiesNamesArr = propertiesNames.split(",");

    PropertiesUtil propertiesUtil = new PropertiesUtil(propertiesNamesArr);

    Iterator<Map.Entry<Object, Object>> allProperties = propertiesUtil.getAllProperties();

    if (Check.NuNObj(allProperties)) {
        return;
    }

    while (allProperties.hasNext()) {
        Map.Entry<Object, Object> objectEntry = allProperties.next();
        String key = (String) objectEntry.getKey();

        // 配置文件的key默认加上系统名称变量
        if (!Check.NuNStr(applicationName)) {
            key = applicationName + "." + key;
        }

        // 判断System中是否存在相应属性,如存在将不处理
        if (!Check.NuNObj(System.getProperty(key))) {
            continue;
        }

        // 注册ZK监听
        try {
            ConfigSubscriber.getInstance().registConfig(key, objectEntry.getValue());
        } catch (Exception e) {
            LOGGER.error("注册配置文件的属性到ZK监听异常。key:{},error:{}", key, e);
        }
    }
}
 
Example #14
Source File: BaseNettyServer.java    From recipes-rss with Apache License 2.0 5 votes vote down vote up
public BaseNettyServer() {

        // This must be set before karyonServer.initialize() otherwise the
        // archaius properties will not be available in JMX/jconsole
        System.setProperty(DynamicPropertyFactory.ENABLE_JMX, "true");

        this.karyonServer = new KaryonServer();
        this.injector = karyonServer.initialize();		
    }
 
Example #15
Source File: SCBEngine.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
private void blockShutDownOperationForConsumerRefresh() {
  try {
    long turnDownWaitSeconds = DynamicPropertyFactory.getInstance()
        .getLongProperty(CFG_KEY_TURN_DOWN_STATUS_WAIT_SEC, DEFAULT_TURN_DOWN_STATUS_WAIT_SEC)
        .get();
    if (turnDownWaitSeconds <= 0) {
      return;
    }
    Thread.sleep(TimeUnit.SECONDS.toMillis(turnDownWaitSeconds));
  } catch (InterruptedException e) {
    LOGGER.warn("failed to block the shutdown procedure", e);
  }
}
 
Example #16
Source File: TestPriorityProperty.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void globalRefresh() {
  PriorityProperty<String> property = priorityPropertyManager.createPriorityProperty(String.class, null, null, keys);

  Assert.assertNull(property.getValue());

  ConcurrentCompositeConfiguration config = (ConcurrentCompositeConfiguration) DynamicPropertyFactory
      .getBackingConfigurationSource();
  config.addConfiguration(new MapConfiguration(Collections.singletonMap(high, "high-value")));

  Assert.assertEquals("high-value", property.getValue());
}
 
Example #17
Source File: AbstractHandlerManager.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Handler> create(String microserviceName) {
  String handlerChainKey = "servicecomb.handler.chain." + getName() + ".service." + microserviceName;
  String chainDef = DynamicPropertyFactory.getInstance()
      .getStringProperty(handlerChainKey,
          defaultChainDef)
      .get();
  LOGGER.info("get handler chain for [{}]: [{}]", handlerChainKey, chainDef);
  return createHandlerChain(chainDef);
}
 
Example #18
Source File: RSSManager.java    From recipes-rss with Apache License 2.0 5 votes vote down vote up
private RSSManager() {
    if (RSSConstants.RSS_STORE_CASSANDRA.equals(
            DynamicPropertyFactory.getInstance().getStringProperty(RSSConstants.RSS_STORE, RSSConstants.RSS_STORE_CASSANDRA).get())) {
        store = new CassandraStoreImpl();
    } else {
        store = new InMemoryStoreImpl();
    }
}
 
Example #19
Source File: RestServletInitializer.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("try")
public void onStartup(ServletContext servletContext) throws ServletException {
  if (StringUtils.isEmpty(ServletConfig.getServletUrlPattern())) {
    // ensure the servlet will be instantiated
    Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource();
    configuration.setProperty(ServletConfig.KEY_SERVLET_URL_PATTERN, ServletConfig.DEFAULT_URL_PATTERN);
  }

  if (this.factory == null) {
    // when running in external tomcat, WebServerFactoryCustomizer will not be available, but now tomcat
    // is already listening and we can call ServletUtils.init directly.
    ServletUtils.init(servletContext);
    return;
  }

  if (factory.getPort() == 0) {
    LOGGER.warn(
        "spring boot embedded web container listen port is 0, ServiceComb will not use container's port to handler REST request.");
    return;
  }

  // when running in embedded tomcat, web container did not listen now. Call ServletUtils.init needs server is ready,
  // so mock to listen, and then close.
  try (ServerSocket ss = new ServerSocket(factory.getPort(), 0, factory.getAddress())) {
    ServletUtils.init(servletContext);
  } catch (IOException e) {
    throw new ServletException(e);
  }
}
 
Example #20
Source File: URLMappedConfigurationLoader.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static Map<String, URLMappedConfigurationItem> loadConfigurations(
    ConcurrentCompositeConfiguration config, String configPrefix) {
  Map<String, URLMappedConfigurationItem> configurations = new HashMap<>();
  Iterator<String> configsItems = config.getKeys(configPrefix);
  while (configsItems.hasNext()) {
    String pathKey = configsItems.next();
    if (pathKey.endsWith(KEY_MAPPING_PATH)) {
      URLMappedConfigurationItem configurationItem = new URLMappedConfigurationItem();
      String pattern = DynamicPropertyFactory.getInstance()
          .getStringProperty(pathKey, null).get();
      if (StringUtils.isEmpty(pattern)) {
        continue;
      }
      configurationItem.setPattern(Pattern.compile(pattern));
      configurationItem.setStringPattern(pattern);
      String pathKeyItem = pathKey
          .substring(configPrefix.length() + 1, pathKey.length() - KEY_MAPPING_PATH.length());
      configurationItem.setMicroserviceName(DynamicPropertyFactory.getInstance()
          .getStringProperty(String.format(KEY_MAPPING_SERVICE_NAME, configPrefix, pathKeyItem), null).get());
      if (StringUtils.isEmpty(configurationItem.getMicroserviceName())) {
        continue;
      }
      configurationItem.setPrefixSegmentCount(DynamicPropertyFactory.getInstance()
          .getIntProperty(String.format(KEY_MAPPING_PREFIX_SEGMENT_COUNT, configPrefix, pathKeyItem), 0).get());
      configurationItem.setVersionRule(DynamicPropertyFactory.getInstance()
          .getStringProperty(String.format(KEY_MAPPING_VERSION_RULE, configPrefix, pathKeyItem), "0.0.0+").get());
      configurations.put(pathKeyItem, configurationItem);
    }
  }
  logConfigurations(configurations);
  return configurations;
}
 
Example #21
Source File: ServiceRegistryConfigBuilder.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public int getConnectionTimeout() {
  DynamicIntProperty property =
      DynamicPropertyFactory.getInstance()
          .getIntProperty("servicecomb.service.registry.client.timeout.connection",
              1000);
  int timeout = property.get();
  return timeout < 0 ? 1000 : timeout;
}
 
Example #22
Source File: RouterInvokeFilter.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
/**
 * read config and get Header
 */
private boolean loadHeaders() {
  if (!CollectionUtils.isEmpty(allHeader)) {
    return true;
  }
  DynamicStringProperty headerStr = DynamicPropertyFactory.getInstance()
      .getStringProperty(SERVICECOMB_ROUTER_HEADER, null, () -> {
        DynamicStringProperty temHeader = DynamicPropertyFactory.getInstance()
            .getStringProperty(SERVICECOMB_ROUTER_HEADER, null);
        if (!addAllHeaders(temHeader.get())) {
          allHeader = new ArrayList<>();
        }
      });
  return addAllHeaders(headerStr.get());
}
 
Example #23
Source File: SpringmvcServer.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
private static void assertPropertyCorrect() {
  String result = DynamicPropertyFactory.getInstance()
      .getStringProperty("test.unresolved.placeholder", null).get();
  if (!"jdbc:postgresql://${ip}:${port}/pt".equals(result)) {
    LOGGER.error("tests for configuration error, stop");
    SCBEngine.getInstance().destroy();
  }
}
 
Example #24
Source File: ArchaeusPaasConfiguration.java    From staash with Apache License 2.0 5 votes vote down vote up
@Override
public Integer getInteger(GenericProperty name) {
    PropertyWrapper<Integer> prop = (PropertyWrapper<Integer>)parameters.get(name.getName());
    if (prop == null) {
        PropertyWrapper<Integer> newProp = DynamicPropertyFactory.getInstance().getIntProperty(namespace + name, Integer.parseInt(name.getDefault()));
        prop = (PropertyWrapper<Integer>) parameters.putIfAbsent(name.getName(),  newProp);
        if (prop == null)
            prop = newProp;
    }
    return prop.getValue();
}
 
Example #25
Source File: ServiceRegistryConfigBuilder.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public int getHeartBeatRequestTimeout() {
  DynamicIntProperty property =
      DynamicPropertyFactory.getInstance()
          .getIntProperty("servicecomb.service.registry.client.timeout.heartbeat",
              ServiceRegistryConfig.DEFAULT_REQUEST_HEARTBEAT_TIMEOUT_IN_MS);
  int timeout = property.get();
  return timeout < 1 ? ServiceRegistryConfig.DEFAULT_REQUEST_HEARTBEAT_TIMEOUT_IN_MS : timeout;
}
 
Example #26
Source File: ServiceRegistryConfigBuilder.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public int getInstances() {
  DynamicIntProperty property =
      DynamicPropertyFactory.getInstance()
          .getIntProperty(ServiceRegistryConfig.VERTICLE_INSTANCES, 1);
  int deployInstances = property.get();
  if (deployInstances <= 0) {
    int nAvailableProcessors = Runtime.getRuntime().availableProcessors();
    LOGGER.warn("The property `{}` must be positive integer, fallback to use number of available processors: {}",
        ServiceRegistryConfig.VERTICLE_INSTANCES,
        nAvailableProcessors);
    return nAvailableProcessors;
  }
  return deployInstances;
}
 
Example #27
Source File: EdgeAddHeaderClientFilter.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public EdgeAddHeaderClientFilter() {
  init();
  ((ConcurrentCompositeConfiguration) DynamicPropertyFactory
      .getBackingConfigurationSource()).addConfigurationListener(event -> {
    if (event.getPropertyName().startsWith(KEY_HEADERS) || event.getPropertyName().startsWith(KEY_ENABLED)) {
      LOGGER.info("Public headers config have been changed. Event=" + event.getType());
      init();
    }
  });
}
 
Example #28
Source File: ProducerProviderManager.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
private void registerUrlPrefixToSwagger(Swagger swagger) {
  String urlPrefix = ClassLoaderScopeContext.getClassLoaderScopeProperty(DefinitionConst.URL_PREFIX);
  if (!StringUtils.isEmpty(urlPrefix) && !swagger.getBasePath().startsWith(urlPrefix)
      && DynamicPropertyFactory.getInstance()
      .getBooleanProperty(DefinitionConst.REGISTER_URL_PREFIX, false).get()) {
    LOGGER.info("Add swagger base path prefix for {} with {}", swagger.getBasePath(), urlPrefix);
    swagger.setBasePath(urlPrefix + swagger.getBasePath());
  }
}
 
Example #29
Source File: ZuulCommandHelper.java    From s2g-zuul with MIT License 5 votes vote down vote up
public static int  getRibbonReadTimeout(String groupName, String routeName) {
int socketTimeout = DynamicPropertyFactory.getInstance().getIntProperty("ribbbon."+routeName + ".socket.timeout", 0).get();
if (socketTimeout == 0) {
	socketTimeout = DynamicPropertyFactory.getInstance().getIntProperty("ribbbon."+groupName + ".socket.timeout", 0).get();
}
if (socketTimeout == 0) {
	socketTimeout = DynamicPropertyFactory.getInstance().getIntProperty("zuul.socket.timeout.global", 10000)
			.get();
}
return socketTimeout;
  }
 
Example #30
Source File: SchemaDiscovery.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
private SchemaDiscoveryService getOrCreateSchemaDiscoveryService() {
  if (this.schemaDiscoveryService == null) {
    // For schema discovery, assume all instances of different microservices
    // are instances of this microservice.
    String serviceName = DynamicPropertyFactory.getInstance()
        .getStringProperty(ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY,
            ServiceCombConstants.DEFAULT_MICROSERVICE_NAME).get();

    schemaDiscoveryService = Invoker
        .createProxy(serviceName, SchemaDiscoveryService.SCHEMA_ID,
            SchemaDiscoveryService.class);
  }
  return schemaDiscoveryService;
}