diff --git a/hystrix-serialization/build.gradle b/hystrix-serialization/build.gradle index f9919395f..f20c021ba 100644 --- a/hystrix-serialization/build.gradle +++ b/hystrix-serialization/build.gradle @@ -14,7 +14,6 @@ dependencies { compileApi 'com.fasterxml.jackson.core:jackson-databind:2.7.5' compileApi 'com.fasterxml.jackson.core:jackson-annotations:2.7.5' compile 'com.fasterxml.jackson.module:jackson-module-afterburner:2.7.5' - compileApi 'com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.7.5' testCompile 'junit:junit-dep:4.10' testCompile 'org.mockito:mockito-all:1.9.5' diff --git a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixConfiguration.java b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixConfiguration.java index 03c8dd82b..cd0179d01 100644 --- a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixConfiguration.java +++ b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixConfiguration.java @@ -16,12 +16,8 @@ package com.netflix.hystrix.serial; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.dataformat.cbor.CBORParser; import com.netflix.hystrix.HystrixCollapserKey; -import com.netflix.hystrix.HystrixCommandGroupKey; import com.netflix.hystrix.HystrixCommandKey; -import com.netflix.hystrix.HystrixCommandProperties; import com.netflix.hystrix.HystrixThreadPoolKey; import com.netflix.hystrix.config.HystrixCollapserConfiguration; import com.netflix.hystrix.config.HystrixCommandConfiguration; @@ -30,33 +26,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringWriter; import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Iterator; import java.util.Map; public class SerialHystrixConfiguration extends SerialHystrixMetric { private static final Logger logger = LoggerFactory.getLogger(SerialHystrixConfiguration.class); + @Deprecated public static byte[] toBytes(HystrixConfiguration config) { - byte[] retVal = null; - - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - JsonGenerator cbor = cborFactory.createGenerator(bos); - - serializeConfiguration(config, cbor); - - retVal = bos.toByteArray(); - } catch (Exception e) { - throw new RuntimeException(e); - } - - return retVal; + throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly"); } public static String toJsonString(HystrixConfiguration config) { @@ -109,108 +90,9 @@ private static void serializeConfiguration(HystrixConfiguration config, JsonGene } + @Deprecated public static HystrixConfiguration fromByteBuffer(ByteBuffer bb) { - byte[] byteArray = new byte[bb.remaining()]; - bb.get(byteArray); - - Map commandConfigMap = new HashMap(); - Map threadPoolConfigMap = new HashMap(); - Map collapserConfigMap = new HashMap(); - - try { - CBORParser parser = cborFactory.createParser(byteArray); - JsonNode rootNode = mapper.readTree(parser); - - Iterator> commands = rootNode.path("commands").fields(); - Iterator> threadPools = rootNode.path("threadpools").fields(); - Iterator> collapsers = rootNode.path("collapsers").fields(); - - while (commands.hasNext()) { - Map.Entry command = commands.next(); - - JsonNode executionConfig = command.getValue().path("execution"); - - JsonNode circuitBreakerConfig = command.getValue().path("circuitBreaker"); - JsonNode metricsConfig = command.getValue().path("metrics"); - HystrixCommandKey commandKey = HystrixCommandKey.Factory.asKey(command.getKey()); - HystrixCommandConfiguration commandConfig = new HystrixCommandConfiguration( - commandKey, - HystrixThreadPoolKey.Factory.asKey(command.getValue().path("threadPoolKey").asText()), - HystrixCommandGroupKey.Factory.asKey(command.getValue().path("groupKey").asText()), - new HystrixCommandConfiguration.HystrixCommandExecutionConfig( - executionConfig.path("semaphoreSize").asInt(), - HystrixCommandProperties.ExecutionIsolationStrategy.valueOf( - executionConfig.path("isolationStrategy").asText()), - executionConfig.path("threadInterruptOnTimeout").asBoolean(), - executionConfig.path("threadPoolKeyOverride").asText(), - executionConfig.path("timeoutEnabled").asBoolean(), - executionConfig.path("timeoutInMilliseconds").asInt(), - executionConfig.path("fallbackEnabled").asBoolean(), - executionConfig.path("fallbackSemaphoreSize").asInt(), - executionConfig.path("requestCacheEnabled").asBoolean(), - executionConfig.path("requestLogEnabled").asBoolean() - ), - new HystrixCommandConfiguration.HystrixCommandCircuitBreakerConfig( - circuitBreakerConfig.path("enabled").asBoolean(), - circuitBreakerConfig.path("errorPercentageThreshold").asInt(), - circuitBreakerConfig.path("isForcedClosed").asBoolean(), - circuitBreakerConfig.path("isForcedOpen").asBoolean(), - circuitBreakerConfig.path("requestVolumeThreshold").asInt(), - circuitBreakerConfig.path("sleepInMilliseconds").asInt() - ), - new HystrixCommandConfiguration.HystrixCommandMetricsConfig( - metricsConfig.path("healthBucketSizeInMs").asInt(), - metricsConfig.path("percentileEnabled").asBoolean(), - metricsConfig.path("percentileBucketCount").asInt(), - metricsConfig.path("percentileBucketSizeInMilliseconds").asInt(), - metricsConfig.path("counterBucketCount").asInt(), - metricsConfig.path("counterBucketSizeInMilliseconds").asInt() - ) - ); - - commandConfigMap.put(commandKey, commandConfig); - } - - while (threadPools.hasNext()) { - Map.Entry threadPool = threadPools.next(); - HystrixThreadPoolKey threadPoolKey = HystrixThreadPoolKey.Factory.asKey(threadPool.getKey()); - HystrixThreadPoolConfiguration threadPoolConfig = new HystrixThreadPoolConfiguration( - threadPoolKey, - threadPool.getValue().path("coreSize").asInt(), - threadPool.getValue().path("maximumSize").asInt(), - threadPool.getValue().path("maxQueueSize").asInt(), - threadPool.getValue().path("queueRejectionThreshold").asInt(), - threadPool.getValue().path("keepAliveTimeInMinutes").asInt(), - threadPool.getValue().path("allowMaximumSizeToDivergeFromCoreSize").asBoolean(), - threadPool.getValue().path("counterBucketCount").asInt(), - threadPool.getValue().path("counterBucketSizeInMilliseconds").asInt() - ); - threadPoolConfigMap.put(threadPoolKey, threadPoolConfig); - } - - while (collapsers.hasNext()) { - Map.Entry collapser = collapsers.next(); - HystrixCollapserKey collapserKey = HystrixCollapserKey.Factory.asKey(collapser.getKey()); - JsonNode metricsConfig = collapser.getValue().path("metrics"); - HystrixCollapserConfiguration collapserConfig = new HystrixCollapserConfiguration( - collapserKey, - collapser.getValue().path("maxRequestsInBatch").asInt(), - collapser.getValue().path("timerDelayInMilliseconds").asInt(), - collapser.getValue().path("requestCacheEnabled").asBoolean(), - new HystrixCollapserConfiguration.CollapserMetricsConfig( - metricsConfig.path("percentileBucketCount").asInt(), - metricsConfig.path("percentileBucketSizeInMilliseconds").asInt(), - metricsConfig.path("percentileEnabled").asBoolean(), - metricsConfig.path("counterBucketCount").asInt(), - metricsConfig.path("counterBucketSizeInMilliseconds").asInt() - ) - ); - collapserConfigMap.put(collapserKey, collapserConfig); - } - } catch (IOException ioe) { - logger.error("IO Exception during deserialization of HystrixConfiguration : " + ioe); - } - return new HystrixConfiguration(commandConfigMap, threadPoolConfigMap, collapserConfigMap); + throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly"); } private static void writeCommandConfigJson(JsonGenerator json, HystrixCommandKey key, HystrixCommandConfiguration commandConfig) throws IOException { diff --git a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixDashboardData.java b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixDashboardData.java index 916f36055..5754d2fbd 100644 --- a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixDashboardData.java +++ b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixDashboardData.java @@ -28,10 +28,8 @@ import com.netflix.hystrix.metric.consumer.HystrixDashboardStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import rx.Observable; import rx.functions.Func0; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringWriter; import java.util.ArrayList; @@ -41,20 +39,9 @@ public class SerialHystrixDashboardData extends SerialHystrixMetric { private static final Logger logger = LoggerFactory.getLogger(SerialHystrixDashboardData.class); + @Deprecated public static byte[] toBytes(HystrixDashboardStream.DashboardData dashboardData) { - byte[] retVal = null; - - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - JsonGenerator cbor = cborFactory.createGenerator(bos); - writeDashboardData(cbor, dashboardData); - retVal = bos.toByteArray(); - - } catch (Exception e) { - throw new RuntimeException(e); - } - - return retVal; + throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly"); } public static String toJsonString(HystrixDashboardStream.DashboardData dashboardData) { diff --git a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixMetric.java b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixMetric.java index e2f4ef65a..905a1e8de 100644 --- a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixMetric.java +++ b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixMetric.java @@ -16,34 +16,19 @@ package com.netflix.hystrix.serial; import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.cbor.CBORFactory; -import com.fasterxml.jackson.dataformat.cbor.CBORParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; import java.nio.ByteBuffer; public class SerialHystrixMetric { protected final static JsonFactory jsonFactory = new JsonFactory(); - protected final static CBORFactory cborFactory = new CBORFactory(); protected final static ObjectMapper mapper = new ObjectMapper(); protected final static Logger logger = LoggerFactory.getLogger(SerialHystrixMetric.class); + @Deprecated public static String fromByteBufferToString(ByteBuffer bb) { - byte[] byteArray = new byte[bb.remaining()]; - bb.get(byteArray); - - try { - CBORParser parser = cborFactory.createParser(byteArray); - JsonNode rootNode = mapper.readTree(parser); - - return rootNode.toString(); - } catch (IOException ioe) { - logger.error("IO Exception during deserialization of ByteBuffer of Hystrix Metric : " + ioe); - return ""; - } + throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly"); } } diff --git a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixRequestEvents.java b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixRequestEvents.java index 2f442e15c..8b1e1d60b 100644 --- a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixRequestEvents.java +++ b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixRequestEvents.java @@ -20,7 +20,6 @@ import com.netflix.hystrix.HystrixEventType; import com.netflix.hystrix.metric.HystrixRequestEvents; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringWriter; import java.util.List; @@ -28,21 +27,9 @@ public class SerialHystrixRequestEvents extends SerialHystrixMetric { + @Deprecated public static byte[] toBytes(HystrixRequestEvents requestEvents) { - byte[] retVal = null; - - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - JsonGenerator cbor = cborFactory.createGenerator(bos); - - serializeRequestEvents(requestEvents, cbor); - - retVal = bos.toByteArray(); - } catch (Exception e) { - throw new RuntimeException(e); - } - - return retVal; + throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly"); } public static String toJsonString(HystrixRequestEvents requestEvents) { diff --git a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixUtilization.java b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixUtilization.java index 43239faa4..56465f19c 100644 --- a/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixUtilization.java +++ b/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixUtilization.java @@ -16,44 +16,26 @@ package com.netflix.hystrix.serial; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.dataformat.cbor.CBORParser; import com.netflix.hystrix.HystrixCommandKey; import com.netflix.hystrix.HystrixThreadPoolKey; -import com.netflix.hystrix.config.HystrixConfiguration; import com.netflix.hystrix.metric.sample.HystrixCommandUtilization; import com.netflix.hystrix.metric.sample.HystrixThreadPoolUtilization; import com.netflix.hystrix.metric.sample.HystrixUtilization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringWriter; import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Iterator; import java.util.Map; public class SerialHystrixUtilization extends SerialHystrixMetric { private final static Logger logger = LoggerFactory.getLogger(SerialHystrixUtilization.class); + @Deprecated public static byte[] toBytes(HystrixUtilization utilization) { - byte[] retVal = null; - - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - JsonGenerator cbor = cborFactory.createGenerator(bos); - - serializeUtilization(utilization, cbor); - - retVal = bos.toByteArray(); - } catch (Exception e) { - throw new RuntimeException(e); - } - - return retVal; + throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly"); } public static String toJsonString(HystrixUtilization utilization) { @@ -97,42 +79,9 @@ private static void serializeUtilization(HystrixUtilization utilization, JsonGen } } + @Deprecated public static HystrixUtilization fromByteBuffer(ByteBuffer bb) { - byte[] byteArray = new byte[bb.remaining()]; - bb.get(byteArray); - - Map commandUtilizationMap = new HashMap(); - Map threadPoolUtilizationMap = new HashMap(); - - try { - CBORParser parser = cborFactory.createParser(byteArray); - JsonNode rootNode = mapper.readTree(parser); - - Iterator> commands = rootNode.path("commands").fields(); - Iterator> threadPools = rootNode.path("threadpools").fields(); - - while (commands.hasNext()) { - Map.Entry command = commands.next(); - HystrixCommandKey commandKey = HystrixCommandKey.Factory.asKey(command.getKey()); - HystrixCommandUtilization commandUtilization = new HystrixCommandUtilization(command.getValue().path("activeCount").asInt()); - commandUtilizationMap.put(commandKey, commandUtilization); - } - - while (threadPools.hasNext()) { - Map.Entry threadPool = threadPools.next(); - HystrixThreadPoolKey threadPoolKey = HystrixThreadPoolKey.Factory.asKey(threadPool.getKey()); - HystrixThreadPoolUtilization threadPoolUtilization = new HystrixThreadPoolUtilization( - threadPool.getValue().path("activeCount").asInt(), - threadPool.getValue().path("corePoolSize").asInt(), - threadPool.getValue().path("poolSize").asInt(), - threadPool.getValue().path("queueSize").asInt() - ); - threadPoolUtilizationMap.put(threadPoolKey, threadPoolUtilization); - } - } catch (IOException ioe) { - logger.error("IO Exception during desrialization of HystrixUtilization : " + ioe); - } - return new HystrixUtilization(commandUtilizationMap, threadPoolUtilizationMap); + throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly"); } private static void writeCommandUtilizationJson(JsonGenerator json, HystrixCommandKey key, HystrixCommandUtilization utilization) throws IOException {