Java Code Examples for com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule#getParamItem()

The following examples show how to use com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule#getParamItem() . 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: GatewayFlowRuleEntity.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
public static GatewayFlowRuleEntity fromGatewayFlowRule(String app, String ip, Integer port, GatewayFlowRule rule) {
    GatewayFlowRuleEntity entity = new GatewayFlowRuleEntity();
    entity.setApp(app);
    entity.setIp(ip);
    entity.setPort(port);

    entity.setResource(rule.getResource());
    entity.setResourceMode(rule.getResourceMode());

    entity.setGrade(rule.getGrade());
    entity.setCount(rule.getCount());
    Object[] intervalSecResult = parseIntervalSec(rule.getIntervalSec());
    entity.setInterval((Long) intervalSecResult[0]);
    entity.setIntervalUnit((Integer) intervalSecResult[1]);

    entity.setControlBehavior(rule.getControlBehavior());
    entity.setBurst(rule.getBurst());
    entity.setMaxQueueingTimeoutMs(rule.getMaxQueueingTimeoutMs());

    GatewayParamFlowItem paramItem = rule.getParamItem();
    if (paramItem != null) {
        GatewayParamFlowItemEntity itemEntity = new GatewayParamFlowItemEntity();
        entity.setParamItem(itemEntity);
        itemEntity.setParseStrategy(paramItem.getParseStrategy());
        itemEntity.setFieldName(paramItem.getFieldName());
        itemEntity.setPattern(paramItem.getPattern());
        itemEntity.setMatchStrategy(paramItem.getMatchStrategy());
    }

    return entity;
}
 
Example 2
Source File: GatewayFlowRuleEntity.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
public static GatewayFlowRuleEntity fromGatewayFlowRule(String app, String ip, Integer port, GatewayFlowRule rule) {
    GatewayFlowRuleEntity entity = new GatewayFlowRuleEntity();
    entity.setApp(app);
    entity.setIp(ip);
    entity.setPort(port);

    entity.setResource(rule.getResource());
    entity.setResourceMode(rule.getResourceMode());

    entity.setGrade(rule.getGrade());
    entity.setCount(rule.getCount());
    Object[] intervalSecResult = parseIntervalSec(rule.getIntervalSec());
    entity.setInterval((Long) intervalSecResult[0]);
    entity.setIntervalUnit((Integer) intervalSecResult[1]);

    entity.setControlBehavior(rule.getControlBehavior());
    entity.setBurst(rule.getBurst());
    entity.setMaxQueueingTimeoutMs(rule.getMaxQueueingTimeoutMs());

    GatewayParamFlowItem paramItem = rule.getParamItem();
    if (paramItem != null) {
        GatewayParamFlowItemEntity itemEntity = new GatewayParamFlowItemEntity();
        entity.setParamItem(itemEntity);
        itemEntity.setParseStrategy(paramItem.getParseStrategy());
        itemEntity.setFieldName(paramItem.getFieldName());
        itemEntity.setPattern(paramItem.getPattern());
        itemEntity.setMatchStrategy(paramItem.getMatchStrategy());
    }

    return entity;
}