Search in sources :

Example 1 with HystrixEventType

use of com.netflix.hystrix.HystrixEventType in project Hystrix by Netflix.

the class CommandStreamTest method bucketToString.

protected static String bucketToString(long[] eventCounts) {
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    for (HystrixEventType eventType : HystrixEventType.values()) {
        if (eventCounts[eventType.ordinal()] > 0) {
            sb.append(eventType.name()).append("->").append(eventCounts[eventType.ordinal()]).append(", ");
        }
    }
    sb.append("]");
    return sb.toString();
}
Also used : HystrixEventType(com.netflix.hystrix.HystrixEventType)

Example 2 with HystrixEventType

use of com.netflix.hystrix.HystrixEventType in project Hystrix by Netflix.

the class SerialHystrixRequestEvents method convertExecutionToJson.

private static void convertExecutionToJson(JsonGenerator json, HystrixRequestEvents.ExecutionSignature executionSignature, List<Integer> latencies) throws IOException {
    json.writeStartObject();
    json.writeStringField("name", executionSignature.getCommandName());
    json.writeArrayFieldStart("events");
    ExecutionResult.EventCounts eventCounts = executionSignature.getEventCounts();
    for (HystrixEventType eventType : HystrixEventType.values()) {
        if (!eventType.equals(HystrixEventType.COLLAPSED)) {
            if (eventCounts.contains(eventType)) {
                int eventCount = eventCounts.getCount(eventType);
                if (eventCount > 1) {
                    json.writeStartObject();
                    json.writeStringField("name", eventType.name());
                    json.writeNumberField("count", eventCount);
                    json.writeEndObject();
                } else {
                    json.writeString(eventType.name());
                }
            }
        }
    }
    json.writeEndArray();
    json.writeArrayFieldStart("latencies");
    for (int latency : latencies) {
        json.writeNumber(latency);
    }
    json.writeEndArray();
    if (executionSignature.getCachedCount() > 0) {
        json.writeNumberField("cached", executionSignature.getCachedCount());
    }
    if (executionSignature.getEventCounts().contains(HystrixEventType.COLLAPSED)) {
        json.writeObjectFieldStart("collapsed");
        json.writeStringField("name", executionSignature.getCollapserKey().name());
        json.writeNumberField("count", executionSignature.getCollapserBatchSize());
        json.writeEndObject();
    }
    json.writeEndObject();
}
Also used : HystrixEventType(com.netflix.hystrix.HystrixEventType) ExecutionResult(com.netflix.hystrix.ExecutionResult)

Example 3 with HystrixEventType

use of com.netflix.hystrix.HystrixEventType in project Hystrix by Netflix.

the class HystrixRequestEventsJsonStream method convertExecutionToJson.

private static void convertExecutionToJson(JsonGenerator json, HystrixRequestEvents.ExecutionSignature executionSignature, List<Integer> latencies) throws IOException {
    json.writeStartObject();
    json.writeStringField("name", executionSignature.getCommandName());
    json.writeArrayFieldStart("events");
    ExecutionResult.EventCounts eventCounts = executionSignature.getEventCounts();
    for (HystrixEventType eventType : HystrixEventType.values()) {
        if (eventType != HystrixEventType.COLLAPSED) {
            if (eventCounts.contains(eventType)) {
                int eventCount = eventCounts.getCount(eventType);
                if (eventCount > 1) {
                    json.writeStartObject();
                    json.writeStringField("name", eventType.name());
                    json.writeNumberField("count", eventCount);
                    json.writeEndObject();
                } else {
                    json.writeString(eventType.name());
                }
            }
        }
    }
    json.writeEndArray();
    json.writeArrayFieldStart("latencies");
    for (int latency : latencies) {
        json.writeNumber(latency);
    }
    json.writeEndArray();
    if (executionSignature.getCachedCount() > 0) {
        json.writeNumberField("cached", executionSignature.getCachedCount());
    }
    if (executionSignature.getEventCounts().contains(HystrixEventType.COLLAPSED)) {
        json.writeObjectFieldStart("collapsed");
        json.writeStringField("name", executionSignature.getCollapserKey().name());
        json.writeNumberField("count", executionSignature.getCollapserBatchSize());
        json.writeEndObject();
    }
    json.writeEndObject();
}
Also used : HystrixEventType(com.netflix.hystrix.HystrixEventType) ExecutionResult(com.netflix.hystrix.ExecutionResult)

Example 4 with HystrixEventType

use of com.netflix.hystrix.HystrixEventType in project Hystrix by Netflix.

the class HystrixCommandCompletion method toString.

@Override
public String toString() {
    StringBuffer sb = new StringBuffer();
    List<HystrixEventType> foundEventTypes = new ArrayList<HystrixEventType>();
    sb.append(getCommandKey().name()).append("[");
    for (HystrixEventType eventType : ALL_EVENT_TYPES) {
        if (executionResult.getEventCounts().contains(eventType)) {
            foundEventTypes.add(eventType);
        }
    }
    int i = 0;
    for (HystrixEventType eventType : foundEventTypes) {
        sb.append(eventType.name());
        int eventCount = executionResult.getEventCounts().getCount(eventType);
        if (eventCount > 1) {
            sb.append("x").append(eventCount);
        }
        if (i < foundEventTypes.size() - 1) {
            sb.append(", ");
        }
        i++;
    }
    sb.append("][").append(getExecutionLatency()).append(" ms]");
    return sb.toString();
}
Also used : HystrixEventType(com.netflix.hystrix.HystrixEventType) ArrayList(java.util.ArrayList)

Aggregations

HystrixEventType (com.netflix.hystrix.HystrixEventType)4 ExecutionResult (com.netflix.hystrix.ExecutionResult)2 ArrayList (java.util.ArrayList)1