com.netflix.config.DynamicBooleanProperty Java Examples

The following examples show how to use com.netflix.config.DynamicBooleanProperty. 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: Application.java    From apollo-use-cases with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
  // set apollo meta server address, adjust to actual address if necessary
  String apolloConfigServiceUrl = "http://localhost:8080";

  String appId = "netflix-archaius";
  System.setProperty(ARCHAIUS_ADD_ITIONAL_URLS,
      apolloConfigServiceUrl + "/configfiles/" + appId + "/default/application");

  DynamicBooleanProperty hystrixForceClosedProperty = DynamicPropertyFactory.getInstance()
      .getBooleanProperty("hystrix.command.default.circuitBreaker.forceClosed", false);

  //Archaius 默认30秒从服务端更新一次配置信息
  hystrixForceClosedProperty.addCallback(
      () -> System.out.println("[" + LocalDateTime.now().toString() + "] update forceClosed :" +  hystrixForceClosedProperty.get()));

  while (true) {
    System.in.read();
  }
}
 
Example #2
Source File: InitializeServletListener.java    From s2g-zuul with MIT License 5 votes vote down vote up
private void registerEureka() {
	DynamicBooleanProperty eurekaEnabled = DynamicPropertyFactory.getInstance().getBooleanProperty("eureka.enabled",
			true);
	if (!eurekaEnabled.get())
		return;

	EurekaInstanceConfig eurekaInstanceConfig = new PropertiesInstanceConfig() {
	};
       ConfigurationManager.getConfigInstance().setProperty("eureka.statusPageUrl","http://"+ getTurbineInstance());

	DiscoveryManager.getInstance().initComponent(eurekaInstanceConfig, new DefaultEurekaClientConfig());

	final DynamicStringProperty serverStatus = DynamicPropertyFactory.getInstance()
			.getStringProperty("server." + IPUtil.getLocalIP() + ".status", "up");
	DiscoveryManager.getInstance().getDiscoveryClient().registerHealthCheckCallback(new HealthCheckCallback() {
		@Override
		public boolean isHealthy() {
			return serverStatus.get().toLowerCase().equals("up");
		}
	});

	String version = String.valueOf(System.currentTimeMillis());
	String group = ConfigurationManager.getConfigInstance().getString("server.group", "default");
	String dataCenter = ConfigurationManager.getConfigInstance().getString("server.data-center", "default");

	Map<String, String> metadata = new HashMap<String, String>();
	metadata.put("version", version);
	metadata.put("group", group);
	metadata.put("dataCenter", dataCenter);

	String turbineInstance = getTurbineInstance();
	if (turbineInstance != null) {
		metadata.put("turbine.instance", turbineInstance);
	}

	ApplicationInfoManager.getInstance().registerAppMetadata(metadata);
}
 
Example #3
Source File: ServiceRegistryConfigBuilder.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public boolean isRegistryAutoDiscovery() {
  DynamicBooleanProperty property =
      DynamicPropertyFactory.getInstance()
          .getBooleanProperty("servicecomb.service.registry.autodiscovery",
              false);
  return property.get();
}
 
Example #4
Source File: ServiceRegistryConfigBuilder.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public boolean isAlwaysOverrideSchema() {
  DynamicBooleanProperty property =
      DynamicPropertyFactory.getInstance()
          .getBooleanProperty("servicecomb.service.registry.instance.alwaysOverrideSchema",
              false);
  return property.get();
}
 
Example #5
Source File: ServiceRegistryConfigBuilder.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public boolean isPreferIpAddress() {
  DynamicBooleanProperty property =
      DynamicPropertyFactory.getInstance()
          .getBooleanProperty("servicecomb.service.registry.instance.preferIpAddress",
              false);
  return property.get();
}
 
Example #6
Source File: ServiceRegistryConfigBuilder.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public boolean isWatch() {
  DynamicBooleanProperty property =
      DynamicPropertyFactory.getInstance()
          .getBooleanProperty("servicecomb.service.registry.instance.watch",
              true);
  return property.get();
}
 
Example #7
Source File: BaseServerStartup.java    From zuul with Apache License 2.0 5 votes vote down vote up
public static boolean chooseBooleanChannelProperty(
        String listenAddressName, String propertySuffix, boolean defaultValue) {
    String globalPropertyName = "server." + propertySuffix;
    String listenAddressPropertyName = "server." + listenAddressName + "." + propertySuffix;

    Boolean value = new ChainedDynamicProperty.DynamicBooleanPropertyThatSupportsNull(
            listenAddressPropertyName, null).get();
    if (value == null) {
        value = new DynamicBooleanProperty(globalPropertyName, defaultValue).getDynamicProperty().getBoolean();
        if (value == null) {
            value = defaultValue;
        }
    }
    return value;
}
 
Example #8
Source File: InitializeServletListener.java    From s2g-zuul with MIT License 4 votes vote down vote up
private void updateInstanceStatusToEureka() {
	DynamicBooleanProperty eurekaEnabled = DynamicPropertyFactory.getInstance().getBooleanProperty("eureka.enabled",
			true);
	if (!eurekaEnabled.get()) return;
       ApplicationInfoManager.getInstance().setInstanceStatus(InstanceInfo.InstanceStatus.UP);
}
 
Example #9
Source File: DynamicPropertiesImpl.java    From servicecomb-java-chassis with Apache License 2.0 4 votes vote down vote up
@Override
public boolean getBooleanProperty(String propertyName, Consumer<Boolean> consumer, boolean defaultValue) {
  DynamicBooleanProperty prop = propertyFactoryInstance().getBooleanProperty(propertyName, defaultValue);
  prop.addCallback(() -> consumer.accept(prop.get()));
  return prop.get();
}
 
Example #10
Source File: ConfigSubscriber.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
@Override
public boolean getBoolean(String key, boolean defaultValue, Runnable callback) {
    final DynamicBooleanProperty property = DynamicPropertyFactory.getInstance().getBooleanProperty(key, defaultValue, callback);
    return property.get();
}
 
Example #11
Source File: ArchaiusConnectionPoolConfiguration.java    From dyno with Apache License 2.0 4 votes vote down vote up
public void setIsDualWriteEnabled(DynamicBooleanProperty booleanProperty) {
    this.isDualWriteEnabled = booleanProperty;
}
 
Example #12
Source File: SurgicalDebugFilter.java    From zuul with Apache License 2.0 3 votes vote down vote up
@Override
public boolean shouldFilter(HttpRequestMessage request) {

    DynamicBooleanProperty debugFilterShutoff = new DynamicBooleanProperty(ZuulConstants.ZUUL_DEBUGFILTERS_DISABLED, false);

    if (debugFilterShutoff.get()) return false;

    if (isDisabled()) return false;

    String isSurgicalFilterRequest = request.getHeaders().getFirst(ZuulHeaders.X_ZUUL_SURGICAL_FILTER);
    // dont' apply filter if it was already applied
    boolean notAlreadyFiltered = !("true".equals(isSurgicalFilterRequest));

    return notAlreadyFiltered && patternMatches(request);
}
 
Example #13
Source File: ConfigSubscriber.java    From AsuraFramework with Apache License 2.0 2 votes vote down vote up
/**
 * @param key
 *         配置项的key
 * @param defaultValue
 *         如果取回的配置项值为空, 应该返回的默认值
 *
 * @return 配置项的值
 */
@Override
public boolean getBoolean(String key, boolean defaultValue) {
    final DynamicBooleanProperty property = DynamicPropertyFactory.getInstance().getBooleanProperty(key, defaultValue);
    return property.get();
}