├── .github └── workflows │ ├── nebula-ci.yml │ ├── nebula-publish.yml │ └── nebula-snapshot.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE-2.0.txt ├── OSSMETADATA ├── README.md ├── build.gradle ├── codequality └── checkstyle.xml ├── gradle.properties ├── gradle ├── doclet-exclude.jar ├── javadocStyleSheet.css └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── hystrix-contrib ├── README.md ├── hystrix-clj │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── clojure │ │ │ └── com │ │ │ └── netflix │ │ │ └── hystrix │ │ │ └── core.clj │ │ └── test │ │ └── clojure │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ └── core_test.clj ├── hystrix-codahale-metrics-publisher │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── netflix │ │ │ └── hystrix │ │ │ └── contrib │ │ │ └── codahalemetricspublisher │ │ │ ├── ConfigurableCodaHaleMetricFilter.java │ │ │ ├── HystrixCodaHaleMetricsPublisher.java │ │ │ ├── HystrixCodaHaleMetricsPublisherCollapser.java │ │ │ ├── HystrixCodaHaleMetricsPublisherCommand.java │ │ │ └── HystrixCodaHaleMetricsPublisherThreadPool.java │ │ └── test │ │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ └── contrib │ │ └── codahalemetricspublisher │ │ ├── ConfigurableCodaHaleMetricFilterTest.java │ │ └── HystrixCodaHaleMetricsPublisherCommandTest.java ├── hystrix-javanica │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── ajcTest │ │ ├── java │ │ │ └── com │ │ │ │ └── netflix │ │ │ │ └── hystrix │ │ │ │ └── contrib │ │ │ │ └── javanica │ │ │ │ └── test │ │ │ │ └── aspectj │ │ │ │ ├── cache │ │ │ │ └── CacheTest.java │ │ │ │ ├── collapser │ │ │ │ └── CollapserTest.java │ │ │ │ ├── command │ │ │ │ └── CommandTest.java │ │ │ │ ├── configuration │ │ │ │ ├── collapser │ │ │ │ │ └── CollapserPropertiesTest.java │ │ │ │ └── command │ │ │ │ │ └── CommandPropertiesTest.java │ │ │ │ ├── error │ │ │ │ ├── ErrorPropagationTest.java │ │ │ │ └── ObservableErrorPropagationTest.java │ │ │ │ ├── fallback │ │ │ │ └── CommandFallbackTest.java │ │ │ │ └── observable │ │ │ │ └── ObservableTest.java │ │ └── resources │ │ │ ├── dummy.txt │ │ │ └── log4j.properties │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── netflix │ │ │ │ └── hystrix │ │ │ │ └── contrib │ │ │ │ └── javanica │ │ │ │ ├── annotation │ │ │ │ ├── DefaultProperties.java │ │ │ │ ├── HystrixCollapser.java │ │ │ │ ├── HystrixCommand.java │ │ │ │ ├── HystrixException.java │ │ │ │ ├── HystrixProperty.java │ │ │ │ └── ObservableExecutionMode.java │ │ │ │ ├── aop │ │ │ │ └── aspectj │ │ │ │ │ ├── HystrixCacheAspect.java │ │ │ │ │ ├── HystrixCommandAspect.java │ │ │ │ │ └── WeavingMode.java │ │ │ │ ├── cache │ │ │ │ ├── CacheInvocationContext.java │ │ │ │ ├── CacheInvocationContextFactory.java │ │ │ │ ├── CacheInvocationParameter.java │ │ │ │ ├── DefaultHystrixGeneratedCacheKey.java │ │ │ │ ├── HystrixCacheKeyGenerator.java │ │ │ │ ├── HystrixGeneratedCacheKey.java │ │ │ │ ├── HystrixRequestCacheManager.java │ │ │ │ └── annotation │ │ │ │ │ ├── CacheKey.java │ │ │ │ │ ├── CacheRemove.java │ │ │ │ │ └── CacheResult.java │ │ │ │ ├── collapser │ │ │ │ └── CommandCollapser.java │ │ │ │ ├── command │ │ │ │ ├── AbstractHystrixCommand.java │ │ │ │ ├── AsyncResult.java │ │ │ │ ├── BatchHystrixCommand.java │ │ │ │ ├── ClosureCommand.java │ │ │ │ ├── CommandAction.java │ │ │ │ ├── CommandActions.java │ │ │ │ ├── CommandExecutionAction.java │ │ │ │ ├── CommandExecutor.java │ │ │ │ ├── ExecutionType.java │ │ │ │ ├── GenericCommand.java │ │ │ │ ├── GenericObservableCommand.java │ │ │ │ ├── GenericSetterBuilder.java │ │ │ │ ├── HystrixCommandBuilder.java │ │ │ │ ├── HystrixCommandBuilderFactory.java │ │ │ │ ├── HystrixCommandFactory.java │ │ │ │ ├── LazyCommandExecutionAction.java │ │ │ │ ├── MetaHolder.java │ │ │ │ ├── MethodExecutionAction.java │ │ │ │ └── closure │ │ │ │ │ ├── AbstractClosureFactory.java │ │ │ │ │ ├── AsyncClosureFactory.java │ │ │ │ │ ├── Closure.java │ │ │ │ │ └── ClosureFactory.java │ │ │ │ ├── conf │ │ │ │ └── HystrixPropertiesManager.java │ │ │ │ ├── exception │ │ │ │ ├── CommandActionExecutionException.java │ │ │ │ ├── ExceptionUtils.java │ │ │ │ ├── FallbackDefinitionException.java │ │ │ │ ├── FallbackInvocationException.java │ │ │ │ ├── HystrixCacheKeyGenerationException.java │ │ │ │ ├── HystrixCachingException.java │ │ │ │ └── HystrixPropertyException.java │ │ │ │ └── utils │ │ │ │ ├── AopUtils.java │ │ │ │ ├── CommonUtils.java │ │ │ │ ├── EnvUtils.java │ │ │ │ ├── FallbackMethod.java │ │ │ │ ├── FutureDecorator.java │ │ │ │ ├── MethodProvider.java │ │ │ │ ├── TypeHelper.java │ │ │ │ └── ajc │ │ │ │ └── AjcUtils.java │ │ └── resources │ │ │ └── dummy.txt │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── netflix │ │ │ └── hystrix │ │ │ └── contrib │ │ │ └── javanica │ │ │ ├── cache │ │ │ ├── CacheInvocationContextFactoryTest.java │ │ │ ├── CacheInvocationParameterTest.java │ │ │ └── HystrixCacheKeyGeneratorTest.java │ │ │ ├── command │ │ │ └── ExecutionTypeTest.java │ │ │ ├── test │ │ │ ├── common │ │ │ │ ├── BasicHystrixTest.java │ │ │ │ ├── CommonUtils.java │ │ │ │ ├── cache │ │ │ │ │ └── BasicCacheTest.java │ │ │ │ ├── collapser │ │ │ │ │ └── BasicCollapserTest.java │ │ │ │ ├── command │ │ │ │ │ └── BasicCommandTest.java │ │ │ │ ├── configuration │ │ │ │ │ ├── collapser │ │ │ │ │ │ └── BasicCollapserPropertiesTest.java │ │ │ │ │ ├── command │ │ │ │ │ │ ├── BasicCommandDefaultPropertiesTest.java │ │ │ │ │ │ └── BasicCommandPropertiesTest.java │ │ │ │ │ └── fallback │ │ │ │ │ │ └── BasicFallbackDefaultPropertiesTest.java │ │ │ │ ├── domain │ │ │ │ │ ├── Domain.java │ │ │ │ │ ├── Profile.java │ │ │ │ │ └── User.java │ │ │ │ ├── error │ │ │ │ │ ├── BasicDefaultIgnoreExceptionsTest.java │ │ │ │ │ ├── BasicDefaultRaiseHystrixExceptionsTest.java │ │ │ │ │ ├── BasicErrorPropagationTest.java │ │ │ │ │ └── BasicObservableErrorPropagationTest.java │ │ │ │ ├── fallback │ │ │ │ │ ├── BasicCommandFallbackTest.java │ │ │ │ │ ├── BasicDefaultFallbackTest.java │ │ │ │ │ └── BasicGenericFallbackTest.java │ │ │ │ └── observable │ │ │ │ │ └── BasicObservableTest.java │ │ │ └── spring │ │ │ │ ├── cache │ │ │ │ └── CacheTest.java │ │ │ │ ├── collapser │ │ │ │ └── CollapserTest.java │ │ │ │ ├── command │ │ │ │ ├── CommandTest.java │ │ │ │ ├── cglib │ │ │ │ │ └── CommandCGlibProxyTest.java │ │ │ │ └── jdk │ │ │ │ │ └── CommandJdkProxyTest.java │ │ │ │ ├── conf │ │ │ │ ├── AopCglibConfig.java │ │ │ │ ├── AopJdkConfig.java │ │ │ │ ├── AopLoadTimeWeavingConfig.java │ │ │ │ └── SpringApplicationContext.java │ │ │ │ ├── configuration │ │ │ │ ├── collapser │ │ │ │ │ └── CollapserPropertiesTest.java │ │ │ │ ├── command │ │ │ │ │ ├── CommandDefaultPropertiesTest.java │ │ │ │ │ └── CommandPropertiesTest.java │ │ │ │ └── fallback │ │ │ │ │ └── FallbackDefaultPropertiesTest.java │ │ │ │ ├── error │ │ │ │ ├── DefaultIgnoreExceptionsTest.java │ │ │ │ ├── DefaultRaiseHystrixExceptionsTest.java │ │ │ │ ├── ErrorPropagationTest.java │ │ │ │ └── ObservableErrorPropagationTest.java │ │ │ │ ├── fallback │ │ │ │ ├── CommandFallbackTest.java │ │ │ │ ├── DefaultFallbackTest.java │ │ │ │ ├── GenericFallbackTest.java │ │ │ │ └── InheritedFallbackTest.java │ │ │ │ └── observable │ │ │ │ └── ObservableTest.java │ │ │ └── util │ │ │ ├── FallbackMethodTest.java │ │ │ ├── FallbackMethodValidationTest.java │ │ │ ├── GetMethodTest.java │ │ │ └── bridge │ │ │ ├── Child.java │ │ │ ├── GenericInterface.java │ │ │ ├── GenericInterfaceImpl.java │ │ │ ├── Parent.java │ │ │ ├── SubChild.java │ │ │ └── UnbridgeMethodTest.java │ │ └── resources │ │ ├── dummy.txt │ │ └── log4j.properties ├── hystrix-junit │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── hystrix │ │ │ └── junit │ │ │ └── HystrixRequestContextRule.java │ │ └── test │ │ └── java │ │ └── com │ │ └── hystrix │ │ └── junit │ │ └── HystrixRequestContextRuleTest.java ├── hystrix-metrics-event-stream-jaxrs │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── netflix │ │ │ └── hystrix │ │ │ └── contrib │ │ │ └── metrics │ │ │ ├── HystrixStream.java │ │ │ ├── HystrixStreamFeature.java │ │ │ ├── HystrixStreamingOutputProvider.java │ │ │ └── controller │ │ │ ├── AbstractHystrixStreamController.java │ │ │ ├── HystrixConfigSseController.java │ │ │ ├── HystrixMetricsStreamController.java │ │ │ ├── HystrixRequestEventsSseController.java │ │ │ └── HystrixUtilizationSseController.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── netflix │ │ │ └── hystrix │ │ │ └── contrib │ │ │ └── metrics │ │ │ └── controller │ │ │ ├── HystricsMetricsControllerTest.java │ │ │ ├── HystrixConfigControllerTest.java │ │ │ ├── HystrixUtilizationControllerTest.java │ │ │ └── StreamingOutputProviderTest.java │ │ └── resources │ │ └── test.properties ├── hystrix-metrics-event-stream │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── netflix │ │ │ └── hystrix │ │ │ └── contrib │ │ │ ├── metrics │ │ │ └── eventstream │ │ │ │ ├── HystrixMetricsPoller.java │ │ │ │ └── HystrixMetricsStreamServlet.java │ │ │ ├── requests │ │ │ └── stream │ │ │ │ ├── HystrixRequestEventsJsonStream.java │ │ │ │ └── HystrixRequestEventsSseServlet.java │ │ │ └── sample │ │ │ └── stream │ │ │ ├── HystrixConfigSseServlet.java │ │ │ ├── HystrixConfigurationJsonStream.java │ │ │ ├── HystrixSampleSseServlet.java │ │ │ ├── HystrixUtilizationJsonStream.java │ │ │ └── HystrixUtilizationSseServlet.java │ │ └── test │ │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ └── contrib │ │ ├── metrics │ │ └── eventstream │ │ │ ├── HystrixMetricsPollerTest.java │ │ │ └── HystrixMetricsStreamServletUnitTest.java │ │ └── sample │ │ └── stream │ │ ├── HystrixConfigSseServletTest.java │ │ └── HystrixSampleSseServletTest.java ├── hystrix-network-auditor-agent │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ └── contrib │ │ └── networkauditor │ │ ├── HystrixNetworkAuditorAgent.java │ │ ├── HystrixNetworkAuditorEventListener.java │ │ └── NetworkClassTransform.java ├── hystrix-request-servlet │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ └── contrib │ │ └── requestservlet │ │ ├── HystrixRequestContextServletFilter.java │ │ ├── HystrixRequestLogViaLoggerServletFilter.java │ │ └── HystrixRequestLogViaResponseHeaderServletFilter.java ├── hystrix-rx-netty-metrics-stream │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── netflix │ │ │ └── hystrix │ │ │ └── contrib │ │ │ └── rxnetty │ │ │ └── metricsstream │ │ │ └── HystrixMetricsStreamHandler.java │ │ └── test │ │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ ├── HystrixCommandMetricsSamples.java │ │ └── contrib │ │ └── rxnetty │ │ └── metricsstream │ │ └── HystrixMetricsStreamHandlerTest.java ├── hystrix-servo-metrics-publisher │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── netflix │ │ │ └── hystrix │ │ │ └── contrib │ │ │ └── servopublisher │ │ │ ├── HystrixServoMetricsPublisher.java │ │ │ ├── HystrixServoMetricsPublisherAbstract.java │ │ │ ├── HystrixServoMetricsPublisherCollapser.java │ │ │ ├── HystrixServoMetricsPublisherCommand.java │ │ │ └── HystrixServoMetricsPublisherThreadPool.java │ │ └── test │ │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ └── contrib │ │ └── servopublisher │ │ └── HystrixServoMetricsPublisherCommandTest.java └── hystrix-yammer-metrics-publisher │ ├── README.md │ ├── build.gradle │ └── src │ └── main │ └── java │ └── com │ └── netflix │ └── hystrix │ └── contrib │ └── yammermetricspublisher │ ├── HystrixYammerMetricsPublisher.java │ ├── HystrixYammerMetricsPublisherCollapser.java │ ├── HystrixYammerMetricsPublisherCommand.java │ └── HystrixYammerMetricsPublisherThreadPool.java ├── hystrix-core ├── README.md ├── build.gradle └── src │ ├── jmh │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ └── perf │ │ ├── CollapserPerfTest.java │ │ ├── CommandConstructionPerfTest.java │ │ ├── CommandExecutionAndConcurrentMetricsReadPerfTest.java │ │ ├── CommandExecutionPerfTest.java │ │ ├── ObservableCollapserPerfTest.java │ │ ├── RollingMaxPerfTest.java │ │ ├── RollingNumberPerfTest.java │ │ └── RollingPercentilePerfTest.java │ ├── main │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ ├── AbstractCommand.java │ │ ├── ExecutionResult.java │ │ ├── Hystrix.java │ │ ├── HystrixCachedObservable.java │ │ ├── HystrixCircuitBreaker.java │ │ ├── HystrixCollapser.java │ │ ├── HystrixCollapserKey.java │ │ ├── HystrixCollapserMetrics.java │ │ ├── HystrixCollapserProperties.java │ │ ├── HystrixCommand.java │ │ ├── HystrixCommandGroupKey.java │ │ ├── HystrixCommandKey.java │ │ ├── HystrixCommandMetrics.java │ │ ├── HystrixCommandProperties.java │ │ ├── HystrixCommandResponseFromCache.java │ │ ├── HystrixCounters.java │ │ ├── HystrixEventType.java │ │ ├── HystrixExecutable.java │ │ ├── HystrixInvokable.java │ │ ├── HystrixInvokableInfo.java │ │ ├── HystrixKey.java │ │ ├── HystrixMetrics.java │ │ ├── HystrixObservable.java │ │ ├── HystrixObservableCollapser.java │ │ ├── HystrixObservableCommand.java │ │ ├── HystrixRequestCache.java │ │ ├── HystrixRequestLog.java │ │ ├── HystrixThreadPool.java │ │ ├── HystrixThreadPoolKey.java │ │ ├── HystrixThreadPoolMetrics.java │ │ ├── HystrixThreadPoolProperties.java │ │ ├── HystrixTimerThreadPoolProperties.java │ │ ├── collapser │ │ ├── CollapsedRequestSubject.java │ │ ├── CollapserTimer.java │ │ ├── HystrixCollapserBridge.java │ │ ├── README.txt │ │ ├── RealCollapserTimer.java │ │ ├── RequestBatch.java │ │ ├── RequestCollapser.java │ │ └── RequestCollapserFactory.java │ │ ├── config │ │ ├── HystrixCollapserConfiguration.java │ │ ├── HystrixCommandConfiguration.java │ │ ├── HystrixConfiguration.java │ │ ├── HystrixConfigurationStream.java │ │ └── HystrixThreadPoolConfiguration.java │ │ ├── exception │ │ ├── ExceptionNotWrappedByHystrix.java │ │ ├── HystrixBadRequestException.java │ │ ├── HystrixRuntimeException.java │ │ ├── HystrixTimeoutException.java │ │ └── package-info.java │ │ ├── metric │ │ ├── CachedValuesHistogram.java │ │ ├── HystrixCollapserEvent.java │ │ ├── HystrixCollapserEventStream.java │ │ ├── HystrixCommandCompletion.java │ │ ├── HystrixCommandCompletionStream.java │ │ ├── HystrixCommandEvent.java │ │ ├── HystrixCommandExecutionStarted.java │ │ ├── HystrixCommandStartStream.java │ │ ├── HystrixEvent.java │ │ ├── HystrixEventStream.java │ │ ├── HystrixRequestEvents.java │ │ ├── HystrixRequestEventsStream.java │ │ ├── HystrixThreadEventStream.java │ │ ├── HystrixThreadPoolCompletionStream.java │ │ ├── HystrixThreadPoolStartStream.java │ │ ├── consumer │ │ │ ├── BucketedCounterStream.java │ │ │ ├── BucketedCumulativeCounterStream.java │ │ │ ├── BucketedRollingCounterStream.java │ │ │ ├── CumulativeCollapserEventCounterStream.java │ │ │ ├── CumulativeCommandEventCounterStream.java │ │ │ ├── CumulativeThreadPoolEventCounterStream.java │ │ │ ├── HealthCountsStream.java │ │ │ ├── HystrixDashboardStream.java │ │ │ ├── RollingCollapserBatchSizeDistributionStream.java │ │ │ ├── RollingCollapserEventCounterStream.java │ │ │ ├── RollingCommandEventCounterStream.java │ │ │ ├── RollingCommandLatencyDistributionStream.java │ │ │ ├── RollingCommandMaxConcurrencyStream.java │ │ │ ├── RollingCommandUserLatencyDistributionStream.java │ │ │ ├── RollingConcurrencyStream.java │ │ │ ├── RollingDistributionStream.java │ │ │ ├── RollingThreadPoolEventCounterStream.java │ │ │ └── RollingThreadPoolMaxConcurrencyStream.java │ │ └── sample │ │ │ ├── HystrixCommandUtilization.java │ │ │ ├── HystrixThreadPoolUtilization.java │ │ │ ├── HystrixUtilization.java │ │ │ └── HystrixUtilizationStream.java │ │ ├── package-info.java │ │ ├── strategy │ │ ├── HystrixArchaiusHelper.java │ │ ├── HystrixPlugins.java │ │ ├── concurrency │ │ │ ├── HystrixConcurrencyStrategy.java │ │ │ ├── HystrixConcurrencyStrategyDefault.java │ │ │ ├── HystrixContextCallable.java │ │ │ ├── HystrixContextRunnable.java │ │ │ ├── HystrixContextScheduler.java │ │ │ ├── HystrixContextSchedulerAction.java │ │ │ ├── HystrixLifecycleForwardingRequestVariable.java │ │ │ ├── HystrixRequestContext.java │ │ │ ├── HystrixRequestVariable.java │ │ │ ├── HystrixRequestVariableDefault.java │ │ │ ├── HystrixRequestVariableHolder.java │ │ │ ├── HystrixRequestVariableLifecycle.java │ │ │ └── package-info.java │ │ ├── eventnotifier │ │ │ ├── HystrixEventNotifier.java │ │ │ ├── HystrixEventNotifierDefault.java │ │ │ └── package-info.java │ │ ├── executionhook │ │ │ ├── HystrixCommandExecutionHook.java │ │ │ ├── HystrixCommandExecutionHookDefault.java │ │ │ └── package-info.java │ │ ├── metrics │ │ │ ├── HystrixMetricsPublisher.java │ │ │ ├── HystrixMetricsPublisherCollapser.java │ │ │ ├── HystrixMetricsPublisherCollapserDefault.java │ │ │ ├── HystrixMetricsPublisherCommand.java │ │ │ ├── HystrixMetricsPublisherCommandDefault.java │ │ │ ├── HystrixMetricsPublisherDefault.java │ │ │ ├── HystrixMetricsPublisherFactory.java │ │ │ ├── HystrixMetricsPublisherThreadPool.java │ │ │ ├── HystrixMetricsPublisherThreadPoolDefault.java │ │ │ └── package-info.java │ │ ├── package-info.java │ │ └── properties │ │ │ ├── HystrixDynamicProperties.java │ │ │ ├── HystrixDynamicPropertiesSystemProperties.java │ │ │ ├── HystrixDynamicProperty.java │ │ │ ├── HystrixPropertiesChainedArchaiusProperty.java │ │ │ ├── HystrixPropertiesChainedProperty.java │ │ │ ├── HystrixPropertiesCollapserDefault.java │ │ │ ├── HystrixPropertiesCommandDefault.java │ │ │ ├── HystrixPropertiesFactory.java │ │ │ ├── HystrixPropertiesStrategy.java │ │ │ ├── HystrixPropertiesStrategyDefault.java │ │ │ ├── HystrixPropertiesThreadPoolDefault.java │ │ │ ├── HystrixPropertiesTimerThreadPoolDefault.java │ │ │ ├── HystrixProperty.java │ │ │ ├── archaius │ │ │ └── HystrixDynamicPropertiesArchaius.java │ │ │ └── package-info.java │ │ └── util │ │ ├── ExceptionThreadingUtility.java │ │ ├── Exceptions.java │ │ ├── HystrixRollingNumber.java │ │ ├── HystrixRollingNumberEvent.java │ │ ├── HystrixRollingPercentile.java │ │ ├── HystrixTimer.java │ │ ├── InternMap.java │ │ ├── LongAdder.java │ │ ├── LongMaxUpdater.java │ │ ├── PlatformSpecific.java │ │ ├── Striped64.java │ │ └── package-info.java │ └── test │ ├── java │ └── com │ │ └── netflix │ │ └── hystrix │ │ ├── AbstractTestHystrixCommand.java │ │ ├── CommonHystrixCommandTests.java │ │ ├── HystrixCircuitBreakerTest.java │ │ ├── HystrixCollapserTest.java │ │ ├── HystrixCommandMetricsTest.java │ │ ├── HystrixCommandPropertiesTest.java │ │ ├── HystrixCommandTest.java │ │ ├── HystrixCommandTestWithCustomConcurrencyStrategy.java │ │ ├── HystrixCommandTimeoutConcurrencyTesting.java │ │ ├── HystrixObservableCollapserTest.java │ │ ├── HystrixObservableCommandTest.java │ │ ├── HystrixRequestCacheTest.java │ │ ├── HystrixRequestLogTest.java │ │ ├── HystrixSubclassCommandTest.java │ │ ├── HystrixTest.java │ │ ├── HystrixThreadPoolMetricsTest.java │ │ ├── HystrixThreadPoolPropertiesTest.java │ │ ├── HystrixThreadPoolTest.java │ │ ├── InspectableBuilder.java │ │ ├── NotWrappedByHystrixTestException.java │ │ ├── NotWrappedByHystrixTestRuntimeException.java │ │ ├── TestHystrixCommand.java │ │ ├── TestHystrixObservableCommand.java │ │ ├── TestableExecutionHook.java │ │ ├── UnsubscribedTasksRequestCacheTest.java │ │ ├── collapser │ │ └── CollapsedRequestSubjectTest.java │ │ ├── config │ │ └── HystrixConfigurationStreamTest.java │ │ ├── metric │ │ ├── CommandStreamTest.java │ │ ├── HystrixCommandCompletionStreamTest.java │ │ ├── HystrixThreadEventStreamTest.java │ │ ├── consumer │ │ │ ├── CumulativeCollapserEventCounterStreamTest.java │ │ │ ├── CumulativeCommandEventCounterStreamTest.java │ │ │ ├── CumulativeThreadPoolEventCounterStreamTest.java │ │ │ ├── HealthCountsStreamTest.java │ │ │ ├── HystrixDashboardStreamTest.java │ │ │ ├── RollingCollapserBatchSizeDistributionStreamTest.java │ │ │ ├── RollingCollapserEventCounterStreamTest.java │ │ │ ├── RollingCommandEventCounterStreamTest.java │ │ │ ├── RollingCommandLatencyDistributionStreamTest.java │ │ │ ├── RollingCommandMaxConcurrencyStreamTest.java │ │ │ ├── RollingThreadPoolEventCounterStreamTest.java │ │ │ └── RollingThreadPoolMaxConcurrencyStreamTest.java │ │ └── sample │ │ │ └── HystrixUtilizationStreamTest.java │ │ ├── strategy │ │ ├── HystrixPluginsTest.java │ │ ├── concurrency │ │ │ ├── HystrixConcurrencyStrategyTest.java │ │ │ └── HystrixContextSchedulerTest.java │ │ ├── metrics │ │ │ └── HystrixMetricsPublisherFactoryTest.java │ │ └── properties │ │ │ ├── HystrixPropertiesChainedArchaiusPropertyTest.java │ │ │ └── HystrixPropertyTest.java │ │ └── util │ │ ├── ExceptionsTest.java │ │ ├── HystrixRollingNumberTest.java │ │ ├── HystrixRollingPercentileTest.java │ │ └── HystrixTimerTest.java │ └── resources │ └── FAKE_META_INF_SERVICES │ ├── com.netflix.hystrix.strategy.properties.HystrixDynamicProperties │ └── com.netflix.hystrix.strategy.properties.HystrixDynamicPropertiesFail ├── hystrix-examples-webapp ├── README.md ├── build.gradle └── src │ └── main │ └── webapp │ ├── WEB-INF │ ├── classes │ │ └── log4j.properties │ └── web.xml │ └── index.jsp ├── hystrix-examples ├── README.md ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── netflix │ └── hystrix │ └── examples │ ├── basic │ ├── CommandCollapserGetValueForKey.java │ ├── CommandFacadeWithPrimarySecondary.java │ ├── CommandHelloFailure.java │ ├── CommandHelloWorld.java │ ├── CommandThatFailsFast.java │ ├── CommandThatFailsSilently.java │ ├── CommandUsingRequestCache.java │ ├── CommandUsingRequestCacheInvalidation.java │ ├── CommandUsingSemaphoreIsolation.java │ ├── CommandWithFallbackViaNetwork.java │ ├── CommandWithStubbedFallback.java │ ├── ObservableCollapserGetWordForNumber.java │ └── ObservableCommandNumbersToWords.java │ └── demo │ ├── CreditCardAuthorizationResult.java │ ├── CreditCardCommand.java │ ├── GetOrderCommand.java │ ├── GetPaymentInformationCommand.java │ ├── GetUserAccountCommand.java │ ├── HystrixCommandAsyncDemo.java │ ├── HystrixCommandDemo.java │ ├── Order.java │ ├── PaymentInformation.java │ └── UserAccount.java ├── hystrix-serialization ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── netflix │ │ └── hystrix │ │ └── serial │ │ ├── SerialHystrixConfiguration.java │ │ ├── SerialHystrixDashboardData.java │ │ ├── SerialHystrixMetric.java │ │ ├── SerialHystrixRequestEvents.java │ │ └── SerialHystrixUtilization.java │ └── test │ └── java │ └── com │ └── netflix │ └── hystrix │ └── serial │ └── SerialHystrixRequestEventsTest.java └── settings.gradle /.github/workflows/nebula-ci.yml: -------------------------------------------------------------------------------- 1 | name: "CI" 2 | on: 3 | push: 4 | branches: 5 | - '*' 6 | tags-ignore: 7 | - '*' 8 | pull_request: 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | # test against JDK 8 16 | java: [ 8 ] 17 | name: CI with Java ${{ matrix.java }} 18 | steps: 19 | - uses: actions/checkout@v1 20 | - name: Setup jdk 21 | uses: actions/setup-java@v1 22 | with: 23 | java-version: ${{ matrix.java }} 24 | - uses: actions/cache@v1 25 | id: gradle-cache 26 | with: 27 | path: ~/.gradle/caches 28 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }} 29 | restore-keys: | 30 | - ${{ runner.os }}-gradle- 31 | - uses: actions/cache@v1 32 | id: gradle-wrapper-cache 33 | with: 34 | path: ~/.gradle/wrapper 35 | key: ${{ runner.os }}-gradlewrapper-${{ hashFiles('gradle/wrapper/*') }} 36 | restore-keys: | 37 | - ${{ runner.os }}-gradlewrapper- 38 | - name: Build with Gradle 39 | run: ./gradlew --info --stacktrace build 40 | env: 41 | CI_NAME: github_actions 42 | CI_BUILD_NUMBER: ${{ github.sha }} 43 | CI_BUILD_URL: 'https://github.com/${{ github.repository }}' 44 | CI_BRANCH: ${{ github.ref }} 45 | COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} 46 | -------------------------------------------------------------------------------- /.github/workflows/nebula-publish.yml: -------------------------------------------------------------------------------- 1 | name: "Publish candidate/release to NetflixOSS and Maven Central" 2 | on: 3 | push: 4 | tags: 5 | - v*.*.* 6 | - v*.*.*-rc.* 7 | release: 8 | types: 9 | - published 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v1 16 | - name: Setup jdk 8 17 | uses: actions/setup-java@v1 18 | with: 19 | java-version: 1.8 20 | - uses: actions/cache@v1 21 | id: gradle-cache 22 | with: 23 | path: ~/.gradle/caches 24 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }} 25 | restore-keys: | 26 | - ${{ runner.os }}-gradle- 27 | - uses: actions/cache@v1 28 | id: gradle-wrapper-cache 29 | with: 30 | path: ~/.gradle/wrapper 31 | key: ${{ runner.os }}-gradlewrapper-${{ hashFiles('gradle/wrapper/*') }} 32 | restore-keys: | 33 | - ${{ runner.os }}-gradlewrapper- 34 | - name: Publish candidate 35 | if: contains(github.ref, '-rc.') 36 | run: ./gradlew --info --stacktrace -Prelease.useLastTag=true candidate 37 | env: 38 | NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }} 39 | NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }} 40 | NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }} 41 | NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }} 42 | - name: Publish release 43 | if: (!contains(github.ref, '-rc.')) 44 | run: ./gradlew --info -Prelease.useLastTag=true final 45 | env: 46 | NETFLIX_OSS_SONATYPE_USERNAME: ${{ secrets.ORG_SONATYPE_USERNAME }} 47 | NETFLIX_OSS_SONATYPE_PASSWORD: ${{ secrets.ORG_SONATYPE_PASSWORD }} 48 | NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }} 49 | NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }} 50 | NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }} 51 | NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }} 52 | -------------------------------------------------------------------------------- /.github/workflows/nebula-snapshot.yml: -------------------------------------------------------------------------------- 1 | name: "Publish snapshot to NetflixOSS and Maven Central" 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | fetch-depth: 0 15 | - name: Set up JDK 16 | uses: actions/setup-java@v1 17 | with: 18 | java-version: 8 19 | - uses: actions/cache@v2 20 | id: gradle-cache 21 | with: 22 | path: | 23 | ~/.gradle/caches 24 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} 25 | - uses: actions/cache@v2 26 | id: gradle-wrapper-cache 27 | with: 28 | path: | 29 | ~/.gradle/wrapper 30 | key: ${{ runner.os }}-gradlewrapper-${{ hashFiles('gradle/wrapper/*') }} 31 | - name: Build 32 | run: ./gradlew build snapshot 33 | env: 34 | NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }} 35 | NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }} 36 | NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }} 37 | NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }} 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # Logs and databases # 24 | ###################### 25 | *.log 26 | 27 | # OS generated files # 28 | ###################### 29 | .DS_Store* 30 | ehthumbs.db 31 | Icon? 32 | Thumbs.db 33 | 34 | # Editor Files # 35 | ################ 36 | *~ 37 | *.swp 38 | 39 | # Gradle Files # 40 | ################ 41 | .gradle 42 | .m2 43 | 44 | # Build output directies 45 | target/ 46 | build/ 47 | 48 | # IntelliJ specific files/directories 49 | out 50 | .idea 51 | *.ipr 52 | *.iws 53 | *.iml 54 | atlassian-ide-plugin.xml 55 | 56 | # Eclipse specific files/directories 57 | .classpath 58 | .project 59 | .settings 60 | .metadata 61 | bin/ 62 | 63 | # NetBeans specific files/directories 64 | .nbattrs 65 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Hystrix 2 | 3 | If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request. 4 | 5 | When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. 6 | 7 | ## License 8 | 9 | By contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/Netflix/Hystrix/blob/master/LICENSE-2.0.txt 10 | 11 | All files are released with the Apache 2.0 license. 12 | 13 | If you are adding a new file it should have a header like this: 14 | 15 | ``` 16 | /** 17 | * Copyright 2013 Netflix, Inc. 18 | * 19 | * Licensed under the Apache License, Version 2.0 (the "License"); 20 | * you may not use this file except in compliance with the License. 21 | * You may obtain a copy of the License at 22 | * 23 | * http://www.apache.org/licenses/LICENSE-2.0 24 | * 25 | * Unless required by applicable law or agreed to in writing, software 26 | * distributed under the License is distributed on an "AS IS" BASIS, 27 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 28 | * See the License for the specific language governing permissions and 29 | * limitations under the License. 30 | */ 31 | ``` 32 | -------------------------------------------------------------------------------- /OSSMETADATA: -------------------------------------------------------------------------------- 1 | osslifecycle=maintenance 2 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.netflix.nebula.netflixoss" version "11.3.1" 3 | id "me.champeau.jmh" version "0.7.1" 4 | } 5 | 6 | allprojects { 7 | repositories { 8 | mavenCentral() 9 | } 10 | } 11 | 12 | subprojects { 13 | apply plugin: 'nebula.netflixoss' 14 | apply plugin: 'java-library' 15 | 16 | group = "com.netflix.hystrix" 17 | 18 | tasks.withType(Javadoc).configureEach { 19 | failOnError = false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix/Hystrix/7c03bafe32b518182e09e92fa57358a01043a504/gradle.properties -------------------------------------------------------------------------------- /gradle/doclet-exclude.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix/Hystrix/7c03bafe32b518182e09e92fa57358a01043a504/gradle/doclet-exclude.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix/Hystrix/7c03bafe32b518182e09e92fa57358a01043a504/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jun 19 21:27:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip 7 | -------------------------------------------------------------------------------- /hystrix-contrib/README.md: -------------------------------------------------------------------------------- 1 | ## hystrix-contrib 2 | 3 | This is the parent of all "contrib" submodules to Hystrix. 4 | 5 | Examples of what makes sense as a contrib submodule are: 6 | 7 | - alternate implementations of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) 8 | - alternate implementations of [HystrixPropertiesStrategy](http://netflix.github.com/Hystrix/javadoc/com/netflix/hystrix/strategy/properties/HystrixPropertiesStrategy.html) 9 | - request lifecycle implementations (such as [hystrix-request-servlet](https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-request-servlet)) 10 | - implementations of [HystrixEventNotifier](http://netflix.github.com/Hystrix/javadoc/com/netflix/hystrix/strategy/eventnotifier/HystrixEventNotifier.html) 11 | - dashboard and monitoring tools 12 | 13 | 3rd partly libraries wrapped with Hystrix do not belong here and should be their own project. 14 | 15 | They can however be referenced from the Wiki [Libraries](https://github.com/Netflix/Hystrix/wiki/Libraries) page. 16 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-clj/README.md: -------------------------------------------------------------------------------- 1 | # Hystrix Clojure Bindings 2 | 3 | This module contains idiomatic Clojure bindings for Hystrix. 4 | 5 | # Binaries 6 | 7 | Binaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22hystrix-clj%22). 8 | 9 | Example for Maven: 10 | 11 | ```xml 12 | 13 | com.netflix.hystrix 14 | hystrix-clj 15 | x.y.z 16 | 17 | ``` 18 | 19 | and for Ivy: 20 | 21 | ```xml 22 | 23 | ``` 24 | 25 | and for Leiningen: 26 | 27 | ```clojure 28 | [com.netflix.hystrix/hystrix-clj "x.y.z"] 29 | ``` 30 | 31 | # Usage 32 | 33 | Please see the docstrings in src/com/netflix/hystrix/core.clj for extensive usage info. 34 | 35 | ## TL;DR 36 | You have a function that interacts with an untrusted dependency: 37 | 38 | ```clojure 39 | (defn make-request 40 | [arg] 41 | ... make the request ...) 42 | 43 | ; execute the request 44 | (make-request "baz") 45 | ``` 46 | 47 | and you want to make it a Hystrix dependency command. Do this: 48 | 49 | ```clojure 50 | (defcommand make-request 51 | [arg] 52 | ... make the request ...) 53 | 54 | ; execute the request 55 | (make-request "baz") 56 | 57 | ; or queue for async execution 58 | (queue #'make-request "baz") 59 | ``` 60 | 61 | # Event Stream 62 | 63 | A Clojure version of hystrix-event-stream can be found at https://github.com/josephwilk/hystrix-event-stream-clj 64 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-clj/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven{ 5 | name 'clojars' 6 | url 'https://clojars.org/repo' 7 | } 8 | } 9 | dependencies { 10 | classpath 'com.netflix.nebula:nebula-clojure-plugin:13.0.1' 11 | } 12 | } 13 | apply plugin: 'com.netflix.nebula.clojure' // this is a wrapper around clojuresque to make it behave well with other plugins 14 | 15 | repositories { 16 | mavenCentral() 17 | clojarsRepo() 18 | } 19 | 20 | dependencies { 21 | api project(':hystrix-core') 22 | implementation 'org.clojure:clojure:1.7.0' 23 | } 24 | 25 | /* 26 | * Add Counterclockwise and include 'provided' dependencies 27 | */ 28 | eclipse { 29 | project { 30 | natures "ccw.nature" 31 | } 32 | } 33 | 34 | 35 | //////////////////////////////////////////////////////////////////////////////// 36 | // Define a task that runs an nrepl server. The port is given with the nreplPort 37 | // property: 38 | // gradlew nrepl -PnreplPort=9999 39 | // or put the property in ~/.gradle/gradle.properties 40 | def nreplPort = 9999 // hardcoding to 9999 until figuring out how to make this not break Eclipse project import when the property isn't defined 41 | configurations { nrepl } 42 | dependencies { nrepl 'org.clojure:tools.nrepl:0.2.1' } 43 | task nrepl(type: JavaExec) { 44 | classpath configurations.nrepl.asPath, 45 | project.sourceSets.main.clojure.srcDirs, 46 | project.sourceSets.test.clojure.srcDirs, 47 | sourceSets.main.runtimeClasspath 48 | main = "clojure.main" 49 | args '--eval', "(ns gradle-nrepl (:require [clojure.tools.nrepl.server :refer (start-server stop-server)]))", 50 | '--eval', "(println \"Starting nrepl server on port $nreplPort\")", 51 | '--eval', "(def server (start-server :port $nreplPort))" 52 | } 53 | 54 | // vim:ft=groovy 55 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-codahale-metrics-publisher/README.md: -------------------------------------------------------------------------------- 1 | # hystrix-codahale-metrics-publisher 2 | 3 | This is an implementation of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/index.html?com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) that publishes metrics using [Coda Hale Metrics](http://metrics.codahale.com) version 3. If you are using Yammer Metrics version 2, please use the [hystrix-yammer-metrics-publisher](../hystrix-yammer-metrics-publisher) module instead. 4 | 5 | See the [Metrics & Monitoring](https://github.com/Netflix/Hystrix/wiki/Metrics-and-Monitoring) Wiki for more information. 6 | 7 | # Binaries 8 | 9 | Binaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22hystrix-codahale-metrics-publisher%22). 10 | 11 | Example for Maven: 12 | 13 | ```xml 14 | 15 | com.netflix.hystrix 16 | hystrix-codahale-metrics-publisher 17 | 1.1.2 18 | 19 | ``` 20 | 21 | and for Ivy: 22 | 23 | ```xml 24 | 25 | ``` 26 | 27 | Example usage (make it work/plug it in): 28 | 29 | HystrixPlugins.getInstance().registerMetricsPublisher(new HystrixCodahaleMetricsPublisher(yourMetricRegistry)); 30 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-codahale-metrics-publisher/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | api 'io.dropwizard.metrics:metrics-core:3.2.2' 4 | testImplementation 'junit:junit-dep:4.10' 5 | testImplementation 'org.mockito:mockito-all:1.9.5' 6 | } 7 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-codahale-metrics-publisher/src/test/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherCommandTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.codahalemetricspublisher; 2 | 3 | import com.codahale.metrics.MetricRegistry; 4 | import com.netflix.hystrix.HystrixCommand; 5 | import com.netflix.hystrix.HystrixCommandGroupKey; 6 | import com.netflix.hystrix.HystrixCommandKey; 7 | import com.netflix.hystrix.HystrixThreadPoolKey; 8 | import com.netflix.hystrix.strategy.HystrixPlugins; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | import static org.hamcrest.core.Is.is; 13 | import static org.junit.Assert.assertThat; 14 | 15 | public class HystrixCodaHaleMetricsPublisherCommandTest { 16 | private final MetricRegistry metricRegistry = new MetricRegistry(); 17 | 18 | @Before 19 | public void setup() { 20 | HystrixPlugins.getInstance().registerMetricsPublisher(new HystrixCodaHaleMetricsPublisher("hystrix", metricRegistry)); 21 | } 22 | 23 | @Test 24 | public void testCommandSuccess() throws InterruptedException { 25 | Command command = new Command(); 26 | command.execute(); 27 | 28 | Thread.sleep(1000); 29 | 30 | assertThat((Long) metricRegistry.getGauges().get("hystrix.testGroup.testCommand.countSuccess").getValue(), is(1L)); 31 | assertThat((Long) metricRegistry.getGauges().get("hystrix.HystrixThreadPool.threadGroup.totalTaskCount").getValue(), is(1L)); 32 | 33 | } 34 | 35 | private static class Command extends HystrixCommand { 36 | final static HystrixCommandKey hystrixCommandKey = HystrixCommandKey.Factory.asKey("testCommand"); 37 | final static HystrixCommandGroupKey hystrixCommandGroupKey = HystrixCommandGroupKey.Factory.asKey("testGroup"); 38 | final static HystrixThreadPoolKey hystrixThreadPool = HystrixThreadPoolKey.Factory.asKey("threadGroup"); 39 | 40 | Command() { 41 | super(Setter.withGroupKey(hystrixCommandGroupKey).andCommandKey(hystrixCommandKey).andThreadPoolKey(hystrixThreadPool)); 42 | } 43 | 44 | @Override 45 | protected Void run() throws Exception { 46 | return null; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/cache/CacheTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.cache; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.cache.BasicCacheTest; 19 | import org.junit.BeforeClass; 20 | 21 | /** 22 | * Created by dmgcodevil 23 | */ 24 | public class CacheTest extends BasicCacheTest { 25 | @BeforeClass 26 | public static void setUpEnv() { 27 | System.setProperty("weavingMode", "compile"); 28 | } 29 | 30 | @Override 31 | protected UserService createUserService() { 32 | UserService userService = new UserService(); 33 | userService.init(); 34 | return userService; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/collapser/CollapserTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.collapser; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.collapser.BasicCollapserTest; 19 | import org.junit.BeforeClass; 20 | 21 | /** 22 | * Created by dmgcodevil 23 | */ 24 | public class CollapserTest extends BasicCollapserTest { 25 | @BeforeClass 26 | public static void setUpEnv() { 27 | System.setProperty("weavingMode", "compile"); 28 | } 29 | 30 | @Override 31 | protected UserService createUserService() { 32 | return new UserService(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/command/CommandTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.command; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.command.BasicCommandTest; 19 | import com.netflix.hystrix.contrib.javanica.test.common.domain.User; 20 | import org.junit.BeforeClass; 21 | 22 | 23 | public class CommandTest extends BasicCommandTest { 24 | 25 | @BeforeClass 26 | public static void setUpEnv(){ 27 | System.setProperty("weavingMode", "compile"); 28 | } 29 | 30 | @Override 31 | protected UserService createUserService() { 32 | return new UserService(); 33 | } 34 | 35 | @Override 36 | protected AdvancedUserService createAdvancedUserServiceService() { 37 | return new AdvancedUserService(); 38 | } 39 | 40 | @Override 41 | protected GenericService createGenericUserService() { 42 | return new GenericUserService(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/configuration/collapser/CollapserPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.configuration.collapser; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.configuration.collapser.BasicCollapserPropertiesTest; 19 | import org.junit.BeforeClass; 20 | 21 | /** 22 | * Created by dmgcodevil 23 | */ 24 | public class CollapserPropertiesTest extends BasicCollapserPropertiesTest { 25 | 26 | @BeforeClass 27 | public static void setUpEnv() { 28 | System.setProperty("weavingMode", "compile"); 29 | } 30 | 31 | @Override 32 | protected UserService createUserService() { 33 | return new UserService(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/configuration/command/CommandPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.configuration.command; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.configuration.command.BasicCommandPropertiesTest; 19 | import org.junit.BeforeClass; 20 | 21 | /** 22 | * Created by dmgcodevil 23 | */ 24 | public class CommandPropertiesTest extends BasicCommandPropertiesTest { 25 | 26 | @BeforeClass 27 | public static void setUpEnv() { 28 | System.setProperty("weavingMode", "compile"); 29 | } 30 | 31 | @Override 32 | protected UserService createUserService() { 33 | return new UserService(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/error/ErrorPropagationTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.error; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.error.BasicErrorPropagationTest; 19 | import org.junit.BeforeClass; 20 | 21 | /** 22 | * Created by dmgcodevil 23 | */ 24 | public class ErrorPropagationTest extends BasicErrorPropagationTest { 25 | 26 | @BeforeClass 27 | public static void setUpEnv() { 28 | System.setProperty("weavingMode", "compile"); 29 | } 30 | 31 | @Override 32 | protected UserService createUserService() { 33 | return new UserService(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/error/ObservableErrorPropagationTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.error; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.error.BasicErrorPropagationTest; 19 | import com.netflix.hystrix.contrib.javanica.test.common.error.BasicObservableErrorPropagationTest; 20 | import org.junit.BeforeClass; 21 | 22 | /** 23 | * Created by dmgcodevil 24 | */ 25 | public class ObservableErrorPropagationTest extends BasicObservableErrorPropagationTest { 26 | 27 | @BeforeClass 28 | public static void setUpEnv() { 29 | System.setProperty("weavingMode", "compile"); 30 | } 31 | 32 | @Override 33 | protected UserService createUserService() { 34 | return new UserService(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/fallback/CommandFallbackTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.fallback; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.fallback.BasicCommandFallbackTest; 19 | import org.junit.BeforeClass; 20 | 21 | /** 22 | * Created by dmgcodevil 23 | */ 24 | public class CommandFallbackTest extends BasicCommandFallbackTest { 25 | 26 | @BeforeClass 27 | public static void setUpEnv() { 28 | System.setProperty("weavingMode", "compile"); 29 | } 30 | 31 | @Override 32 | protected UserService createUserService() { 33 | return new UserService(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/observable/ObservableTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.aspectj.observable; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.observable.BasicObservableTest; 19 | import org.junit.BeforeClass; 20 | 21 | /** 22 | * Created by dmgcodevil 23 | */ 24 | public class ObservableTest extends BasicObservableTest { 25 | 26 | @BeforeClass 27 | public static void setUpEnv() { 28 | System.setProperty("weavingMode", "compile"); 29 | } 30 | 31 | @Override 32 | protected UserService createUserService() { 33 | return new UserService(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/resources/dummy.txt: -------------------------------------------------------------------------------- 1 | ==== 2 | Copyright 2016 Netflix, Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ==== 16 | 17 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/ajcTest/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016 Netflix, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # Define the root logger with appender console 18 | log4j.rootLogger = ERROR, CONSOLE 19 | 20 | # Define the console appender 21 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 22 | log4j.appender.CONSOLE.File=${log}/log.out 23 | 24 | # Define the layout for console appender 25 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 26 | log4j.appender.CONSOLE.layout.conversionPattern=%m%n -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/annotation/HystrixException.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.annotation; 2 | 3 | /** 4 | * Created by Mike Cowan 5 | */ 6 | public enum HystrixException { 7 | RUNTIME_EXCEPTION, 8 | } 9 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/annotation/HystrixProperty.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * This annotation allows specify Hystrix command properties in the following format: 26 | * property name = property value. 27 | */ 28 | @Target({ElementType.METHOD}) 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Documented 31 | public @interface HystrixProperty { 32 | 33 | /** 34 | * Property name. 35 | * 36 | * @return name 37 | */ 38 | String name(); 39 | 40 | /** 41 | * Property value 42 | * 43 | * @return value 44 | */ 45 | String value(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/annotation/ObservableExecutionMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.annotation; 17 | 18 | import com.netflix.hystrix.HystrixObservable; 19 | import rx.Observable; 20 | 21 | /** 22 | * Hystrix observable command can be executed in two different ways: 23 | * eager - {@link HystrixObservable#observe()}, 24 | * lazy - {@link HystrixObservable#toObservable()}. 25 | *

26 | * This enum is used to specify desire execution mode. 27 | *

28 | * Created by dmgcodevil. 29 | */ 30 | public enum ObservableExecutionMode { 31 | 32 | /** 33 | * This mode lazily starts execution of the command only once the {@link Observable} is subscribed to. 34 | */ 35 | LAZY, 36 | 37 | /** 38 | * This mode eagerly starts execution of the command the same as {@link com.netflix.hystrix.HystrixCommand#queue()} 39 | * and {@link com.netflix.hystrix.HystrixCommand#execute()}. 40 | */ 41 | EAGER 42 | } 43 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/aop/aspectj/WeavingMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.aop.aspectj; 17 | 18 | /** 19 | * Created by dmgcodevil 20 | */ 21 | public enum WeavingMode { 22 | 23 | COMPILE, RUNTIME 24 | 25 | } 26 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/cache/DefaultHystrixGeneratedCacheKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.cache; 17 | 18 | import com.google.common.base.Objects; 19 | 20 | /** 21 | * Default implementation of {@link HystrixGeneratedCacheKey}. 22 | * 23 | * @author dmgcodevil 24 | */ 25 | public class DefaultHystrixGeneratedCacheKey implements HystrixGeneratedCacheKey { 26 | 27 | /** 28 | * Means "do not cache". 29 | */ 30 | public static final DefaultHystrixGeneratedCacheKey EMPTY = new DefaultHystrixGeneratedCacheKey(null); 31 | 32 | private String cacheKey; 33 | 34 | public DefaultHystrixGeneratedCacheKey(String cacheKey) { 35 | this.cacheKey = cacheKey; 36 | } 37 | 38 | @Override 39 | public String getCacheKey() { 40 | return cacheKey; 41 | } 42 | 43 | @Override 44 | public int hashCode() { 45 | return Objects.hashCode(cacheKey); 46 | } 47 | 48 | @Override 49 | public boolean equals(Object o) { 50 | if (this == o) 51 | return true; 52 | if (o == null || getClass() != o.getClass()) 53 | return false; 54 | 55 | DefaultHystrixGeneratedCacheKey that = (DefaultHystrixGeneratedCacheKey) o; 56 | 57 | return Objects.equal(this.cacheKey, that.cacheKey); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/cache/HystrixGeneratedCacheKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.cache; 17 | 18 | /** 19 | * Specific interface to adopt {@link HystrixGeneratedCacheKey} for Hystrix environment. 20 | * 21 | * @author dmgcodevil 22 | */ 23 | public interface HystrixGeneratedCacheKey { 24 | 25 | /** 26 | * Key to be used for request caching. 27 | *

28 | * By default this returns null which means "do not cache". 29 | *

30 | * To enable caching override this method and return a string key uniquely representing the state of a command instance. 31 | *

32 | * If multiple command instances in the same request scope match keys then only the first will be executed and all others returned from cache. 33 | * 34 | * @return cacheKey 35 | */ 36 | String getCacheKey(); 37 | } 38 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/cache/annotation/CacheKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.cache.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Marks a method argument as part of the cache key. 26 | * If no arguments are marked all arguments are used. 27 | * If {@link CacheResult} or {@link CacheRemove} annotation has specified cacheKeyMethod then 28 | * a method arguments will not be used to build cache key even if they annotated with {@link CacheKey}. 29 | * 30 | * @author dmgcodevil 31 | */ 32 | @Target({ElementType.PARAMETER}) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Documented 35 | public @interface CacheKey { 36 | 37 | /** 38 | * Allows specify name of a certain argument property. 39 | * for example: @CacheKey("id") User user, 40 | * or in case composite property: @CacheKey("profile.name") User user. 41 | * null properties are ignored, i.e. if profile is null 42 | * then result of @CacheKey("profile.name") User user will be empty string. 43 | * 44 | * @return name of an argument property 45 | */ 46 | String value() default ""; 47 | } 48 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/cache/annotation/CacheResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.cache.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Marks a methods that results should be cached for a Hystrix command. 26 | * This annotation must be used in conjunction with {@link com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand} annotation. 27 | * 28 | * @author dmgcodevil 29 | */ 30 | @Target({ElementType.METHOD}) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Documented 33 | public @interface CacheResult { 34 | 35 | /** 36 | * Method name to be used to get a key for request caching. 37 | * The command and cache key method should be placed in the same class and have same method signature except 38 | * cache key method return type, that should be String. 39 | *

40 | * cacheKeyMethod has higher priority than an arguments of a method, that means what actual arguments 41 | * of a method that annotated with {@link CacheResult} will not be used to generate cache key, instead specified 42 | * cacheKeyMethod fully assigns to itself responsibility for cache key generation. 43 | * By default this returns empty string which means "do not use cache method". 44 | * 45 | * @return method name or empty string 46 | */ 47 | String cacheKeyMethod() default ""; 48 | } 49 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/ClosureCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.command; 17 | 18 | /** 19 | * This interface is used to perform command logic within an anonymous class and basically used as wrapper for some logic. 20 | * 21 | * @param command result type 22 | */ 23 | public interface ClosureCommand { 24 | 25 | /** 26 | * Process logic. 27 | * 28 | * @return result 29 | */ 30 | T invoke(); 31 | } 32 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/CommandAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.command; 17 | 18 | import com.netflix.hystrix.contrib.javanica.exception.CommandActionExecutionException; 19 | 20 | /** 21 | * Simple action to encapsulate some logic to process it in a Hystrix command. 22 | */ 23 | public interface CommandAction { 24 | 25 | MetaHolder getMetaHolder(); 26 | 27 | /** 28 | * Executes action in accordance with the given execution type. 29 | * 30 | * @param executionType the execution type 31 | * @return result of execution 32 | * @throws com.netflix.hystrix.contrib.javanica.exception.CommandActionExecutionException 33 | */ 34 | Object execute(ExecutionType executionType) throws CommandActionExecutionException; 35 | 36 | /** 37 | * Executes action with parameters in accordance with the given execution ty 38 | * 39 | * @param executionType the execution type 40 | * @param args the parameters of the action 41 | * @return result of execution 42 | * @throws com.netflix.hystrix.contrib.javanica.exception.CommandActionExecutionException 43 | */ 44 | Object executeWithArgs(ExecutionType executionType, Object[] args) throws CommandActionExecutionException; 45 | 46 | /** 47 | * Gets action name. Useful for debugging. 48 | * 49 | * @return the action name 50 | */ 51 | String getActionName(); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/closure/AsyncClosureFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.command.closure; 17 | 18 | import com.netflix.hystrix.contrib.javanica.command.AsyncResult; 19 | import com.netflix.hystrix.contrib.javanica.command.ClosureCommand; 20 | 21 | /** 22 | * Specific implementation of {@link ClosureFactory}. 23 | */ 24 | public class AsyncClosureFactory extends AbstractClosureFactory { 25 | 26 | private static final AsyncClosureFactory INSTANCE = new AsyncClosureFactory(); 27 | 28 | private AsyncClosureFactory() { 29 | } 30 | 31 | public static AsyncClosureFactory getInstance() { 32 | return INSTANCE; 33 | } 34 | 35 | /** 36 | * {@inheritDoc}. 37 | */ 38 | @Override 39 | boolean isClosureCommand(Object closureObj) { 40 | return closureObj instanceof AsyncResult; 41 | } 42 | 43 | /** 44 | * {@inheritDoc}. 45 | */ 46 | @Override 47 | Class getClosureCommandType() { 48 | return AsyncResult.class; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/closure/Closure.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.command.closure; 17 | 18 | import java.lang.reflect.Method; 19 | 20 | /** 21 | * Contains method and instance of anonymous class which implements 22 | * {@link com.netflix.hystrix.contrib.javanica.command.ClosureCommand} interface. 23 | */ 24 | public class Closure { 25 | 26 | private final Method closureMethod; 27 | private final Object closureObj; 28 | 29 | public Closure() { 30 | closureMethod = null; 31 | closureObj = null; 32 | } 33 | 34 | public Closure(Method closureMethod, Object closureObj) { 35 | this.closureMethod = closureMethod; 36 | this.closureObj = closureObj; 37 | } 38 | 39 | public Method getClosureMethod() { 40 | return closureMethod; 41 | } 42 | 43 | public Object getClosureObj() { 44 | return closureObj; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/closure/ClosureFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.command.closure; 17 | 18 | import com.netflix.hystrix.contrib.javanica.command.MetaHolder; 19 | 20 | import java.lang.reflect.Method; 21 | 22 | /** 23 | * Factory to create instances of {@link Closure} class. 24 | */ 25 | public interface ClosureFactory { 26 | 27 | /** 28 | * Creates closure in accordance with method return type. 29 | * 30 | * @param metaHolder the meta holder 31 | * @param method the external method within which closure is created 32 | * @param o the object the underlying method is invoked from 33 | * @param args the arguments used for the method call 34 | * @return new {@link Closure} instance 35 | */ 36 | Closure createClosure(final MetaHolder metaHolder, final Method method, final Object o, final Object... args); 37 | } 38 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/exception/CommandActionExecutionException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.exception; 17 | 18 | /** 19 | * This exception is used to wrap original exceptions to push through javanica infrastructure. 20 | */ 21 | public class CommandActionExecutionException extends RuntimeException { 22 | 23 | /** 24 | * Creates exceptions instance with cause is original exception. 25 | * 26 | * @param cause the original exception 27 | */ 28 | public CommandActionExecutionException(Throwable cause) { 29 | super(cause); 30 | } 31 | 32 | /** 33 | * Default constructor. 34 | */ 35 | public CommandActionExecutionException() { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/exception/ExceptionUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.exception; 17 | 18 | import com.netflix.hystrix.exception.HystrixBadRequestException; 19 | 20 | /** 21 | * Util class to work with exceptions. 22 | */ 23 | public class ExceptionUtils { 24 | 25 | /** 26 | * Retrieves cause exception and wraps to {@link CommandActionExecutionException}. 27 | * 28 | * @param throwable the throwable 29 | */ 30 | public static void propagateCause(Throwable throwable) throws CommandActionExecutionException { 31 | throw new CommandActionExecutionException(throwable.getCause()); 32 | } 33 | 34 | /** 35 | * Wraps cause exception to {@link CommandActionExecutionException}. 36 | * 37 | * @param throwable the throwable 38 | */ 39 | public static CommandActionExecutionException wrapCause(Throwable throwable) { 40 | return new CommandActionExecutionException(throwable.getCause()); 41 | } 42 | 43 | /** 44 | * Gets actual exception if it's wrapped in {@link CommandActionExecutionException} or {@link HystrixBadRequestException}. 45 | * 46 | * @param e the exception 47 | * @return unwrapped 48 | */ 49 | public static Throwable unwrapCause(Throwable e) { 50 | if (e instanceof CommandActionExecutionException) { 51 | return e.getCause(); 52 | } 53 | if (e instanceof HystrixBadRequestException) { 54 | return e.getCause(); 55 | } 56 | return e; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/exception/FallbackDefinitionException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.exception; 17 | 18 | 19 | public class FallbackDefinitionException extends RuntimeException { 20 | 21 | public FallbackDefinitionException() { 22 | } 23 | 24 | public FallbackDefinitionException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | 28 | public FallbackDefinitionException(Throwable cause) { 29 | super(cause); 30 | } 31 | 32 | public FallbackDefinitionException(String message) { 33 | super(message); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/exception/FallbackInvocationException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.exception; 17 | 18 | /** 19 | * Exception specifies error occurred in fallback method. 20 | */ 21 | public class FallbackInvocationException extends RuntimeException { 22 | 23 | public FallbackInvocationException() { 24 | } 25 | 26 | public FallbackInvocationException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public FallbackInvocationException(Throwable cause) { 31 | super(cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/exception/HystrixCacheKeyGenerationException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.exception; 17 | 18 | /** 19 | * Indicates that something is going wrong with cache key generation logic. 20 | * 21 | * @author dmgcodevil 22 | */ 23 | public class HystrixCacheKeyGenerationException extends RuntimeException { 24 | 25 | public HystrixCacheKeyGenerationException() { 26 | } 27 | 28 | public HystrixCacheKeyGenerationException(String message) { 29 | super(message); 30 | } 31 | 32 | public HystrixCacheKeyGenerationException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | public HystrixCacheKeyGenerationException(Throwable cause) { 37 | super(cause); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/exception/HystrixCachingException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.exception; 17 | 18 | /** 19 | * Indicates that something is going wrong with caching logic. 20 | * 21 | * @author dmgcodevil 22 | */ 23 | public class HystrixCachingException extends RuntimeException { 24 | 25 | public HystrixCachingException() { 26 | } 27 | 28 | public HystrixCachingException(String message) { 29 | super(message); 30 | } 31 | 32 | public HystrixCachingException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | public HystrixCachingException(Throwable cause) { 37 | super(cause); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/exception/HystrixPropertyException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.exception; 17 | 18 | /** 19 | * Created by dmgcodevil. 20 | */ 21 | public class HystrixPropertyException extends RuntimeException { 22 | 23 | public HystrixPropertyException() { 24 | } 25 | 26 | public HystrixPropertyException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public HystrixPropertyException(Throwable cause) { 31 | super(cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/utils/CommonUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.utils; 17 | 18 | import com.netflix.hystrix.contrib.javanica.command.MetaHolder; 19 | import org.apache.commons.lang3.ArrayUtils; 20 | 21 | import java.util.Arrays; 22 | 23 | /** 24 | * Created by dmgcodevil. 25 | */ 26 | public final class CommonUtils { 27 | 28 | private CommonUtils(){ 29 | 30 | } 31 | 32 | public static Object[] createArgsForFallback(MetaHolder metaHolder, Throwable exception) { 33 | return createArgsForFallback(metaHolder.getArgs(), metaHolder, exception); 34 | } 35 | 36 | public static Object[] createArgsForFallback(Object[] args, MetaHolder metaHolder, Throwable exception) { 37 | if (metaHolder.isExtendedFallback()) { 38 | if (metaHolder.isExtendedParentFallback()) { 39 | args[args.length - 1] = exception; 40 | } else { 41 | args = Arrays.copyOf(args, args.length + 1); 42 | args[args.length - 1] = exception; 43 | } 44 | } else { 45 | if (metaHolder.isExtendedParentFallback()) { 46 | args = ArrayUtils.remove(args, args.length - 1); 47 | } 48 | } 49 | return args; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/utils/EnvUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.utils; 17 | 18 | import com.netflix.hystrix.contrib.javanica.aop.aspectj.WeavingMode; 19 | 20 | import java.util.Arrays; 21 | 22 | /** 23 | * Created by dmgcodevil 24 | */ 25 | public final class EnvUtils { 26 | 27 | private static final String WEAVING_MODE; 28 | 29 | static { 30 | WEAVING_MODE = System.getProperty("weavingMode", WeavingMode.RUNTIME.name()).toUpperCase(); 31 | } 32 | 33 | private EnvUtils(){ 34 | 35 | } 36 | 37 | public static WeavingMode getWeavingMode() { 38 | try { 39 | return WeavingMode.valueOf(EnvUtils.WEAVING_MODE); 40 | } catch (IllegalArgumentException e) { 41 | throw new IllegalArgumentException("wrong 'weavingMode' property, supported: " + Arrays.toString(WeavingMode.values()) + ", actual = " + EnvUtils.WEAVING_MODE, e); 42 | } 43 | } 44 | 45 | public static boolean isCompileWeaving() { 46 | return WeavingMode.COMPILE == getWeavingMode(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/utils/FutureDecorator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.utils; 17 | 18 | import java.util.concurrent.ExecutionException; 19 | import java.util.concurrent.Future; 20 | import java.util.concurrent.TimeUnit; 21 | import java.util.concurrent.TimeoutException; 22 | 23 | 24 | public class FutureDecorator implements Future { 25 | 26 | private Future origin; 27 | 28 | public FutureDecorator(Future origin) { 29 | this.origin = origin; 30 | } 31 | 32 | @Override 33 | public boolean cancel(boolean mayInterruptIfRunning) { 34 | return origin.cancel(mayInterruptIfRunning); 35 | } 36 | 37 | @Override 38 | public boolean isCancelled() { 39 | return origin.isCancelled(); 40 | } 41 | 42 | @Override 43 | public boolean isDone() { 44 | return origin.isDone(); 45 | } 46 | 47 | @Override 48 | public Object get() throws InterruptedException, ExecutionException { 49 | Object result = origin.get(); 50 | if (result instanceof Future) { 51 | return ((Future) result).get(); 52 | } 53 | return result; 54 | } 55 | 56 | @Override 57 | public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { 58 | Object result = origin.get(timeout, unit); 59 | if (result instanceof Future) { 60 | return ((Future) result).get(); 61 | } 62 | return result; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/main/resources/dummy.txt: -------------------------------------------------------------------------------- 1 | ==== 2 | Copyright 2016 Netflix, Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ==== 16 | 17 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/domain/Domain.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.common.domain; 17 | 18 | 19 | public class Domain { 20 | } 21 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/domain/Profile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.common.domain; 17 | 18 | /** 19 | * Created by dmgcodevil on 1/9/2015. 20 | */ 21 | public class Profile { 22 | private String email; 23 | 24 | public String getEmail() { 25 | return email; 26 | } 27 | 28 | public void setEmail(String email) { 29 | this.email = email; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/collapser/CollapserTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.collapser; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.collapser.BasicCollapserTest; 19 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.beans.factory.annotation.Configurable; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.test.context.ContextConfiguration; 25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 26 | 27 | /** 28 | * This test covers "Request Collapsing" functionality. 29 | *

30 | * https://github.com/Netflix/Hystrix/wiki/How-To-Use#Collapsing 31 | */ 32 | @RunWith(SpringJUnit4ClassRunner.class) 33 | @ContextConfiguration(classes = {AopCglibConfig.class, CollapserTest.CollapserTestConfig.class}) 34 | public class CollapserTest extends BasicCollapserTest { 35 | 36 | @Autowired 37 | private BasicCollapserTest.UserService userService; 38 | 39 | @Override 40 | protected UserService createUserService() { 41 | return userService; 42 | } 43 | 44 | 45 | /** 46 | * Spring configuration. 47 | */ 48 | @Configurable 49 | public static class CollapserTestConfig { 50 | 51 | @Bean 52 | public UserService userService() { 53 | return new UserService(); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/command/cglib/CommandCGlibProxyTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.command.cglib; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.spring.command.CommandTest; 19 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.test.context.ContextConfiguration; 22 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 23 | 24 | @RunWith(SpringJUnit4ClassRunner.class) 25 | @ContextConfiguration(classes = {AopCglibConfig.class, CommandTest.CommandTestConfig.class}) 26 | public class CommandCGlibProxyTest extends CommandTest { 27 | } 28 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/command/jdk/CommandJdkProxyTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.command.jdk; 17 | 18 | 19 | import com.netflix.hystrix.contrib.javanica.test.spring.command.CommandTest; 20 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopJdkConfig; 21 | import org.junit.runner.RunWith; 22 | import org.springframework.test.context.ContextConfiguration; 23 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 24 | 25 | @RunWith(SpringJUnit4ClassRunner.class) 26 | @ContextConfiguration(classes = {AopJdkConfig.class, CommandTest.CommandTestConfig.class}) 27 | public class CommandJdkProxyTest extends CommandTest { 28 | } 29 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/conf/AopCglibConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.conf; 17 | 18 | import org.springframework.beans.factory.annotation.Configurable; 19 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 20 | import org.springframework.context.annotation.Import; 21 | 22 | @Configurable 23 | @Import(SpringApplicationContext.class) 24 | @EnableAspectJAutoProxy(proxyTargetClass = true) 25 | public class AopCglibConfig { 26 | } 27 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/conf/AopJdkConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.conf; 17 | 18 | import org.springframework.beans.factory.annotation.Configurable; 19 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 20 | import org.springframework.context.annotation.Import; 21 | 22 | @Configurable 23 | @Import(SpringApplicationContext.class) 24 | @EnableAspectJAutoProxy 25 | public class AopJdkConfig { 26 | } 27 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/conf/AopLoadTimeWeavingConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.conf; 17 | 18 | import org.springframework.beans.factory.annotation.Configurable; 19 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 20 | import org.springframework.context.annotation.EnableLoadTimeWeaving; 21 | import org.springframework.context.annotation.Import; 22 | 23 | @Configurable 24 | @Import(SpringApplicationContext.class) 25 | @EnableAspectJAutoProxy 26 | @EnableLoadTimeWeaving(aspectjWeaving = EnableLoadTimeWeaving.AspectJWeaving.ENABLED) 27 | public class AopLoadTimeWeavingConfig { 28 | } 29 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/conf/SpringApplicationContext.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.conf; 17 | 18 | import com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect; 19 | import org.springframework.beans.factory.annotation.Configurable; 20 | import org.springframework.context.annotation.Bean; 21 | import org.springframework.context.annotation.ComponentScan; 22 | 23 | @Configurable 24 | @ComponentScan("com.netflix.hystrix.contrib.javanica.test.spring") 25 | public class SpringApplicationContext { 26 | 27 | @Bean 28 | public HystrixCommandAspect hystrixAspect() { 29 | return new HystrixCommandAspect(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/configuration/collapser/CollapserPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.configuration.collapser; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.configuration.collapser.BasicCollapserPropertiesTest; 19 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.beans.factory.annotation.Configurable; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.test.context.ContextConfiguration; 25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 26 | 27 | @RunWith(SpringJUnit4ClassRunner.class) 28 | @ContextConfiguration(classes = {AopCglibConfig.class, CollapserPropertiesTest.CollapserPropertiesTestConfig.class}) 29 | public class CollapserPropertiesTest extends BasicCollapserPropertiesTest { 30 | 31 | @Autowired 32 | private UserService userService; 33 | 34 | @Override 35 | protected UserService createUserService() { 36 | return userService; 37 | } 38 | 39 | 40 | @Configurable 41 | public static class CollapserPropertiesTestConfig { 42 | 43 | @Bean 44 | public BasicCollapserPropertiesTest.UserService userService() { 45 | return new UserService(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/configuration/command/CommandDefaultPropertiesTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.test.spring.configuration.command; 2 | 3 | import com.netflix.hystrix.contrib.javanica.test.common.configuration.command.BasicCommandDefaultPropertiesTest; 4 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Configurable; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Scope; 10 | import org.springframework.test.context.ContextConfiguration; 11 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 12 | 13 | /** 14 | * Created by dmgcodevil. 15 | */ 16 | @RunWith(SpringJUnit4ClassRunner.class) 17 | @ContextConfiguration(classes = {AopCglibConfig.class, CommandDefaultPropertiesTest.Config.class}) 18 | public class CommandDefaultPropertiesTest extends BasicCommandDefaultPropertiesTest { 19 | 20 | @Autowired 21 | private Service service; 22 | 23 | @Override 24 | protected Service createService() { 25 | return service; 26 | } 27 | 28 | @Configurable 29 | public static class Config { 30 | @Bean 31 | @Scope(value = "prototype") 32 | public BasicCommandDefaultPropertiesTest.Service service() { 33 | return new BasicCommandDefaultPropertiesTest.Service(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/configuration/command/CommandPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.configuration.command; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.configuration.command.BasicCommandPropertiesTest; 19 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.beans.factory.annotation.Configurable; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.test.context.ContextConfiguration; 25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 26 | 27 | @RunWith(SpringJUnit4ClassRunner.class) 28 | @ContextConfiguration(classes = {AopCglibConfig.class, CommandPropertiesTest.CommandPropertiesTestConfig.class}) 29 | public class CommandPropertiesTest extends BasicCommandPropertiesTest { 30 | 31 | @Autowired 32 | private BasicCommandPropertiesTest.UserService userService; 33 | 34 | @Override 35 | protected UserService createUserService() { 36 | return userService; 37 | } 38 | 39 | 40 | @Configurable 41 | public static class CommandPropertiesTestConfig { 42 | 43 | @Bean 44 | public UserService userService() { 45 | return new UserService(); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/configuration/fallback/FallbackDefaultPropertiesTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.test.spring.configuration.fallback; 2 | 3 | import com.netflix.hystrix.contrib.javanica.test.common.configuration.fallback.BasicFallbackDefaultPropertiesTest; 4 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Configurable; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.test.context.ContextConfiguration; 10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 11 | 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | @ContextConfiguration(classes = {AopCglibConfig.class, FallbackDefaultPropertiesTest.Config.class}) 14 | public class FallbackDefaultPropertiesTest extends BasicFallbackDefaultPropertiesTest { 15 | 16 | @Autowired 17 | private Service service; 18 | 19 | @Override 20 | protected Service createService() { 21 | return service; 22 | } 23 | 24 | @Configurable 25 | public static class Config { 26 | @Bean 27 | public BasicFallbackDefaultPropertiesTest.Service service() { 28 | return new BasicFallbackDefaultPropertiesTest.Service(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/error/DefaultIgnoreExceptionsTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.test.spring.error; 2 | 3 | import com.netflix.hystrix.contrib.javanica.test.common.error.BasicDefaultIgnoreExceptionsTest; 4 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Configurable; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.test.context.ContextConfiguration; 10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 11 | 12 | /** 13 | * Created by dmgcodevil. 14 | */ 15 | @RunWith(SpringJUnit4ClassRunner.class) 16 | @ContextConfiguration(classes = {AopCglibConfig.class, DefaultIgnoreExceptionsTest.DefaultIgnoreExceptionsTestConfig.class}) 17 | public class DefaultIgnoreExceptionsTest extends BasicDefaultIgnoreExceptionsTest { 18 | 19 | 20 | @Autowired 21 | private BasicDefaultIgnoreExceptionsTest.Service service; 22 | 23 | @Override 24 | protected BasicDefaultIgnoreExceptionsTest.Service createService() { 25 | return service; 26 | } 27 | 28 | @Configurable 29 | public static class DefaultIgnoreExceptionsTestConfig { 30 | 31 | @Bean 32 | public BasicDefaultIgnoreExceptionsTest.Service userService() { 33 | return new BasicDefaultIgnoreExceptionsTest.Service(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/error/DefaultRaiseHystrixExceptionsTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.test.spring.error; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.beans.factory.annotation.Configurable; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.test.context.ContextConfiguration; 8 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 9 | 10 | import com.netflix.hystrix.contrib.javanica.test.common.error.BasicDefaultRaiseHystrixExceptionsTest; 11 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 12 | 13 | /** 14 | * Created by Mike Cowan 15 | */ 16 | @RunWith(SpringJUnit4ClassRunner.class) 17 | @ContextConfiguration(classes = {AopCglibConfig.class, DefaultRaiseHystrixExceptionsTest.DefaultRaiseHystrixExceptionsTestConfig.class}) 18 | public class DefaultRaiseHystrixExceptionsTest extends BasicDefaultRaiseHystrixExceptionsTest { 19 | 20 | @Autowired 21 | private BasicDefaultRaiseHystrixExceptionsTest.Service service; 22 | 23 | @Override 24 | protected BasicDefaultRaiseHystrixExceptionsTest.Service createService() { 25 | return service; 26 | } 27 | 28 | @Configurable 29 | public static class DefaultRaiseHystrixExceptionsTestConfig { 30 | 31 | @Bean 32 | public BasicDefaultRaiseHystrixExceptionsTest.Service userService() { 33 | return new BasicDefaultRaiseHystrixExceptionsTest.Service(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/error/ErrorPropagationTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.error; 17 | 18 | 19 | import com.netflix.hystrix.contrib.javanica.test.common.error.BasicErrorPropagationTest; 20 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 21 | import org.junit.runner.RunWith; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.beans.factory.annotation.Configurable; 24 | import org.springframework.context.annotation.Bean; 25 | import org.springframework.test.context.ContextConfiguration; 26 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 27 | 28 | /** 29 | * Test covers "Error Propagation" functionality. 30 | * https://github.com/Netflix/Hystrix/wiki/How-To-Use#ErrorPropagation 31 | */ 32 | @RunWith(SpringJUnit4ClassRunner.class) 33 | @ContextConfiguration(classes = {AopCglibConfig.class, ErrorPropagationTest.ErrorPropagationTestConfig.class}) 34 | public class ErrorPropagationTest extends BasicErrorPropagationTest { 35 | 36 | 37 | @Autowired 38 | private BasicErrorPropagationTest.UserService userService; 39 | 40 | @Override 41 | protected UserService createUserService() { 42 | return userService; 43 | } 44 | 45 | 46 | @Configurable 47 | public static class ErrorPropagationTestConfig { 48 | 49 | @Bean 50 | public UserService userService() { 51 | return new UserService(); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/error/ObservableErrorPropagationTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.error; 17 | 18 | 19 | import com.netflix.hystrix.contrib.javanica.test.common.error.BasicObservableErrorPropagationTest; 20 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 21 | import org.junit.runner.RunWith; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.beans.factory.annotation.Configurable; 24 | import org.springframework.context.annotation.Bean; 25 | import org.springframework.test.context.ContextConfiguration; 26 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 27 | 28 | /** 29 | * Test covers "Error Propagation" functionality. 30 | * https://github.com/Netflix/Hystrix/wiki/How-To-Use#ErrorPropagation 31 | */ 32 | @RunWith(SpringJUnit4ClassRunner.class) 33 | @ContextConfiguration(classes = {AopCglibConfig.class, ObservableErrorPropagationTest.ErrorPropagationTestConfig.class}) 34 | public class ObservableErrorPropagationTest extends BasicObservableErrorPropagationTest { 35 | 36 | 37 | @Autowired 38 | private UserService userService; 39 | 40 | @Override 41 | protected UserService createUserService() { 42 | return userService; 43 | } 44 | 45 | 46 | @Configurable 47 | public static class ErrorPropagationTestConfig { 48 | 49 | @Bean 50 | public UserService userService() { 51 | return new UserService(); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/fallback/CommandFallbackTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.fallback; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.fallback.BasicCommandFallbackTest; 19 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.beans.factory.annotation.Configurable; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.test.context.ContextConfiguration; 25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 26 | 27 | /** 28 | * Test covers "Fallback" functionality. 29 | *

30 | * https://github.com/Netflix/Hystrix/wiki/How-To-Use#Fallback 31 | */ 32 | @RunWith(SpringJUnit4ClassRunner.class) 33 | @ContextConfiguration(classes = {AopCglibConfig.class, CommandFallbackTest.CommandTestConfig.class}) 34 | public class CommandFallbackTest extends BasicCommandFallbackTest { 35 | 36 | @Autowired 37 | private UserService userService; 38 | 39 | @Override 40 | protected BasicCommandFallbackTest.UserService createUserService() { 41 | return userService; 42 | } 43 | 44 | @Configurable 45 | public static class CommandTestConfig { 46 | @Bean 47 | public UserService userService() { 48 | return new UserService(); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/fallback/DefaultFallbackTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.test.spring.fallback; 2 | 3 | import com.netflix.hystrix.contrib.javanica.test.common.fallback.BasicDefaultFallbackTest; 4 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Configurable; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.test.context.ContextConfiguration; 10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 11 | 12 | /** 13 | * Created by dmgcodevil. 14 | */ 15 | @RunWith(SpringJUnit4ClassRunner.class) 16 | @ContextConfiguration(classes = {AopCglibConfig.class, DefaultFallbackTest.Config.class}) 17 | public class DefaultFallbackTest extends BasicDefaultFallbackTest { 18 | 19 | @Autowired 20 | private ServiceWithDefaultFallback serviceWithDefaultFallback; 21 | @Autowired 22 | private ServiceWithDefaultCommandFallback serviceWithDefaultCommandFallback; 23 | 24 | 25 | @Override 26 | protected ServiceWithDefaultFallback createServiceWithDefaultFallback() { 27 | return serviceWithDefaultFallback; 28 | } 29 | 30 | @Override 31 | protected ServiceWithDefaultCommandFallback serviceWithDefaultCommandFallback() { 32 | return serviceWithDefaultCommandFallback; 33 | } 34 | 35 | @Configurable 36 | public static class Config { 37 | @Bean 38 | public ServiceWithDefaultFallback serviceWithDefaultFallback() { 39 | return new ServiceWithDefaultFallback(); 40 | } 41 | 42 | @Bean 43 | public ServiceWithDefaultCommandFallback serviceWithDefaultCommandFallback() { 44 | return new ServiceWithDefaultCommandFallback(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/fallback/GenericFallbackTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.test.spring.fallback; 2 | 3 | import com.netflix.hystrix.contrib.javanica.test.common.fallback.BasicGenericFallbackTest; 4 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.config.AutowireCapableBeanFactory; 7 | import org.springframework.context.ApplicationContext; 8 | import org.springframework.test.context.ContextConfiguration; 9 | 10 | /** 11 | * Created by dmgcodevil. 12 | */ 13 | @ContextConfiguration(classes = {AopCglibConfig.class}) 14 | public class GenericFallbackTest extends BasicGenericFallbackTest { 15 | 16 | @Autowired 17 | private ApplicationContext applicationContext; 18 | 19 | @Override 20 | protected T createProxy(Class t) { 21 | AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory(); 22 | return beanFactory.createBean(t); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/fallback/InheritedFallbackTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.test.spring.fallback; 2 | 3 | import com.netflix.hystrix.contrib.javanica.test.common.fallback.BasicCommandFallbackTest; 4 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Configurable; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.test.context.ContextConfiguration; 10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 11 | 12 | /** 13 | * Created by dmgcodevil. 14 | */ 15 | @RunWith(SpringJUnit4ClassRunner.class) 16 | @ContextConfiguration(classes = {AopCglibConfig.class, InheritedFallbackTest.CommandTestConfig.class}) 17 | public class InheritedFallbackTest extends BasicCommandFallbackTest { 18 | 19 | @Autowired 20 | private UserService userService; 21 | 22 | @Override 23 | protected BasicCommandFallbackTest.UserService createUserService() { 24 | return userService; 25 | } 26 | 27 | @Configurable 28 | public static class CommandTestConfig { 29 | @Bean 30 | public UserService userService() { 31 | return new SubClass(); 32 | } 33 | } 34 | 35 | public static class SubClass extends BasicCommandFallbackTest.UserService { 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/observable/ObservableTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.test.spring.observable; 17 | 18 | import com.netflix.hystrix.contrib.javanica.test.common.observable.BasicObservableTest; 19 | import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.beans.factory.annotation.Configurable; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.test.context.ContextConfiguration; 25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 26 | 27 | /** 28 | * Test covers "Reactive Execution" functionality. 29 | * https://github.com/Netflix/Hystrix/wiki/How-To-Use#Reactive-Execution 30 | */ 31 | @RunWith(SpringJUnit4ClassRunner.class) 32 | @ContextConfiguration(classes = {AopCglibConfig.class, ObservableTest.ObservableTestConfig.class}) 33 | public class ObservableTest extends BasicObservableTest { 34 | 35 | @Autowired 36 | private UserService userService; 37 | 38 | @Override 39 | protected UserService createUserService() { 40 | return userService; 41 | } 42 | 43 | @Configurable 44 | public static class ObservableTestConfig { 45 | 46 | @Bean 47 | public BasicObservableTest.UserService userService() { 48 | return new UserService(); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/util/GetMethodTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.contrib.javanica.util; 2 | 3 | import com.google.common.base.Optional; 4 | import com.netflix.hystrix.contrib.javanica.utils.MethodProvider; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.junit.runners.Parameterized; 8 | 9 | import java.lang.reflect.Method; 10 | import java.util.Arrays; 11 | import java.util.Collection; 12 | 13 | import static org.junit.Assert.assertEquals; 14 | import static org.junit.Assert.assertTrue; 15 | 16 | /** 17 | * Created by dmgcodevil. 18 | */ 19 | @RunWith(Parameterized.class) 20 | public class GetMethodTest { 21 | 22 | private String methodName; 23 | private Class[] parametersTypes; 24 | 25 | @Parameterized.Parameters 26 | public static Collection data() { 27 | return Arrays.asList(new Object[][] { 28 | { "foo", new Class[]{ String.class } }, 29 | { "bar", new Class[]{ Integer.class } } 30 | }); 31 | } 32 | 33 | public GetMethodTest(String methodName, Class[] parametersTypes) { 34 | this.methodName = methodName; 35 | this.parametersTypes = parametersTypes; 36 | } 37 | 38 | @Test 39 | public void testGetMethodFoo(){ 40 | Optional method = MethodProvider.getInstance().getMethod(C.class, methodName, parametersTypes); 41 | 42 | assertTrue(method.isPresent()); 43 | assertEquals(methodName, method.get().getName()); 44 | } 45 | 46 | 47 | public static class A { void foo(String in) {} } 48 | public static class B extends A { void bar(Integer in) {} } 49 | public static class C extends B{ } 50 | 51 | } -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/util/bridge/Child.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.util.bridge; 17 | 18 | /** 19 | * Created by dmgcodevil. 20 | */ 21 | public class Child extends Parent { 22 | } 23 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/util/bridge/GenericInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.util.bridge; 17 | 18 | /** 19 | * Created by dmgcodevil 20 | */ 21 | public interface GenericInterface { 22 | 23 | 24 | R foo(P1 p1); 25 | } 26 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/util/bridge/GenericInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.util.bridge; 17 | 18 | /** 19 | * Created by dmgcodevil 20 | */ 21 | public class GenericInterfaceImpl implements GenericInterface { 22 | 23 | 24 | public Child foo(SubChild c) { 25 | return null; 26 | } 27 | 28 | @Override 29 | public Child foo(Child c) { 30 | return null; 31 | } 32 | 33 | public Child foo(Parent c) { 34 | return null; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/util/bridge/Parent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.util.bridge; 17 | 18 | 19 | public class Parent { 20 | } 21 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/util/bridge/SubChild.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.javanica.util.bridge; 17 | 18 | /** 19 | * Created by dmgcodevil. 20 | */ 21 | public class SubChild extends Child { 22 | } 23 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/resources/dummy.txt: -------------------------------------------------------------------------------- 1 | ==== 2 | Copyright 2016 Netflix, Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ==== 16 | 17 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-javanica/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016 Netflix, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # Define the root logger with appender console 18 | log4j.rootLogger = ERROR, CONSOLE 19 | 20 | # Define the console appender 21 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 22 | 23 | # Define the layout for console appender 24 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 25 | log4j.appender.CONSOLE.layout.conversionPattern=%m%n 26 | 27 | log4j.logger.com.netflix.hystrix.contrib.javanica=DEBUG 28 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-junit/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | api "junit:junit:4.11" 4 | } 5 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-junit/src/main/java/com/hystrix/junit/HystrixRequestContextRule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.hystrix.junit; 17 | 18 | import com.netflix.hystrix.Hystrix; 19 | import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext; 20 | import org.junit.rules.ExternalResource; 21 | 22 | /** 23 | * JUnit rule to be used to simplify tests that require a HystrixRequestContext. 24 | * 25 | * Example of usage: 26 | * 27 | *

28 | *
29 |  *     @Rule
30 |  *     public HystrixRequestContextRule context = new HystrixRequestContextRule();
31 |  * 
32 | *
33 | * 34 | */ 35 | public final class HystrixRequestContextRule extends ExternalResource { 36 | private HystrixRequestContext context; 37 | 38 | @Override 39 | protected void before() { 40 | this.context = HystrixRequestContext.initializeContext(); 41 | Hystrix.reset(); 42 | } 43 | 44 | @Override 45 | protected void after() { 46 | if (this.context != null) { 47 | this.context.shutdown(); 48 | this.context = null; 49 | } 50 | } 51 | 52 | public HystrixRequestContext context() { 53 | return this.context; 54 | } 55 | 56 | public void reset() { 57 | after(); 58 | before(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-junit/src/test/java/com/hystrix/junit/HystrixRequestContextRuleTest.java: -------------------------------------------------------------------------------- 1 | package com.hystrix.junit; 2 | 3 | import org.hamcrest.CoreMatchers; 4 | import org.hamcrest.MatcherAssert; 5 | import org.junit.Rule; 6 | import org.junit.Test; 7 | 8 | public final class HystrixRequestContextRuleTest { 9 | @Rule 10 | public HystrixRequestContextRule request = new HystrixRequestContextRule(); 11 | 12 | @Test 13 | public void initsContext() { 14 | MatcherAssert.assertThat(this.request.context(), CoreMatchers.notNullValue()); 15 | } 16 | 17 | @Test 18 | public void manuallyShutdownContextDontBreak() { 19 | this.request.after(); 20 | this.request.after(); 21 | MatcherAssert.assertThat(this.request.context(), CoreMatchers.nullValue()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-metrics-event-stream-jaxrs/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | implementation project(':hystrix-serialization') 4 | compileOnly 'javax.ws.rs:javax.ws.rs-api:2.0.1' 5 | testImplementation 'junit:junit-dep:4.10' 6 | testImplementation 'org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.25.1' 7 | testImplementation 'org.glassfish.jersey.media:jersey-media-sse:2.25.1' 8 | 9 | } 10 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-metrics-event-stream-jaxrs/src/main/java/com/netflix/hystrix/contrib/metrics/HystrixStream.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.metrics; 17 | 18 | import java.util.concurrent.atomic.AtomicInteger; 19 | 20 | import rx.Observable; 21 | 22 | /** 23 | * @author justinjose28 24 | * 25 | */ 26 | public final class HystrixStream { 27 | private final Observable sampleStream; 28 | private final int pausePollerThreadDelayInMs; 29 | private final AtomicInteger concurrentConnections; 30 | 31 | public HystrixStream(Observable sampleStream, int pausePollerThreadDelayInMs, AtomicInteger concurrentConnections) { 32 | this.sampleStream = sampleStream; 33 | this.pausePollerThreadDelayInMs = pausePollerThreadDelayInMs; 34 | this.concurrentConnections = concurrentConnections; 35 | } 36 | 37 | public Observable getSampleStream() { 38 | return sampleStream; 39 | } 40 | 41 | public int getPausePollerThreadDelayInMs() { 42 | return pausePollerThreadDelayInMs; 43 | } 44 | 45 | public AtomicInteger getConcurrentConnections() { 46 | return concurrentConnections; 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-metrics-event-stream-jaxrs/src/main/java/com/netflix/hystrix/contrib/metrics/HystrixStreamFeature.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.metrics; 17 | 18 | import javax.ws.rs.core.Feature; 19 | import javax.ws.rs.core.FeatureContext; 20 | 21 | import com.netflix.hystrix.contrib.metrics.controller.HystrixConfigSseController; 22 | import com.netflix.hystrix.contrib.metrics.controller.HystrixMetricsStreamController; 23 | import com.netflix.hystrix.contrib.metrics.controller.HystrixRequestEventsSseController; 24 | import com.netflix.hystrix.contrib.metrics.controller.HystrixUtilizationSseController; 25 | 26 | /** 27 | * @author justinjose28 28 | * 29 | */ 30 | public class HystrixStreamFeature implements Feature { 31 | 32 | @Override 33 | public boolean configure(FeatureContext context) { 34 | context.register(new HystrixMetricsStreamController()); 35 | context.register(new HystrixUtilizationSseController()); 36 | context.register(new HystrixRequestEventsSseController()); 37 | context.register(new HystrixConfigSseController()); 38 | context.register(HystrixStreamingOutputProvider.class); 39 | return true; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-metrics-event-stream-jaxrs/src/test/java/com/netflix/hystrix/contrib/metrics/controller/HystrixConfigControllerTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.metrics.controller; 17 | 18 | /** 19 | * @author justinjose28 20 | * 21 | */ 22 | public class HystrixConfigControllerTest extends HystricsMetricsControllerTest { 23 | 24 | @Override 25 | protected String getPath() { 26 | return "hystrix/config.stream"; 27 | } 28 | 29 | @Override 30 | protected boolean isStreamValid(String data) { 31 | return data.contains("\"type\":\"HystrixConfig\""); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-metrics-event-stream-jaxrs/src/test/java/com/netflix/hystrix/contrib/metrics/controller/HystrixUtilizationControllerTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.contrib.metrics.controller; 17 | 18 | /** 19 | * @author justinjose28 20 | * 21 | */ 22 | public class HystrixUtilizationControllerTest extends HystricsMetricsControllerTest { 23 | 24 | @Override 25 | protected String getPath() { 26 | return "hystrix/utilization.stream"; 27 | } 28 | 29 | @Override 30 | protected boolean isStreamValid(String data) { 31 | return data.contains("\"type\":\"HystrixUtilization\""); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-metrics-event-stream-jaxrs/src/test/resources/test.properties: -------------------------------------------------------------------------------- 1 | hystrix.stream.utilization.intervalInMilliseconds=10 2 | hystrix.stream.dashboard.intervalInMilliseconds=10 3 | hystrix.stream.config.intervalInMilliseconds=10 4 | hystrix.config.stream.maxConcurrentConnections=3 5 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-metrics-event-stream/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | implementation project(':hystrix-serialization') 4 | compileOnly 'javax.servlet:servlet-api:2.5' 5 | testImplementation 'javax.servlet:servlet-api:2.5' 6 | testImplementation 'junit:junit-dep:4.10' 7 | testImplementation 'org.mockito:mockito-all:1.9.5' 8 | } 9 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-network-auditor-agent/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api 'org.javassist:javassist:3.19+' 3 | 4 | jar { 5 | // make a fatjar otherwise it's painful getting the boot-class-path correct when deploying 6 | from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } } 7 | manifest { 8 | attributes( 9 | "Agent-Class": "com.netflix.hystrix.contrib.networkauditor.HystrixNetworkAuditorAgent", 10 | "Can-Redefine-Classes": true, 11 | "Can-Retransform-Classes": true, 12 | "Boot-Class-Path": "hystrix-network-auditor-agent-" + version + ".jar", 13 | "Premain-Class": "com.netflix.hystrix.contrib.networkauditor.HystrixNetworkAuditorAgent") 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-request-servlet/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | compileOnly 'javax.servlet:servlet-api:2.5' 4 | } 5 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-rx-netty-metrics-stream/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | implementation project(':hystrix-serialization') 4 | api 'io.reactivex:rxnetty:0.4.17' 5 | implementation 'io.netty:netty-transport:4.1.3.Final' 6 | implementation 'io.netty:netty-buffer:4.1.3.Final' 7 | implementation 'io.netty:netty-codec-http:4.1.3.Final' 8 | testImplementation 'junit:junit-dep:4.10' 9 | testImplementation 'org.powermock:powermock-easymock-release-full:1.5.5' 10 | testImplementation 'org.easymock:easymock:3.2' 11 | } 12 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-servo-metrics-publisher/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | api 'com.netflix.servo:servo-core:0.10.1' 4 | testImplementation 'junit:junit-dep:4.10' 5 | testImplementation 'org.mockito:mockito-all:1.9.5' 6 | } 7 | -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-yammer-metrics-publisher/README.md: -------------------------------------------------------------------------------- 1 | # hystrix-yammer-metrics-publisher 2 | 3 | This is an implementation of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/index.html?com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) that publishes metrics using [Yammer Metrics](http://metrics.codahale.com) version 2. If you are using Coda Hale Metrics version 3, please use the [hystrix-codahale-metrics-publisher](../hystrix-codahale-metrics-publisher) module instead. 4 | 5 | See the [Metrics & Monitoring](https://github.com/Netflix/Hystrix/wiki/Metrics-and-Monitoring) Wiki for more information. 6 | 7 | # Binaries 8 | 9 | Binaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22hystrix-yammer-metrics-publisher%22). 10 | 11 | Example for Maven: 12 | 13 | ```xml 14 | 15 | com.netflix.hystrix 16 | hystrix-yammer-metrics-publisher 17 | 1.1.2 18 | 19 | ``` 20 | 21 | and for Ivy: 22 | 23 | ```xml 24 | 25 | ``` -------------------------------------------------------------------------------- /hystrix-contrib/hystrix-yammer-metrics-publisher/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | api 'com.yammer.metrics:metrics-core:2.2.0' 4 | } 5 | -------------------------------------------------------------------------------- /hystrix-core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'me.champeau.jmh' 2 | 3 | dependencies { 4 | api 'com.netflix.archaius:archaius-core:0.4.1' 5 | api 'io.reactivex:rxjava:1.2.0' 6 | implementation 'org.slf4j:slf4j-api:1.7.0' 7 | api 'org.hdrhistogram:HdrHistogram:2.1.9' 8 | testImplementation 'junit:junit-dep:4.10' 9 | testImplementation project(':hystrix-junit') 10 | } 11 | 12 | 13 | javadoc { 14 | // the exclude isn't working, nor is there a subPackages options as docs suggest there should be 15 | // we do not want the com.netflix.hystrix.util package include 16 | exclude '**/util/**' 17 | 18 | options { 19 | doclet = "org.benjchristensen.doclet.DocletExclude" 20 | docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] 21 | stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') 22 | windowTitle = "Hystrix Javadoc ${project.version}" 23 | } 24 | options.addStringOption('top').value = '

Hystrix: Latency and Fault Tolerance for Distributed Systems

' 25 | } 26 | 27 | jmh { 28 | fork = 10 29 | iterations = 3 30 | jmhVersion = '1.15' 31 | profilers = ['gc'] 32 | threads = 8 33 | warmup = '1s' 34 | warmupBatchSize = 1 35 | warmupIterations = 5 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-core/src/jmh/java/com/netflix/hystrix/perf/CommandConstructionPerfTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.perf; 17 | 18 | import com.netflix.hystrix.HystrixCommand; 19 | import com.netflix.hystrix.HystrixCommandGroupKey; 20 | import org.openjdk.jmh.annotations.Benchmark; 21 | import org.openjdk.jmh.annotations.BenchmarkMode; 22 | import org.openjdk.jmh.annotations.Mode; 23 | import org.openjdk.jmh.annotations.OutputTimeUnit; 24 | 25 | import java.util.concurrent.TimeUnit; 26 | 27 | public class CommandConstructionPerfTest { 28 | 29 | static HystrixCommandGroupKey groupKey = HystrixCommandGroupKey.Factory.asKey("Group"); 30 | 31 | @Benchmark 32 | @BenchmarkMode({Mode.SingleShotTime}) 33 | @OutputTimeUnit(TimeUnit.MICROSECONDS) 34 | public HystrixCommand constructHystrixCommandByGroupKeyOnly() { 35 | return new HystrixCommand(groupKey) { 36 | @Override 37 | protected Integer run() throws Exception { 38 | return 1; 39 | } 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/HystrixCachedObservable.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix; 2 | 3 | import rx.Observable; 4 | import rx.Subscription; 5 | import rx.functions.Action0; 6 | import rx.subjects.ReplaySubject; 7 | 8 | public class HystrixCachedObservable { 9 | protected final Subscription originalSubscription; 10 | protected final Observable cachedObservable; 11 | private volatile int outstandingSubscriptions = 0; 12 | 13 | protected HystrixCachedObservable(final Observable originalObservable) { 14 | ReplaySubject replaySubject = ReplaySubject.create(); 15 | this.originalSubscription = originalObservable 16 | .subscribe(replaySubject); 17 | 18 | this.cachedObservable = replaySubject 19 | .doOnUnsubscribe(new Action0() { 20 | @Override 21 | public void call() { 22 | outstandingSubscriptions--; 23 | if (outstandingSubscriptions == 0) { 24 | originalSubscription.unsubscribe(); 25 | } 26 | } 27 | }) 28 | .doOnSubscribe(new Action0() { 29 | @Override 30 | public void call() { 31 | outstandingSubscriptions++; 32 | } 33 | }); 34 | } 35 | 36 | public static HystrixCachedObservable from(Observable o, AbstractCommand originalCommand) { 37 | return new HystrixCommandResponseFromCache(o, originalCommand); 38 | } 39 | 40 | public static HystrixCachedObservable from(Observable o) { 41 | return new HystrixCachedObservable(o); 42 | } 43 | 44 | public Observable toObservable() { 45 | return cachedObservable; 46 | } 47 | 48 | public void unsubscribe() { 49 | originalSubscription.unsubscribe(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/HystrixInvokable.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix; 17 | 18 | /** 19 | * Marker interface for Hystrix commands that can be invoked. 20 | */ 21 | public interface HystrixInvokable { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/HystrixInvokableInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix; 17 | 18 | import java.util.List; 19 | 20 | public interface HystrixInvokableInfo { 21 | 22 | HystrixCommandGroupKey getCommandGroup(); 23 | 24 | HystrixCommandKey getCommandKey(); 25 | 26 | HystrixThreadPoolKey getThreadPoolKey(); 27 | 28 | String getPublicCacheKey(); //have to use public in the name, as there's already a protected {@link AbstractCommand#getCacheKey()} method. 29 | 30 | HystrixCollapserKey getOriginatingCollapserKey(); 31 | 32 | HystrixCommandMetrics getMetrics(); 33 | 34 | HystrixCommandProperties getProperties(); 35 | 36 | boolean isCircuitBreakerOpen(); 37 | 38 | boolean isExecutionComplete(); 39 | 40 | boolean isExecutedInThread(); 41 | 42 | boolean isSuccessfulExecution(); 43 | 44 | boolean isFailedExecution(); 45 | 46 | Throwable getFailedExecutionException(); 47 | 48 | boolean isResponseFromFallback(); 49 | 50 | boolean isResponseTimedOut(); 51 | 52 | boolean isResponseShortCircuited(); 53 | 54 | boolean isResponseFromCache(); 55 | 56 | boolean isResponseRejected(); 57 | 58 | boolean isResponseSemaphoreRejected(); 59 | 60 | boolean isResponseThreadPoolRejected(); 61 | 62 | List getExecutionEvents(); 63 | 64 | int getNumberEmissions(); 65 | 66 | int getNumberFallbackEmissions(); 67 | 68 | int getNumberCollapsed(); 69 | 70 | int getExecutionTimeInMilliseconds(); 71 | 72 | long getCommandRunStartTimeInNanos(); 73 | 74 | ExecutionResult.EventCounts getEventCounts(); 75 | } -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/HystrixKey.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix; 2 | 3 | /** 4 | * Basic class for hystrix keys 5 | */ 6 | public interface HystrixKey { 7 | /** 8 | * The word 'name' is used instead of 'key' so that Enums can implement this interface and it work natively. 9 | * 10 | * @return String 11 | */ 12 | String name(); 13 | 14 | /** 15 | * Default implementation of the interface 16 | */ 17 | abstract class HystrixKeyDefault implements HystrixKey { 18 | private final String name; 19 | 20 | public HystrixKeyDefault(String name) { 21 | this.name = name; 22 | } 23 | 24 | @Override 25 | public String name() { 26 | return name; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return name; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/HystrixMetrics.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix; 17 | 18 | import com.netflix.hystrix.util.HystrixRollingNumber; 19 | import com.netflix.hystrix.util.HystrixRollingNumberEvent; 20 | 21 | /** 22 | * Abstract base class for Hystrix metrics 23 | */ 24 | public abstract class HystrixMetrics { 25 | 26 | protected final HystrixRollingNumber counter; 27 | 28 | protected HystrixMetrics(HystrixRollingNumber counter) { 29 | this.counter = counter; 30 | } 31 | /** 32 | * Get the cumulative count since the start of the application for the given {@link HystrixRollingNumberEvent}. 33 | * 34 | * @param event 35 | * {@link HystrixRollingNumberEvent} of the event to retrieve a sum for 36 | * @return long cumulative count 37 | */ 38 | public long getCumulativeCount(HystrixRollingNumberEvent event) { 39 | return counter.getCumulativeSum(event); 40 | } 41 | 42 | /** 43 | * Get the rolling count for the given {@link HystrixRollingNumberEvent}. 44 | *

45 | * The rolling window is defined by {@link HystrixCommandProperties#metricsRollingStatisticalWindowInMilliseconds()}. 46 | * 47 | * @param event 48 | * {@link HystrixRollingNumberEvent} of the event to retrieve a sum for 49 | * @return long rolling count 50 | */ 51 | public long getRollingCount(HystrixRollingNumberEvent event) { 52 | return counter.getRollingSum(event); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/collapser/CollapserTimer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.collapser; 17 | 18 | import java.lang.ref.Reference; 19 | 20 | import com.netflix.hystrix.util.HystrixTimer.TimerListener; 21 | 22 | /** 23 | * Timer used for trigger batch execution. 24 | */ 25 | public interface CollapserTimer { 26 | 27 | public Reference addListener(TimerListener collapseTask); 28 | } -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/collapser/HystrixCollapserBridge.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.collapser; 17 | 18 | import java.util.Collection; 19 | 20 | import rx.Observable; 21 | 22 | import com.netflix.hystrix.HystrixCollapser.CollapsedRequest; 23 | import com.netflix.hystrix.HystrixCollapserKey; 24 | 25 | /** 26 | * Bridge between HystrixCollapser and RequestCollapser to expose 'protected' and 'private' functionality across packages. 27 | * 28 | * @param 29 | * @param 30 | * @param 31 | */ 32 | public interface HystrixCollapserBridge { 33 | 34 | Collection>> shardRequests(Collection> requests); 35 | 36 | Observable createObservableCommand(Collection> requests); 37 | 38 | Observable mapResponseToRequests(Observable batchResponse, Collection> requests); 39 | 40 | HystrixCollapserKey getCollapserKey(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/collapser/README.txt: -------------------------------------------------------------------------------- 1 | ==== 2 | Copyright 2016 Netflix, Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ==== 16 | 17 | This package is not part of the public API and can change at any time. Do not rely upon any classes in this package. 18 | 19 | The public API is com.netflix.hystrix.HystrixCollapser -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/collapser/RealCollapserTimer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.collapser; 17 | 18 | import java.lang.ref.Reference; 19 | 20 | import com.netflix.hystrix.util.HystrixTimer; 21 | import com.netflix.hystrix.util.HystrixTimer.TimerListener; 22 | 23 | /** 24 | * Actual CollapserTimer implementation for triggering batch execution that uses HystrixTimer. 25 | */ 26 | public class RealCollapserTimer implements CollapserTimer { 27 | /* single global timer that all collapsers will schedule their tasks on */ 28 | private final static HystrixTimer timer = HystrixTimer.getInstance(); 29 | 30 | @Override 31 | public Reference addListener(TimerListener collapseTask) { 32 | return timer.addTimerListener(collapseTask); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/exception/ExceptionNotWrappedByHystrix.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.exception; 2 | 3 | /** 4 | * Exceptions can implement this interface to prevent Hystrix from wrapping detected exceptions in a HystrixRuntimeException 5 | */ 6 | public interface ExceptionNotWrappedByHystrix { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/exception/HystrixBadRequestException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.exception; 17 | 18 | import com.netflix.hystrix.HystrixCommand; 19 | 20 | /** 21 | * An exception representing an error with provided arguments or state rather than an execution failure. 22 | *

23 | * Unlike all other exceptions thrown by a {@link HystrixCommand} this will not trigger fallback, not count against failure metrics and thus not trigger the circuit breaker. 24 | *

25 | * NOTE: This should only be used when an error is due to user input such as {@link IllegalArgumentException} otherwise it defeats the purpose of fault-tolerance and fallback behavior. 26 | */ 27 | public class HystrixBadRequestException extends RuntimeException { 28 | 29 | private static final long serialVersionUID = -8341452103561805856L; 30 | 31 | public HystrixBadRequestException(String message) { 32 | super(message); 33 | } 34 | 35 | public HystrixBadRequestException(String message, Throwable cause) { 36 | super(message, cause); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/exception/HystrixTimeoutException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.exception; 17 | 18 | import com.netflix.hystrix.HystrixCommand; 19 | import com.netflix.hystrix.HystrixObservableCommand; 20 | 21 | /** 22 | * An exception representing an error where the provided execution method took longer than the Hystrix timeout. 23 | *

24 | * Hystrix will trigger an exception of this type if it times out an execution. This class is public, so 25 | * user-defined execution methods ({@link HystrixCommand#run()} / {@link HystrixObservableCommand#construct()) may also 26 | * throw this error. If you want some types of failures to be counted as timeouts, you may wrap those failures in 27 | * a HystrixTimeoutException. See https://github.com/Netflix/Hystrix/issues/920 for more discussion. 28 | */ 29 | public class HystrixTimeoutException extends Exception { 30 | 31 | private static final long serialVersionUID = -5085623652043595962L; 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Custom exception implementations. 18 | * 19 | * @since 1.0.0 20 | */ 21 | package com.netflix.hystrix.exception; -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.metric; 17 | 18 | /** 19 | * Marker interface for events which may appear in an event stream 20 | */ 21 | public interface HystrixEvent { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixEventStream.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.metric; 17 | 18 | import rx.Observable; 19 | 20 | /** 21 | * Base interface for a stream of {@link com.netflix.hystrix.HystrixEventType}s. Allows consumption by individual 22 | * {@link com.netflix.hystrix.HystrixEventType} or by time-based bucketing of events 23 | */ 24 | public interface HystrixEventStream { 25 | 26 | Observable observe(); 27 | } 28 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixRequestEventsStream.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.metric; 17 | 18 | import com.netflix.hystrix.HystrixInvokableInfo; 19 | import rx.Observable; 20 | import rx.subjects.PublishSubject; 21 | import rx.subjects.Subject; 22 | 23 | import java.util.Collection; 24 | 25 | /** 26 | * Stream of requests, each of which contains a series of command executions 27 | */ 28 | public class HystrixRequestEventsStream { 29 | private final Subject writeOnlyRequestEventsSubject; 30 | private final Observable readOnlyRequestEvents; 31 | 32 | /* package */ HystrixRequestEventsStream() { 33 | writeOnlyRequestEventsSubject = PublishSubject.create(); 34 | readOnlyRequestEvents = writeOnlyRequestEventsSubject.onBackpressureBuffer(1024); 35 | } 36 | 37 | private static final HystrixRequestEventsStream INSTANCE = new HystrixRequestEventsStream(); 38 | 39 | public static HystrixRequestEventsStream getInstance() { 40 | return INSTANCE; 41 | } 42 | 43 | public void shutdown() { 44 | writeOnlyRequestEventsSubject.onCompleted(); 45 | } 46 | 47 | public void write(Collection> executions) { 48 | HystrixRequestEvents requestEvents = new HystrixRequestEvents(executions); 49 | writeOnlyRequestEventsSubject.onNext(requestEvents); 50 | } 51 | 52 | public Observable observe() { 53 | return readOnlyRequestEvents; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/metric/sample/HystrixCommandUtilization.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.metric.sample; 17 | 18 | import com.netflix.hystrix.HystrixCommandMetrics; 19 | 20 | public class HystrixCommandUtilization { 21 | private final int concurrentCommandCount; 22 | 23 | public HystrixCommandUtilization(int concurrentCommandCount) { 24 | this.concurrentCommandCount = concurrentCommandCount; 25 | } 26 | 27 | public static HystrixCommandUtilization sample(HystrixCommandMetrics commandMetrics) { 28 | return new HystrixCommandUtilization(commandMetrics.getCurrentConcurrentExecutionCount()); 29 | } 30 | 31 | public int getConcurrentCommandCount() { 32 | return concurrentCommandCount; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/metric/sample/HystrixUtilization.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.metric.sample; 17 | 18 | import com.netflix.hystrix.HystrixCommandKey; 19 | import com.netflix.hystrix.HystrixThreadPoolKey; 20 | 21 | import java.util.Map; 22 | 23 | public class HystrixUtilization { 24 | private final Map commandUtilizationMap; 25 | private final Map threadPoolUtilizationMap; 26 | 27 | public HystrixUtilization(Map commandUtilizationMap, Map threadPoolUtilizationMap) { 28 | this.commandUtilizationMap = commandUtilizationMap; 29 | this.threadPoolUtilizationMap = threadPoolUtilizationMap; 30 | } 31 | 32 | public static HystrixUtilization from(Map commandUtilizationMap, 33 | Map threadPoolUtilizationMap) { 34 | return new HystrixUtilization(commandUtilizationMap, threadPoolUtilizationMap); 35 | } 36 | 37 | public Map getCommandUtilizationMap() { 38 | return commandUtilizationMap; 39 | } 40 | 41 | public Map getThreadPoolUtilizationMap() { 42 | return threadPoolUtilizationMap; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Core functionality of Hystrix including the HystrixCommand and HystrixCollapser to be extended from. 18 | * 19 | * @since 1.0.0 20 | */ 21 | package com.netflix.hystrix; -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixConcurrencyStrategyDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.concurrency; 17 | 18 | /** 19 | * Default implementation of {@link HystrixConcurrencyStrategy} using standard java.util.concurrent.* implementations. 20 | * 21 | * @ExcludeFromJavadoc 22 | */ 23 | public class HystrixConcurrencyStrategyDefault extends HystrixConcurrencyStrategy { 24 | 25 | private static HystrixConcurrencyStrategyDefault INSTANCE = new HystrixConcurrencyStrategyDefault(); 26 | 27 | public static HystrixConcurrencyStrategy getInstance() { 28 | return INSTANCE; 29 | } 30 | 31 | private HystrixConcurrencyStrategyDefault() { 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestVariable.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.concurrency; 17 | 18 | import com.netflix.hystrix.strategy.HystrixPlugins; 19 | 20 | /** 21 | * Interface for a variable similar to {@link ThreadLocal} but scoped at the user request level. 22 | *

23 | * Default implementation is {@link HystrixRequestVariableDefault} managed by {@link HystrixRequestContext}. 24 | *

25 | * Custom implementations can be injected using {@link HystrixPlugins} and {@link HystrixConcurrencyStrategy#getRequestVariable}. 26 | *

27 | * See JavaDoc of {@link HystrixRequestContext} for more information about functionality this enables and how to use the default implementation. 28 | * 29 | * @param 30 | * Type to be stored on the HystrixRequestVariable 31 | */ 32 | public interface HystrixRequestVariable extends HystrixRequestVariableLifecycle { 33 | 34 | /** 35 | * Retrieve current value or initialize and then return value for this variable for the current request scope. 36 | * 37 | * @return T value of variable for current request scope. 38 | */ 39 | public T get(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestVariableLifecycle.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.concurrency; 17 | 18 | /** 19 | * Interface for lifecycle methods that are then executed by an implementation of {@link HystrixRequestVariable}. 20 | * 21 | * @param 22 | */ 23 | public interface HystrixRequestVariableLifecycle { 24 | 25 | /** 26 | * Invoked when {@link HystrixRequestVariable#get()} is first called. 27 | *

28 | * When using the default implementation this is invoked when {@link HystrixRequestVariableDefault#get()} is called. 29 | * 30 | * @return T with initial value or null if none. 31 | */ 32 | public T initialValue(); 33 | 34 | /** 35 | * Invoked when request scope is shutdown to allow for cleanup. 36 | *

37 | * When using the default implementation this is invoked when {@link HystrixRequestContext#shutdown()} is called. 38 | *

39 | * The {@link HystrixRequestVariable#get()} method should not be called from within this method as it will result in {@link #initialValue()} being called again. 40 | * 41 | * @param value 42 | * of request variable to allow cleanup activity. 43 | *

44 | * If nothing needs to be cleaned up then nothing needs to be done in this method. 45 | */ 46 | public void shutdown(T value); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Strategy definition for concurrency related behavior and default implementation. 18 | * 19 | * @since 1.0.0 20 | */ 21 | package com.netflix.hystrix.strategy.concurrency; -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/eventnotifier/HystrixEventNotifierDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.eventnotifier; 17 | 18 | 19 | /** 20 | * Default implementations of {@link HystrixEventNotifier} that does nothing. 21 | * 22 | * @ExcludeFromJavadoc 23 | */ 24 | public class HystrixEventNotifierDefault extends HystrixEventNotifier { 25 | 26 | private static HystrixEventNotifierDefault INSTANCE = new HystrixEventNotifierDefault(); 27 | 28 | private HystrixEventNotifierDefault() { 29 | 30 | } 31 | 32 | public static HystrixEventNotifier getInstance() { 33 | return INSTANCE; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/eventnotifier/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Strategy definition for event notification. 18 | * 19 | * @since 1.0.0 20 | */ 21 | package com.netflix.hystrix.strategy.eventnotifier; -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/executionhook/HystrixCommandExecutionHookDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.executionhook; 17 | 18 | /** 19 | * Default implementations of {@link HystrixCommandExecutionHook} that does nothing. 20 | * 21 | * @ExcludeFromJavadoc 22 | */ 23 | public class HystrixCommandExecutionHookDefault extends HystrixCommandExecutionHook { 24 | 25 | private static HystrixCommandExecutionHookDefault INSTANCE = new HystrixCommandExecutionHookDefault(); 26 | 27 | private HystrixCommandExecutionHookDefault() { 28 | 29 | } 30 | 31 | public static HystrixCommandExecutionHook getInstance() { 32 | return INSTANCE; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/executionhook/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Strategy definition for execution hook. 18 | * 19 | * @since 1.2.0 20 | */ 21 | package com.netflix.hystrix.strategy.executionhook; -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherCollapser.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.metrics; 17 | 18 | import com.netflix.hystrix.HystrixCollapser; 19 | 20 | /** 21 | * Metrics publisher for a {@link HystrixCollapser} that will be constructed by an implementation of {@link HystrixMetricsPublisher}. 22 | *

23 | * Instantiation of implementations of this interface should NOT allocate resources that require shutdown, register listeners or other such global state changes. 24 | *

25 | * The initialize() method will be called once-and-only-once to indicate when this instance can register with external services, start publishing metrics etc. 26 | *

27 | * Doing this logic in the constructor could result in memory leaks, double-publishing and other such behavior because this can be optimistically constructed more than once and "extras" discarded with 28 | * only one actually having initialize() called on it. 29 | */ 30 | public interface HystrixMetricsPublisherCollapser { 31 | 32 | // TODO should the arguments be given via initialize rather than constructor so people can't accidentally do it wrong? 33 | 34 | public void initialize(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherCollapserDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.metrics; 17 | 18 | import com.netflix.hystrix.HystrixCollapserKey; 19 | import com.netflix.hystrix.HystrixCollapserMetrics; 20 | import com.netflix.hystrix.HystrixCollapserProperties; 21 | 22 | /** 23 | * Default implementation of {@link HystrixMetricsPublisherCollapser} that does nothing. 24 | *

25 | * See Wiki docs about plugins for more information. 26 | * 27 | * @ExcludeFromJavadoc 28 | */ 29 | public class HystrixMetricsPublisherCollapserDefault implements HystrixMetricsPublisherCollapser { 30 | 31 | public HystrixMetricsPublisherCollapserDefault(HystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, HystrixCollapserProperties properties) { 32 | // do nothing by default 33 | } 34 | 35 | @Override 36 | public void initialize() { 37 | // do nothing by default 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.metrics; 17 | 18 | import com.netflix.hystrix.HystrixCommand; 19 | 20 | /** 21 | * Metrics publisher for a {@link HystrixCommand} that will be constructed by an implementation of {@link HystrixMetricsPublisher}. 22 | *

23 | * Instantiation of implementations of this interface should NOT allocate resources that require shutdown, register listeners or other such global state changes. 24 | *

25 | * The initialize() method will be called once-and-only-once to indicate when this instance can register with external services, start publishing metrics etc. 26 | *

27 | * Doing this logic in the constructor could result in memory leaks, double-publishing and other such behavior because this can be optimistically constructed more than once and "extras" discarded with 28 | * only one actually having initialize() called on it. 29 | */ 30 | public interface HystrixMetricsPublisherCommand { 31 | 32 | // TODO should the arguments be given via initialize rather than constructor so they can't accidentally do it wrong? 33 | 34 | public void initialize(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherCommandDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.metrics; 17 | 18 | import com.netflix.hystrix.HystrixCircuitBreaker; 19 | import com.netflix.hystrix.HystrixCommandGroupKey; 20 | import com.netflix.hystrix.HystrixCommandKey; 21 | import com.netflix.hystrix.HystrixCommandMetrics; 22 | import com.netflix.hystrix.HystrixCommandProperties; 23 | 24 | /** 25 | * Default implementation of {@link HystrixMetricsPublisherCommand} that does nothing. 26 | *

27 | * See Wiki docs about plugins for more information. 28 | * 29 | * @ExcludeFromJavadoc 30 | */ 31 | public class HystrixMetricsPublisherCommandDefault implements HystrixMetricsPublisherCommand { 32 | 33 | public HystrixMetricsPublisherCommandDefault(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) { 34 | // do nothing by default 35 | } 36 | 37 | @Override 38 | public void initialize() { 39 | // do nothing by default 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.metrics; 17 | 18 | /** 19 | * Default implementation of {@link HystrixMetricsPublisher}. 20 | *

21 | * See Wiki docs about plugins for more information. 22 | * 23 | * @ExcludeFromJavadoc 24 | */ 25 | public class HystrixMetricsPublisherDefault extends HystrixMetricsPublisher { 26 | 27 | private static HystrixMetricsPublisherDefault INSTANCE = new HystrixMetricsPublisherDefault(); 28 | 29 | public static HystrixMetricsPublisher getInstance() { 30 | return INSTANCE; 31 | } 32 | 33 | private HystrixMetricsPublisherDefault() { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherThreadPool.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.metrics; 17 | 18 | import com.netflix.hystrix.HystrixThreadPool; 19 | 20 | /** 21 | * Metrics publisher for a {@link HystrixThreadPool} that will be constructed by an implementation of {@link HystrixMetricsPublisher}. 22 | *

23 | * Instantiation of implementations of this interface should NOT allocate resources that require shutdown, register listeners or other such global state changes. 24 | *

25 | * The initialize() method will be called once-and-only-once to indicate when this instance can register with external services, start publishing metrics etc. 26 | *

27 | * Doing this logic in the constructor could result in memory leaks, double-publishing and other such behavior because this can be optimistically constructed more than once and "extras" discarded with 28 | * only one actually having initialize() called on it. 29 | */ 30 | public interface HystrixMetricsPublisherThreadPool { 31 | 32 | // TODO should the arguments be given via initialize rather than constructor so people can't accidentally do it wrong? 33 | 34 | public void initialize(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherThreadPoolDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.metrics; 17 | 18 | import com.netflix.hystrix.HystrixThreadPoolKey; 19 | import com.netflix.hystrix.HystrixThreadPoolMetrics; 20 | import com.netflix.hystrix.HystrixThreadPoolProperties; 21 | 22 | /** 23 | * Default implementation of {@link HystrixMetricsPublisherThreadPool} that does nothing. 24 | *

25 | * See Wiki docs about plugins for more information. 26 | * 27 | * @ExcludeFromJavadoc 28 | */ 29 | public class HystrixMetricsPublisherThreadPoolDefault implements HystrixMetricsPublisherThreadPool { 30 | 31 | public HystrixMetricsPublisherThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, HystrixThreadPoolProperties properties) { 32 | // do nothing by default 33 | } 34 | 35 | @Override 36 | public void initialize() { 37 | // do nothing by default 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Strategy definition for publishing metrics and default implementation. 18 | * 19 | * @since 1.0.0 20 | */ 21 | package com.netflix.hystrix.strategy.metrics; -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Parent package of strategies and plugin management. 18 | * 19 | * @since 1.0.0 20 | */ 21 | package com.netflix.hystrix.strategy; -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixDynamicProperty.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.properties; 17 | 18 | /** 19 | * Generic interface to represent a dynamic property value so Hystrix can consume 20 | * properties without being tied to any particular backing implementation. 21 | * 22 | * @author agentgt 23 | * 24 | * @param 25 | * Type of property value. 26 | * @see HystrixProperty 27 | * @see HystrixDynamicProperties 28 | */ 29 | public interface HystrixDynamicProperty extends HystrixProperty{ 30 | 31 | public String getName(); 32 | 33 | /** 34 | * Register a callback to be run if the property is updated. 35 | * Backing implementations may choose to do nothing. 36 | * @param callback callback. 37 | */ 38 | public void addCallback(Runnable callback); 39 | 40 | } -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesCollapserDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.properties; 17 | 18 | import com.netflix.hystrix.HystrixCollapserKey; 19 | import com.netflix.hystrix.HystrixCollapserProperties; 20 | 21 | /** 22 | * Default implementation of {@link HystrixCollapserProperties} using Archaius (https://github.com/Netflix/archaius) 23 | * 24 | * @ExcludeFromJavadoc 25 | */ 26 | public class HystrixPropertiesCollapserDefault extends HystrixCollapserProperties { 27 | 28 | public HystrixPropertiesCollapserDefault(HystrixCollapserKey collapserKey, Setter builder) { 29 | super(collapserKey, builder); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesCommandDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.properties; 17 | 18 | import com.netflix.hystrix.HystrixCommandKey; 19 | import com.netflix.hystrix.HystrixCommandProperties; 20 | 21 | /** 22 | * Default implementation of {@link HystrixCommandProperties} using Archaius (https://github.com/Netflix/archaius) 23 | * 24 | * @ExcludeFromJavadoc 25 | */ 26 | public class HystrixPropertiesCommandDefault extends HystrixCommandProperties { 27 | 28 | public HystrixPropertiesCommandDefault(HystrixCommandKey key, Setter builder) { 29 | super(key, builder); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesStrategyDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.properties; 17 | 18 | /** 19 | * Default implementation of {@link HystrixPropertiesStrategy}. 20 | * 21 | * @ExcludeFromJavadoc 22 | */ 23 | public class HystrixPropertiesStrategyDefault extends HystrixPropertiesStrategy { 24 | 25 | private final static HystrixPropertiesStrategyDefault INSTANCE = new HystrixPropertiesStrategyDefault(); 26 | 27 | private HystrixPropertiesStrategyDefault() { 28 | } 29 | 30 | public static HystrixPropertiesStrategy getInstance() { 31 | return INSTANCE; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesThreadPoolDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.properties; 17 | 18 | import com.netflix.hystrix.HystrixThreadPoolKey; 19 | import com.netflix.hystrix.HystrixThreadPoolProperties; 20 | 21 | /** 22 | * Default implementation of {@link HystrixThreadPoolProperties} using Archaius (https://github.com/Netflix/archaius) 23 | * 24 | * @ExcludeFromJavadoc 25 | */ 26 | public class HystrixPropertiesThreadPoolDefault extends HystrixThreadPoolProperties { 27 | 28 | protected HystrixPropertiesThreadPoolDefault(HystrixThreadPoolKey key, Setter builder) { 29 | super(key, builder); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesTimerThreadPoolDefault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.strategy.properties; 17 | 18 | import com.netflix.hystrix.HystrixTimerThreadPoolProperties; 19 | 20 | /** 21 | * Default implementation of {@link HystrixTimerThreadPoolProperties} using Archaius (https://github.com/Netflix/archaius) 22 | * 23 | * @ExcludeFromJavadoc 24 | */ 25 | public class HystrixPropertiesTimerThreadPoolDefault extends HystrixTimerThreadPoolProperties { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Strategy definition for properties and configuration and default implementation. 18 | * 19 | * @since 1.0.0 20 | */ 21 | package com.netflix.hystrix.strategy.properties; -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/util/ExceptionThreadingUtility.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.util; 17 | 18 | @Deprecated 19 | public class ExceptionThreadingUtility { 20 | 21 | @Deprecated //this functionality is no longer supported 22 | public static void attachCallingThreadStack(Throwable e) { 23 | //no-op now 24 | } 25 | 26 | @Deprecated //this functionality is no longer supported 27 | public static void assignCallingThread(Thread callingThread) { 28 | //no-op now 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/util/Exceptions.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.util; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class Exceptions { 7 | private Exceptions() { 8 | } 9 | 10 | /** 11 | * Throws the argument, return-type is RuntimeException so the caller can use a throw statement break out of the method 12 | */ 13 | public static RuntimeException sneakyThrow(Throwable t) { 14 | return Exceptions.doThrow(t); 15 | } 16 | 17 | private static T doThrow(Throwable ex) throws T { 18 | throw (T) ex; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/util/InternMap.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.util; 2 | 3 | import java.util.concurrent.ConcurrentHashMap; 4 | import java.util.concurrent.ConcurrentMap; 5 | 6 | /** 7 | * Utility to have 'intern' - like functionality, which holds single instance of wrapper for a given key 8 | */ 9 | public class InternMap { 10 | private final ConcurrentMap storage = new ConcurrentHashMap(); 11 | private final ValueConstructor valueConstructor; 12 | 13 | public interface ValueConstructor { 14 | V create(K key); 15 | } 16 | 17 | public InternMap(ValueConstructor valueConstructor) { 18 | this.valueConstructor = valueConstructor; 19 | } 20 | 21 | public V interned(K key) { 22 | V existingKey = storage.get(key); 23 | V newKey = null; 24 | if (existingKey == null) { 25 | newKey = valueConstructor.create(key); 26 | existingKey = storage.putIfAbsent(key, newKey); 27 | } 28 | return existingKey != null ? existingKey : newKey; 29 | } 30 | 31 | public int size() { 32 | return storage.size(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /hystrix-core/src/main/java/com/netflix/hystrix/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Common utility classes. 18 | * 19 | * @since 1.0.0 20 | */ 21 | package com.netflix.hystrix.util; -------------------------------------------------------------------------------- /hystrix-core/src/test/java/com/netflix/hystrix/NotWrappedByHystrixTestException.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix; 2 | 3 | import com.netflix.hystrix.exception.ExceptionNotWrappedByHystrix; 4 | 5 | public class NotWrappedByHystrixTestException extends Exception implements ExceptionNotWrappedByHystrix { 6 | private static final long serialVersionUID = 1L; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /hystrix-core/src/test/java/com/netflix/hystrix/NotWrappedByHystrixTestRuntimeException.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix; 2 | 3 | import com.netflix.hystrix.exception.ExceptionNotWrappedByHystrix; 4 | 5 | public class NotWrappedByHystrixTestRuntimeException extends RuntimeException implements ExceptionNotWrappedByHystrix { 6 | private static final long serialVersionUID = 1L; 7 | 8 | public NotWrappedByHystrixTestRuntimeException() { 9 | super("Raw exception for TestHystrixCommand"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /hystrix-core/src/test/java/com/netflix/hystrix/TestHystrixObservableCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix; 17 | 18 | abstract public class TestHystrixObservableCommand extends HystrixObservableCommand implements AbstractTestHystrixCommand { 19 | 20 | private final TestCommandBuilder builder; 21 | 22 | public TestHystrixObservableCommand(TestCommandBuilder builder) { 23 | super(builder.owner, builder.dependencyKey, builder.threadPoolKey, builder.circuitBreaker, builder.threadPool, 24 | builder.commandPropertiesDefaults, builder.threadPoolPropertiesDefaults, builder.metrics, 25 | builder.fallbackSemaphore, builder.executionSemaphore, TEST_PROPERTIES_FACTORY, builder.executionHook); 26 | this.builder = builder; 27 | } 28 | 29 | public TestCommandBuilder getBuilder() { 30 | return builder; 31 | } 32 | 33 | static TestCommandBuilder testPropsBuilder() { 34 | return new TestCommandBuilder(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE); 35 | } 36 | 37 | static TestCommandBuilder testPropsBuilder(HystrixCircuitBreakerTest.TestCircuitBreaker circuitBreaker) { 38 | return new TestCommandBuilder(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE).setCircuitBreaker(circuitBreaker); 39 | } 40 | 41 | static TestCommandBuilder testPropsBuilder(HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy, HystrixCircuitBreakerTest.TestCircuitBreaker circuitBreaker) { 42 | return new TestCommandBuilder(isolationStrategy).setCircuitBreaker(circuitBreaker); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /hystrix-core/src/test/java/com/netflix/hystrix/util/ExceptionsTest.java: -------------------------------------------------------------------------------- 1 | package com.netflix.hystrix.util; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import java.io.IOException; 7 | 8 | import static org.junit.Assert.assertTrue; 9 | import static org.junit.Assert.fail; 10 | 11 | public class ExceptionsTest { 12 | 13 | @Test 14 | public void testCastOfException(){ 15 | Exception exception = new IOException("simulated checked exception message"); 16 | try{ 17 | Exceptions.sneakyThrow(exception); 18 | fail(); 19 | } catch(Exception e){ 20 | assertTrue(e instanceof IOException); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /hystrix-core/src/test/resources/FAKE_META_INF_SERVICES/com.netflix.hystrix.strategy.properties.HystrixDynamicProperties: -------------------------------------------------------------------------------- 1 | com.netflix.hystrix.strategy.HystrixPluginsTest$MockHystrixDynamicPropertiesTest -------------------------------------------------------------------------------- /hystrix-core/src/test/resources/FAKE_META_INF_SERVICES/com.netflix.hystrix.strategy.properties.HystrixDynamicPropertiesFail: -------------------------------------------------------------------------------- 1 | FAILDONOTWORK -------------------------------------------------------------------------------- /hystrix-examples-webapp/README.md: -------------------------------------------------------------------------------- 1 | # hystrix-examples-webapp 2 | 3 | Web application that demonstrates functionality from [hystrix-examples](https://github.com/Netflix/Hystrix/tree/master/hystrix-examples) and functionality from [hystrix-request-servlet](https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-request-servlet) and [hystrix-metrics-event-stream](https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-metrics-event-stream). 4 | 5 | The [hystrix-dashboard](https://github.com/Netflix/Hystrix/tree/master/hystrix-dashboard) can be used on this example app to monitor its metrics. 6 | 7 | # Run via Gradle 8 | 9 | ``` 10 | $ git clone git@github.com:Netflix/Hystrix.git 11 | $ cd Hystrix/hystrix-examples-webapp 12 | $ ../gradlew appRun 13 | > Building > :hystrix-examples-webapp:appRun > Running at http://localhost:8989/hystrix-examples-webapp 14 | ``` 15 | 16 | Once running, open http://localhost:8989/hystrix-examples-webapp. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /hystrix-examples-webapp/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | maven { 4 | url "https://plugins.gradle.org/m2/" 5 | } 6 | } 7 | dependencies { 8 | classpath "org.gretty:gretty:3.0.5" 9 | } 10 | } 11 | 12 | apply plugin: "org.gretty" 13 | apply plugin: 'war' 14 | 15 | 16 | dependencies { 17 | api project(':hystrix-core') 18 | api project(':hystrix-examples') 19 | api project(':hystrix-request-servlet') 20 | api project(':hystrix-metrics-event-stream') 21 | } 22 | 23 | gretty { 24 | httpPort = 8989 25 | servletContainer = 'jetty9' 26 | } 27 | -------------------------------------------------------------------------------- /hystrix-examples-webapp/src/main/webapp/WEB-INF/classes/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, FILE 2 | log4j.appender.FILE=org.apache.log4j.ConsoleAppender 3 | log4j.appender.FILE.layout=org.apache.log4j.PatternLayout 4 | log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %C:%L [%C{1}] [%M]: %m%n 5 | 6 | log4j.appender.FILE.httpclient=ERROR 7 | -------------------------------------------------------------------------------- /hystrix-examples/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':hystrix-core') 3 | compileOnly 'junit:junit-dep:4.10' 4 | } 5 | 6 | task(runDemo, dependsOn: 'classes', type: JavaExec) { 7 | main = 'com.netflix.hystrix.examples.demo.HystrixCommandDemo' 8 | classpath = sourceSets.main.runtimeClasspath 9 | } 10 | -------------------------------------------------------------------------------- /hystrix-examples/src/main/java/com/netflix/hystrix/examples/basic/CommandUsingSemaphoreIsolation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.examples.basic; 17 | 18 | import com.netflix.hystrix.HystrixCommand; 19 | import com.netflix.hystrix.HystrixCommandGroupKey; 20 | import com.netflix.hystrix.HystrixCommandProperties; 21 | import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy; 22 | 23 | /** 24 | * Example of {@link HystrixCommand} defaulting to use a semaphore isolation strategy 25 | * when its run() method will not perform network traffic. 26 | */ 27 | public class CommandUsingSemaphoreIsolation extends HystrixCommand { 28 | 29 | private final int id; 30 | 31 | public CommandUsingSemaphoreIsolation(int id) { 32 | super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup")) 33 | // since we're doing work in the run() method that doesn't involve network traffic 34 | // and executes very fast with low risk we choose SEMAPHORE isolation 35 | .andCommandPropertiesDefaults(HystrixCommandProperties.Setter() 36 | .withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE))); 37 | this.id = id; 38 | } 39 | 40 | @Override 41 | protected String run() { 42 | // a real implementation would retrieve data from in memory data structure 43 | // or some other similar non-network involved work 44 | return "ValueFromHashMap_" + id; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hystrix-examples/src/main/java/com/netflix/hystrix/examples/demo/Order.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.examples.demo; 17 | 18 | import java.net.HttpCookie; 19 | 20 | /** 21 | * POJO 22 | */ 23 | public class Order { 24 | 25 | private final int orderId; 26 | private UserAccount user; 27 | 28 | public Order(int orderId) { 29 | this.orderId = orderId; 30 | 31 | /* a contrived example of calling GetUserAccount again */ 32 | user = new GetUserAccountCommand(new HttpCookie("mockKey", "mockValueFromHttpRequest")).execute(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /hystrix-examples/src/main/java/com/netflix/hystrix/examples/demo/PaymentInformation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.examples.demo; 17 | 18 | /** 19 | * POJO 20 | */ 21 | public class PaymentInformation { 22 | 23 | private final UserAccount user; 24 | private final String creditCardNumber; 25 | private final int expirationMonth; 26 | private final int expirationYear; 27 | 28 | public PaymentInformation(UserAccount user, String creditCardNumber, int expirationMonth, int expirationYear) { 29 | this.user = user; 30 | this.creditCardNumber = creditCardNumber; 31 | this.expirationMonth = expirationMonth; 32 | this.expirationYear = expirationYear; 33 | } 34 | 35 | public String getCreditCardNumber() { 36 | return creditCardNumber; 37 | } 38 | 39 | public int getExpirationMonth() { 40 | return expirationMonth; 41 | } 42 | 43 | public int getExpirationYear() { 44 | return expirationYear; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hystrix-examples/src/main/java/com/netflix/hystrix/examples/demo/UserAccount.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.examples.demo; 17 | 18 | /** 19 | * Simple POJO to represent a user and their metadata. 20 | */ 21 | public class UserAccount { 22 | 23 | private final int userId; 24 | private final String name; 25 | private final int accountType; 26 | private final boolean isFeatureXenabled; 27 | private final boolean isFeatureYenabled; 28 | private final boolean isFeatureZenabled; 29 | 30 | public UserAccount(int userId, String name, int accountType, boolean x, boolean y, boolean z) { 31 | this.userId = userId; 32 | this.name = name; 33 | this.accountType = accountType; 34 | this.isFeatureXenabled = x; 35 | this.isFeatureYenabled = y; 36 | this.isFeatureZenabled = z; 37 | } 38 | 39 | public int getUserId() { 40 | return userId; 41 | } 42 | 43 | public String getName() { 44 | return name; 45 | } 46 | 47 | public int getAccountType() { 48 | return accountType; 49 | } 50 | 51 | public boolean isFeatureXenabled() { 52 | return isFeatureXenabled; 53 | } 54 | 55 | public boolean isFeatureYenabled() { 56 | return isFeatureYenabled; 57 | } 58 | 59 | public boolean isFeatureZenabled() { 60 | return isFeatureZenabled; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /hystrix-serialization/build.gradle: -------------------------------------------------------------------------------- 1 | repositories { 2 | mavenCentral() 3 | } 4 | 5 | 6 | dependencies { 7 | api project(':hystrix-core') 8 | 9 | //if we bump into the the 2.8.0 series, we are forced to use Java7 10 | api 'com.fasterxml.jackson.core:jackson-core:2.7.5' 11 | api 'com.fasterxml.jackson.core:jackson-databind:2.7.5' 12 | api 'com.fasterxml.jackson.core:jackson-annotations:2.7.5' 13 | implementation 'com.fasterxml.jackson.module:jackson-module-afterburner:2.7.5' 14 | 15 | testImplementation 'junit:junit-dep:4.10' 16 | testImplementation 'org.mockito:mockito-all:1.9.5' 17 | testImplementation project(':hystrix-core').sourceSets.test.output 18 | testImplementation project(':hystrix-junit') 19 | } 20 | -------------------------------------------------------------------------------- /hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixMetric.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.hystrix.serial; 17 | 18 | import com.fasterxml.jackson.core.JsonFactory; 19 | import com.fasterxml.jackson.databind.ObjectMapper; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | import java.nio.ByteBuffer; 24 | 25 | public class SerialHystrixMetric { 26 | protected final static JsonFactory jsonFactory = new JsonFactory(); 27 | protected final static ObjectMapper mapper = new ObjectMapper(); 28 | protected final static Logger logger = LoggerFactory.getLogger(SerialHystrixMetric.class); 29 | 30 | @Deprecated 31 | public static String fromByteBufferToString(ByteBuffer bb) { 32 | throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name='hystrix' 2 | include 'hystrix-core', \ 3 | 'hystrix-examples', \ 4 | 'hystrix-examples-webapp', \ 5 | 'hystrix-contrib/hystrix-clj', \ 6 | 'hystrix-contrib/hystrix-request-servlet', \ 7 | 'hystrix-contrib/hystrix-servo-metrics-publisher', \ 8 | 'hystrix-contrib/hystrix-metrics-event-stream', \ 9 | 'hystrix-contrib/hystrix-metrics-event-stream-jaxrs', \ 10 | 'hystrix-contrib/hystrix-rx-netty-metrics-stream', \ 11 | 'hystrix-contrib/hystrix-codahale-metrics-publisher', \ 12 | 'hystrix-contrib/hystrix-yammer-metrics-publisher', \ 13 | 'hystrix-contrib/hystrix-network-auditor-agent', \ 14 | 'hystrix-contrib/hystrix-javanica', \ 15 | 'hystrix-contrib/hystrix-junit', \ 16 | 'hystrix-serialization' 17 | 18 | project(':hystrix-contrib/hystrix-clj').name = 'hystrix-clj' 19 | project(':hystrix-contrib/hystrix-request-servlet').name = 'hystrix-request-servlet' 20 | project(':hystrix-contrib/hystrix-servo-metrics-publisher').name = 'hystrix-servo-metrics-publisher' 21 | project(':hystrix-contrib/hystrix-metrics-event-stream').name = 'hystrix-metrics-event-stream' 22 | project(':hystrix-contrib/hystrix-metrics-event-stream-jaxrs').name = 'hystrix-metrics-event-stream-jaxrs' 23 | project(':hystrix-contrib/hystrix-rx-netty-metrics-stream').name = 'hystrix-rx-netty-metrics-stream' 24 | project(':hystrix-contrib/hystrix-codahale-metrics-publisher').name = 'hystrix-codahale-metrics-publisher' 25 | project(':hystrix-contrib/hystrix-yammer-metrics-publisher').name = 'hystrix-yammer-metrics-publisher' 26 | project(':hystrix-contrib/hystrix-network-auditor-agent').name = 'hystrix-network-auditor-agent' 27 | project(':hystrix-contrib/hystrix-javanica').name = 'hystrix-javanica' 28 | project(':hystrix-contrib/hystrix-junit').name = 'hystrix-junit' 29 | --------------------------------------------------------------------------------