本文整理汇总了Java中com.netflix.config.DynamicProperty类的典型用法代码示例。如果您正苦于以下问题:Java DynamicProperty类的具体用法?Java DynamicProperty怎么用?Java DynamicProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DynamicProperty类属于com.netflix.config包,在下文中一共展示了DynamicProperty类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initConfig
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
private void initConfig(OperationMeta operationMeta, String key) {
if (watchedKeySet.contains(key)) {
return;
}
watchedKeySet.add(key);
String configKey = Config.CONSUMER_LIMIT_KEY_PREFIX + key;
DynamicProperty property = DynamicProperty.getInstance(configKey);
initQpsLimit(key, getIntegerLimitProperty(property));
property.addCallback(() -> {
updateQpsLimit(key, getIntegerLimitProperty(property));
QpsController qpsController = findReference(operationMeta);
objMap.put(operationMeta.getMicroserviceQualifiedName(), qpsController);
});
}
示例2: getOrCreate
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
@Override
public QpsController getOrCreate(String keyOwner) {
if (keyOwner == null) {
if (globalQpsController == null) {
synchronized (lockObj) {
if (globalQpsController == null) {
DynamicProperty property =
DynamicProperty.getInstance(Config.PROVIDER_LIMIT_KEY_GLOBAL);
globalQpsController = new QpsController(keyOwner, getIntegerLimitProperty(property));
property.addCallback(() -> {
globalQpsController.setQpsLimit(getIntegerLimitProperty(property));
});
}
}
}
return globalQpsController;
} else {
return super.getOrCreate(keyOwner);
}
}
示例3: initConfig
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
private void initConfig(String key) {
if (watchedKeySet.contains(key)) {
return;
}
watchedKeySet.add(key);
String configKey = Config.PROVIDER_LIMIT_KEY_PREFIX + key;
DynamicProperty property = DynamicProperty.getInstance(configKey);
initQpsLimit(key, getIntegerLimitProperty(property));
property.addCallback(() -> {
updateQpsLimit(key, getIntegerLimitProperty(property));
QpsController qpsController = findReference(key);
objMap.put(key, qpsController);
});
}
示例4: getResponse
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
private Observable<HttpClientResponse<ByteBuf>> getResponse(String externalHealthCheckURL) {
String host = "localhost";
int port = DEFAULT_APPLICATION_PORT;
String path = "/healthcheck";
try {
URL url = new URL(externalHealthCheckURL);
host = url.getHost();
port = url.getPort();
path = url.getPath();
} catch (MalformedURLException e) {
//continue
}
Integer timeout = DynamicProperty.getInstance("prana.host.healthcheck.timeout").getInteger(DEFAULT_CONNECTION_TIMEOUT);
HttpClient<ByteBuf, ByteBuf> httpClient = RxNetty.<ByteBuf, ByteBuf>newHttpClientBuilder(host, port)
.pipelineConfigurator(PipelineConfigurators.<ByteBuf, ByteBuf>httpClientConfigurator())
.channelOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, timeout)
.build();
return httpClient.submit(HttpClientRequest.createGet(path));
}
示例5: getProperty
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
protected Object getProperty(String key) {
if (enableDynamicProperties) {
String dynamicValue = null;
DynamicStringProperty dynamicProperty = dynamicProperties.get(key);
if (dynamicProperty != null) {
dynamicValue = dynamicProperty.get();
}
if (dynamicValue == null) {
dynamicValue = DynamicProperty.getInstance(getConfigKey(key)).getString();
if (dynamicValue == null) {
dynamicValue = DynamicProperty.getInstance(getDefaultPropName(key)).getString();
}
}
if (dynamicValue != null) {
return dynamicValue;
}
}
return properties.get(key);
}
示例6: getIntegerLimitProperty
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
private Integer getIntegerLimitProperty(DynamicProperty property) {
try {
return property.getInteger();
} catch (IllegalArgumentException e) {
LOGGER.error(e.getMessage());
return null;
}
}
示例7: close
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
@PreDestroy
public void close() {
if (defaultURLConfig != null) {
defaultURLConfig.stopLoading();
}
setStatic(ConfigurationManager.class, "instance", null);
setStatic(ConfigurationManager.class, "customConfigurationInstalled", false);
setStatic(DynamicPropertyFactory.class, "config", null);
setStatic(DynamicPropertyFactory.class, "initializedWithDefaultConfig", false);
setStatic(DynamicProperty.class, "dynamicPropertySupportImpl", null);
initialized.compareAndSet(true, false);
}
示例8: handle
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
@Override
Observable<Void> handle(final Context context) {
String externalHealthCheckURL = DynamicProperty.getInstance("prana.host.healthcheck.url")
.getString(DEFAULT_HEALTHCHECK_ENDPOINT);
context.setHeader("Content-type", DEFAULT_CONTENT_TYPE);
if (Strings.isNullOrEmpty(externalHealthCheckURL)) {
return context.sendSimple(DEFAULT_OK_HEALTH);
} else {
return getResponse(externalHealthCheckURL).flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<Void>>() {
@Override
public Observable<Void> call(HttpClientResponse<ByteBuf> response) {
if (response.getStatus().code() == HttpResponseStatus.OK.code()) {
context.sendSimple(DEFAULT_OK_HEALTH);
} else {
context.sendError(HttpResponseStatus.SERVICE_UNAVAILABLE, DEFAULT_FAIL_HEALTH);
}
return DEFAULT_NOOP_RESPONSE;
}
}).onErrorFlatMap(new Func1<OnErrorThrowable, Observable<Void>>() {
@Override
public Observable<Void> call(OnErrorThrowable onErrorThrowable) {
context.sendError(HttpResponseStatus.SERVICE_UNAVAILABLE, DEFAULT_FAIL_HEALTH);
return DEFAULT_NOOP_RESPONSE;
}
});
}
}
示例9: handle
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
@Override
Observable<Void> handle(Context context) {
Map<String, String> properties = new HashMap<>();
List<String> ids = context.getQueryParams(ID_QUERY_PARAMETER);
for (String id : ids) {
String property = DynamicProperty.getInstance(id).getString(null);
properties.put(id, property);
}
return context.send(properties);
}
示例10: DynamicPropertyBasedPoolStrategy
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
public DynamicPropertyBasedPoolStrategy(final int maxConnections, String propertyName) {
super(maxConnections);
poolSizeProperty = DynamicProperty.getInstance(propertyName);
setMaxConnections(poolSizeProperty.getInteger(maxConnections));
poolSizeProperty.addCallback(new Runnable() {
@Override
public void run() {
setMaxConnections(poolSizeProperty.getInteger(maxConnections));
};
});
}
示例11: PropertyFactory
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
private PropertyFactory(String prefix, String propName, String workerName) {
this.global = DynamicProperty.getInstance(prefix + "." + propName);
this.local = DynamicProperty.getInstance(prefix + "." + workerName + "." + propName);
}
示例12: isCloudDataCenter
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
private boolean isCloudDataCenter() {
return "cloud".equals(DynamicProperty.getInstance("eureka.datacenter").getString());
}
示例13: DynamicListenableSupplier
import com.netflix.config.DynamicProperty; //导入依赖的package包/类
DynamicListenableSupplier(DynamicProperty prop) {
this.prop = prop;
}