Search in sources :

Example 1 with HystrixThreadPoolConfiguration

use of com.netflix.hystrix.config.HystrixThreadPoolConfiguration in project Hystrix by Netflix.

the class HystrixConfigurationJsonStream method convertToString.

public static String convertToString(HystrixConfiguration config) throws IOException {
    StringWriter jsonString = new StringWriter();
    JsonGenerator json = jsonFactory.createGenerator(jsonString);
    json.writeStartObject();
    json.writeStringField("type", "HystrixConfig");
    json.writeObjectFieldStart("commands");
    for (Map.Entry<HystrixCommandKey, HystrixCommandConfiguration> entry : config.getCommandConfig().entrySet()) {
        final HystrixCommandKey key = entry.getKey();
        final HystrixCommandConfiguration commandConfig = entry.getValue();
        writeCommandConfigJson(json, key, commandConfig);
    }
    json.writeEndObject();
    json.writeObjectFieldStart("threadpools");
    for (Map.Entry<HystrixThreadPoolKey, HystrixThreadPoolConfiguration> entry : config.getThreadPoolConfig().entrySet()) {
        final HystrixThreadPoolKey threadPoolKey = entry.getKey();
        final HystrixThreadPoolConfiguration threadPoolConfig = entry.getValue();
        writeThreadPoolConfigJson(json, threadPoolKey, threadPoolConfig);
    }
    json.writeEndObject();
    json.writeObjectFieldStart("collapsers");
    for (Map.Entry<HystrixCollapserKey, HystrixCollapserConfiguration> entry : config.getCollapserConfig().entrySet()) {
        final HystrixCollapserKey collapserKey = entry.getKey();
        final HystrixCollapserConfiguration collapserConfig = entry.getValue();
        writeCollapserConfigJson(json, collapserKey, collapserConfig);
    }
    json.writeEndObject();
    json.writeEndObject();
    json.close();
    return jsonString.getBuffer().toString();
}
Also used : HystrixCommandKey(com.netflix.hystrix.HystrixCommandKey) StringWriter(java.io.StringWriter) HystrixCommandConfiguration(com.netflix.hystrix.config.HystrixCommandConfiguration) HystrixCollapserKey(com.netflix.hystrix.HystrixCollapserKey) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) HystrixThreadPoolKey(com.netflix.hystrix.HystrixThreadPoolKey) Map(java.util.Map) HystrixCollapserConfiguration(com.netflix.hystrix.config.HystrixCollapserConfiguration) HystrixThreadPoolConfiguration(com.netflix.hystrix.config.HystrixThreadPoolConfiguration)

Example 2 with HystrixThreadPoolConfiguration

use of com.netflix.hystrix.config.HystrixThreadPoolConfiguration in project Hystrix by Netflix.

the class SerialHystrixConfiguration method serializeConfiguration.

private static void serializeConfiguration(HystrixConfiguration config, JsonGenerator json) {
    try {
        json.writeStartObject();
        json.writeStringField("type", "HystrixConfig");
        json.writeObjectFieldStart("commands");
        for (Map.Entry<HystrixCommandKey, HystrixCommandConfiguration> entry : config.getCommandConfig().entrySet()) {
            final HystrixCommandKey key = entry.getKey();
            final HystrixCommandConfiguration commandConfig = entry.getValue();
            writeCommandConfigJson(json, key, commandConfig);
        }
        json.writeEndObject();
        json.writeObjectFieldStart("threadpools");
        for (Map.Entry<HystrixThreadPoolKey, HystrixThreadPoolConfiguration> entry : config.getThreadPoolConfig().entrySet()) {
            final HystrixThreadPoolKey threadPoolKey = entry.getKey();
            final HystrixThreadPoolConfiguration threadPoolConfig = entry.getValue();
            writeThreadPoolConfigJson(json, threadPoolKey, threadPoolConfig);
        }
        json.writeEndObject();
        json.writeObjectFieldStart("collapsers");
        for (Map.Entry<HystrixCollapserKey, HystrixCollapserConfiguration> entry : config.getCollapserConfig().entrySet()) {
            final HystrixCollapserKey collapserKey = entry.getKey();
            final HystrixCollapserConfiguration collapserConfig = entry.getValue();
            writeCollapserConfigJson(json, collapserKey, collapserConfig);
        }
        json.writeEndObject();
        json.writeEndObject();
        json.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : HystrixCommandKey(com.netflix.hystrix.HystrixCommandKey) HystrixCommandConfiguration(com.netflix.hystrix.config.HystrixCommandConfiguration) HystrixCollapserKey(com.netflix.hystrix.HystrixCollapserKey) HystrixThreadPoolKey(com.netflix.hystrix.HystrixThreadPoolKey) Map(java.util.Map) HystrixCollapserConfiguration(com.netflix.hystrix.config.HystrixCollapserConfiguration) IOException(java.io.IOException) HystrixThreadPoolConfiguration(com.netflix.hystrix.config.HystrixThreadPoolConfiguration)

Aggregations

HystrixCollapserKey (com.netflix.hystrix.HystrixCollapserKey)2 HystrixCommandKey (com.netflix.hystrix.HystrixCommandKey)2 HystrixThreadPoolKey (com.netflix.hystrix.HystrixThreadPoolKey)2 HystrixCollapserConfiguration (com.netflix.hystrix.config.HystrixCollapserConfiguration)2 HystrixCommandConfiguration (com.netflix.hystrix.config.HystrixCommandConfiguration)2 HystrixThreadPoolConfiguration (com.netflix.hystrix.config.HystrixThreadPoolConfiguration)2 Map (java.util.Map)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1