Search in sources :

Example 6 with CircuitBreakerStatus

use of com.tencent.polaris.api.pojo.CircuitBreakerStatus 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 : StatusDimension(com.tencent.polaris.api.pojo.StatusDimension) CircuitBreakerStatus(com.tencent.polaris.api.pojo.CircuitBreakerStatus)

Example 7 with CircuitBreakerStatus

use of com.tencent.polaris.api.pojo.CircuitBreakerStatus 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 8 with CircuitBreakerStatus

use of com.tencent.polaris.api.pojo.CircuitBreakerStatus 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 9 with CircuitBreakerStatus

use of com.tencent.polaris.api.pojo.CircuitBreakerStatus 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

CircuitBreakerStatus (com.tencent.polaris.api.pojo.CircuitBreakerStatus)9 StatusDimension (com.tencent.polaris.api.pojo.StatusDimension)5 Instance (com.tencent.polaris.api.pojo.Instance)2 HashMap (java.util.HashMap)2 Configuration (com.tencent.polaris.api.config.Configuration)1 ConsumerAPI (com.tencent.polaris.api.core.ConsumerAPI)1 ResultKey (com.tencent.polaris.api.plugin.circuitbreaker.CircuitBreakResult.ResultKey)1 InstanceProperty (com.tencent.polaris.api.plugin.registry.InstanceProperty)1 DefaultCircuitBreakResult (com.tencent.polaris.api.plugin.stat.DefaultCircuitBreakResult)1 DetectResult (com.tencent.polaris.api.pojo.DetectResult)1 GetInstancesRequest (com.tencent.polaris.api.rpc.GetInstancesRequest)1 InstancesResponse (com.tencent.polaris.api.rpc.InstancesResponse)1 ServiceCallResult (com.tencent.polaris.api.rpc.ServiceCallResult)1 InstanceByProto (com.tencent.polaris.client.pojo.InstanceByProto)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.junit.Test)1