use of com.hummer.doorgod.service.domain.configuration.DoorGoodConfig in project hummer-framework by hummer-team.
the class ListenerConfig method getListener.
private Listener getListener() {
return new Listener() {
@Override
public Executor getExecutor() {
return null;
}
@Override
public void receiveConfigInfo(String configInfo) {
if (Strings.isNullOrEmpty(configInfo)) {
return;
}
log.debug("refresh config done,config value is \n{}", configInfo);
// parse config instance
DoorGoodConfig doorGoodConfig = JSON.parseObject(configInfo, new TypeReference<DoorGoodConfig>() {
});
// refresh gateway config
refreshGatewayRule(doorGoodConfig);
// refresh sentinel config
refreshSentinelConfig(doorGoodConfig);
}
};
}
use of com.hummer.doorgod.service.domain.configuration.DoorGoodConfig in project hummer-framework by hummer-team.
the class ListenerConfig method addListener.
private void addListener(List<String> gatewayGroup, String groupId, long timeoutMillis, ConfigService configService, boolean isFirstLoading) throws NacosException {
Set<DegradeRule> degradeRules = Sets.newConcurrentHashSet();
Set<GatewayFlowRule> gatewayFlowRules = Sets.newConcurrentHashSet();
Set<ApiDefinition> apiDefinitions = Sets.newConcurrentHashSet();
for (String dataId : gatewayGroup) {
Listener listener = getListener();
String configVal = configService.getConfigAndSignListener(dataId, groupId, timeoutMillis, listener);
if (!Strings.isNullOrEmpty(configVal)) {
// refresh gateway config
log.debug("refresh config done,config value is \n{}", configVal);
DoorGoodConfig doorGoodConfig = JSON.parseObject(configVal, new TypeReference<DoorGoodConfig>() {
});
refreshGatewayRule(doorGoodConfig);
listenerMap.put(dataId, ListenerEvent.builder().dataId(dataId).groupId(groupId).listener(listener).sentinelConfig(doorGoodConfig.getSentinelConfig()).build());
if (isFirstLoading) {
addSentinelConfigForInitLoad(degradeRules, gatewayFlowRules, apiDefinitions, doorGoodConfig);
} else {
// refresh sentinel config
refreshSentinelConfig(doorGoodConfig);
}
}
}
firstLoadingSentinel(isFirstLoading, degradeRules, gatewayFlowRules, apiDefinitions);
}
Aggregations