use of com.dtp.common.config.DtpProperties in project dynamic-tp by lyh200.
the class AbstractRefresher method doRefresh.
private void doRefresh(Map<Object, Object> properties) {
ConfigurationPropertySource sources = new MapConfigurationPropertySource(properties);
Binder binder = new Binder(sources);
DtpProperties bindDtpProperties = binder.bind(DynamicTpConst.MAIN_PROPERTIES_PREFIX, Bindable.ofInstance(dtpProperties)).get();
DtpRegistry.refresh(bindDtpProperties);
publishEvent();
}
use of com.dtp.common.config.DtpProperties in project dynamic-tp by lyh200.
the class AbstractWebServerTpHandler method onApplicationEvent.
@Override
public void onApplicationEvent(ServletWebServerInitializedEvent event) {
try {
DtpProperties dtpProperties = ApplicationContextHolder.getBean(DtpProperties.class);
updateWebServerTp(dtpProperties);
} catch (Exception e) {
log.error("Init web server thread pool failed.", e);
}
}
use of com.dtp.common.config.DtpProperties in project dynamic-tp by dromara.
the class ZkConfigEnvironmentProcessor method postProcessEnvironment.
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
DtpProperties dtpProperties = new DtpProperties();
PropertiesBinder.bindDtpProperties(environment, dtpProperties);
Map<Object, Object> properties = CuratorUtil.genPropertiesMap(dtpProperties);
if (!checkPropertyExist(environment)) {
createZkPropertySource(environment, properties);
}
}
use of com.dtp.common.config.DtpProperties in project dynamic-tp by dromara.
the class ZookeeperRefresher method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
final ConnectionStateListener connectionStateListener = (client, newState) -> {
if (newState == ConnectionState.RECONNECTED) {
loadAndRefresh();
}
};
final CuratorListener curatorListener = (client, curatorEvent) -> {
final WatchedEvent watchedEvent = curatorEvent.getWatchedEvent();
if (null != watchedEvent) {
switch(watchedEvent.getType()) {
case NodeChildrenChanged:
case NodeDataChanged:
loadAndRefresh();
break;
default:
break;
}
}
};
CuratorFramework curatorFramework = CuratorUtil.getCuratorFramework(dtpProperties);
String nodePath = CuratorUtil.nodePath(dtpProperties);
curatorFramework.getConnectionStateListenable().addListener(connectionStateListener);
curatorFramework.getCuratorListenable().addListener(curatorListener);
log.info("DynamicTp refresher, add listener success, nodePath: {}", nodePath);
}
use of com.dtp.common.config.DtpProperties in project dynamic-tp by dromara.
the class AbstractDtpHandler method onApplicationEvent.
@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
try {
DtpProperties dtpProperties = ApplicationContextHolder.getBean(DtpProperties.class);
updateTp(dtpProperties);
} catch (Exception e) {
log.error("Init third party thread pool failed.", e);
}
}
Aggregations