Search in sources :

Example 6 with StatusDimension

use of com.tencent.polaris.api.pojo.StatusDimension in project polaris-java-agent by polarismesh.

the class InstanceInvoker method stringToCircuitBreakers.

public static Map<StatusDimension, CircuitBreakerStatus> stringToCircuitBreakers(String value) {
    Map<StatusDimension, CircuitBreakerStatus> values = new HashMap<>();
    if (null == value || value.length() == 0) {
        return values;
    }
    String[] tokens = value.split(SEP_CIRCUIT_BREAKER);
    for (String token : tokens) {
        String[] splits = token.split(SEP_CIRCUIT_BREAKER_VALUE);
        if (splits.length != 2) {
            continue;
        }
        StatusDimension dimension = new StatusDimension(splits[0], null);
        CircuitBreakerStatus circuitBreakerStatus = new CircuitBreakerStatus("", Status.valueOf(splits[1]), 0);
        values.put(dimension, circuitBreakerStatus);
    }
    return values;
}
Also used : StatusDimension(com.tencent.polaris.api.pojo.StatusDimension) CircuitBreakerStatus(com.tencent.polaris.api.pojo.CircuitBreakerStatus)

Example 7 with StatusDimension

use of com.tencent.polaris.api.pojo.StatusDimension in project polaris-java-agent by polarismesh.

the class InstanceInvoker method stringToCircuitBreakers.

public static Map<StatusDimension, CircuitBreakerStatus> stringToCircuitBreakers(String value) {
    Map<StatusDimension, CircuitBreakerStatus> values = new HashMap<>();
    if (null == value || value.length() == 0) {
        return values;
    }
    String[] tokens = value.split(SEP_CIRCUIT_BREAKER);
    for (String token : tokens) {
        String[] splits = token.split(SEP_CIRCUIT_BREAKER_VALUE);
        if (splits.length != 2) {
            continue;
        }
        StatusDimension dimension = new StatusDimension(splits[0], null);
        CircuitBreakerStatus circuitBreakerStatus = new CircuitBreakerStatus("", Status.valueOf(splits[1]), 0);
        values.put(dimension, circuitBreakerStatus);
    }
    return values;
}
Also used : HashMap(java.util.HashMap) StatusDimension(com.tencent.polaris.api.pojo.StatusDimension) CircuitBreakerStatus(com.tencent.polaris.api.pojo.CircuitBreakerStatus)

Example 8 with StatusDimension

use of com.tencent.polaris.api.pojo.StatusDimension in project polaris-java-agent by polarismesh.

the class InstanceInvoker method circuitBreakersToString.

public static String circuitBreakersToString(Instance instance) {
    List<String> values = new ArrayList<>();
    Collection<StatusDimension> statusDimensions = instance.getStatusDimensions();
    if (null != statusDimensions && statusDimensions.size() > 0) {
        for (StatusDimension statusDimension : statusDimensions) {
            CircuitBreakerStatus circuitBreakerStatus = instance.getCircuitBreakerStatus(statusDimension);
            if (null != circuitBreakerStatus) {
                values.add(statusDimension.getMethod() + SEP_CIRCUIT_BREAKER_VALUE + circuitBreakerStatus.getStatus().name());
            }
        }
    }
    if (values.isEmpty()) {
        return "";
    }
    return String.join(SEP_CIRCUIT_BREAKER, values.toArray(new String[0]));
}
Also used : ArrayList(java.util.ArrayList) StatusDimension(com.tencent.polaris.api.pojo.StatusDimension) CircuitBreakerStatus(com.tencent.polaris.api.pojo.CircuitBreakerStatus)

Aggregations

StatusDimension (com.tencent.polaris.api.pojo.StatusDimension)8 CircuitBreakerStatus (com.tencent.polaris.api.pojo.CircuitBreakerStatus)5 Instance (com.tencent.polaris.api.pojo.Instance)3 CircuitBreakerConfig (com.tencent.polaris.api.config.consumer.CircuitBreakerConfig)2 OutlierDetectionConfig (com.tencent.polaris.api.config.consumer.OutlierDetectionConfig)2 CircuitBreakResult (com.tencent.polaris.api.plugin.circuitbreaker.CircuitBreakResult)2 ResultKey (com.tencent.polaris.api.plugin.circuitbreaker.CircuitBreakResult.ResultKey)2 InstanceLocalValue (com.tencent.polaris.api.pojo.InstanceLocalValue)2 RetStatus (com.tencent.polaris.api.pojo.RetStatus)2 RecoverConfig (com.tencent.polaris.client.pb.CircuitBreakerProto.RecoverConfig)2 InstanceByProto (com.tencent.polaris.client.pojo.InstanceByProto)2 HalfOpenConfig (com.tencent.polaris.plugins.circuitbreaker.common.HalfOpenConfig)2 HalfOpenCounter (com.tencent.polaris.plugins.circuitbreaker.common.HalfOpenCounter)2 DefaultPlugins (com.tencent.polaris.api.config.plugin.DefaultPlugins)1 PluginConfigProvider (com.tencent.polaris.api.config.plugin.PluginConfigProvider)1 Verifier (com.tencent.polaris.api.config.verify.Verifier)1 Destroyable (com.tencent.polaris.api.control.Destroyable)1 ErrorCode (com.tencent.polaris.api.exception.ErrorCode)1 PolarisException (com.tencent.polaris.api.exception.PolarisException)1 PluginType (com.tencent.polaris.api.plugin.PluginType)1