com.nepxion.discovery.plugin.admincenter.resource.SentinelParamResourceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-plugin-admin-center-starter Show documentation
Show all versions of discovery-plugin-admin-center-starter Show documentation
Nepxion Discovery is a solution for Spring Cloud with blue green, gray, weight, limitation, circuit breaker, degrade, isolation, monitor, tracing, dye, failover, async agent
The newest version!
package com.nepxion.discovery.plugin.admincenter.resource;
import java.util.ArrayList;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.csp.sentinel.datasource.Converter;
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRuleManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
public class SentinelParamResourceImpl implements SentinelParamResource {
private static final Logger LOG = LoggerFactory.getLogger(SentinelParamResourceImpl.class);
private static Converter> sentinelParamFlowRuleParser = new Converter>() {
@Override
public List convert(String source) {
return JSON.parseObject(source, new TypeReference>() {
});
}
};
@Override
public void updateParamFlowRules(String rule) {
ParamFlowRuleManager.loadRules(sentinelParamFlowRuleParser.convert(rule));
LOG.info("{} param flow rules loaded...", ParamFlowRuleManager.getRules().size());
}
@Override
public void clearParamFlowRules() {
LOG.info("{} param flow rules cleared...", ParamFlowRuleManager.getRules().size());
ParamFlowRuleManager.loadRules(new ArrayList());
}
@Override
public List viewParamFlowRules() {
return ParamFlowRuleManager.getRules();
}
}