Search in sources :

Example 1 with HystrixThreadPoolUtilization

use of com.netflix.hystrix.metric.sample.HystrixThreadPoolUtilization in project Hystrix by Netflix.

the class HystrixUtilizationJsonStream method convertToJson.

protected static String convertToJson(HystrixUtilization utilization) throws IOException {
    StringWriter jsonString = new StringWriter();
    JsonGenerator json = jsonFactory.createGenerator(jsonString);
    json.writeStartObject();
    json.writeStringField("type", "HystrixUtilization");
    json.writeObjectFieldStart("commands");
    for (Map.Entry<HystrixCommandKey, HystrixCommandUtilization> entry : utilization.getCommandUtilizationMap().entrySet()) {
        final HystrixCommandKey key = entry.getKey();
        final HystrixCommandUtilization commandUtilization = entry.getValue();
        writeCommandUtilizationJson(json, key, commandUtilization);
    }
    json.writeEndObject();
    json.writeObjectFieldStart("threadpools");
    for (Map.Entry<HystrixThreadPoolKey, HystrixThreadPoolUtilization> entry : utilization.getThreadPoolUtilizationMap().entrySet()) {
        final HystrixThreadPoolKey threadPoolKey = entry.getKey();
        final HystrixThreadPoolUtilization threadPoolUtilization = entry.getValue();
        writeThreadPoolUtilizationJson(json, threadPoolKey, threadPoolUtilization);
    }
    json.writeEndObject();
    json.writeEndObject();
    json.close();
    return jsonString.getBuffer().toString();
}
Also used : HystrixCommandKey(com.netflix.hystrix.HystrixCommandKey) StringWriter(java.io.StringWriter) HystrixThreadPoolUtilization(com.netflix.hystrix.metric.sample.HystrixThreadPoolUtilization) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) HystrixThreadPoolKey(com.netflix.hystrix.HystrixThreadPoolKey) Map(java.util.Map) HystrixCommandUtilization(com.netflix.hystrix.metric.sample.HystrixCommandUtilization)

Example 2 with HystrixThreadPoolUtilization

use of com.netflix.hystrix.metric.sample.HystrixThreadPoolUtilization in project Hystrix by Netflix.

the class SerialHystrixUtilization method serializeUtilization.

private static void serializeUtilization(HystrixUtilization utilization, JsonGenerator json) {
    try {
        json.writeStartObject();
        json.writeStringField("type", "HystrixUtilization");
        json.writeObjectFieldStart("commands");
        for (Map.Entry<HystrixCommandKey, HystrixCommandUtilization> entry : utilization.getCommandUtilizationMap().entrySet()) {
            final HystrixCommandKey key = entry.getKey();
            final HystrixCommandUtilization commandUtilization = entry.getValue();
            writeCommandUtilizationJson(json, key, commandUtilization);
        }
        json.writeEndObject();
        json.writeObjectFieldStart("threadpools");
        for (Map.Entry<HystrixThreadPoolKey, HystrixThreadPoolUtilization> entry : utilization.getThreadPoolUtilizationMap().entrySet()) {
            final HystrixThreadPoolKey threadPoolKey = entry.getKey();
            final HystrixThreadPoolUtilization threadPoolUtilization = entry.getValue();
            writeThreadPoolUtilizationJson(json, threadPoolKey, threadPoolUtilization);
        }
        json.writeEndObject();
        json.writeEndObject();
        json.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : HystrixCommandKey(com.netflix.hystrix.HystrixCommandKey) HystrixThreadPoolUtilization(com.netflix.hystrix.metric.sample.HystrixThreadPoolUtilization) HystrixThreadPoolKey(com.netflix.hystrix.HystrixThreadPoolKey) Map(java.util.Map) HystrixCommandUtilization(com.netflix.hystrix.metric.sample.HystrixCommandUtilization) IOException(java.io.IOException)

Aggregations

HystrixCommandKey (com.netflix.hystrix.HystrixCommandKey)2 HystrixThreadPoolKey (com.netflix.hystrix.HystrixThreadPoolKey)2 HystrixCommandUtilization (com.netflix.hystrix.metric.sample.HystrixCommandUtilization)2 HystrixThreadPoolUtilization (com.netflix.hystrix.metric.sample.HystrixThreadPoolUtilization)2 Map (java.util.Map)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1