internal RequestCollapser(HystrixCollapser <BatchReturnType, RequestResponseType, RequestArgumentType> commandCollapser, IHystrixCollapserOptions properties, ICollapserTimer timer, HystrixConcurrencyStrategy concurrencyStrategy) { this.commandCollapser = commandCollapser; // the command with implementation of abstract methods we need this.concurrencyStrategy = concurrencyStrategy; this.properties = properties; this.timer = timer; batch.Value = new RequestBatch <BatchReturnType, RequestResponseType, RequestArgumentType>(properties, commandCollapser, properties.MaxRequestsInBatch); }
HystrixCollapserMetrics(IHystrixCollapserKey key, IHystrixCollapserOptions properties) : base(null) { this.collapserKey = key; this.properties = properties; rollingCollapserEventCounterStream = RollingCollapserEventCounterStream.GetInstance(key, properties); cumulativeCollapserEventCounterStream = CumulativeCollapserEventCounterStream.GetInstance(key, properties); rollingCollapserBatchSizeDistributionStream = RollingCollapserBatchSizeDistributionStream.GetInstance(key, properties); }
public RequestCollapserFactory(IHystrixCollapserKey collapserKey, RequestCollapserScope scope, ICollapserTimer timer, IHystrixCollapserOptions properties) { /* strategy: ConcurrencyStrategy */ concurrencyStrategy = HystrixPlugins.ConcurrencyStrategy; this.timer = timer; Scope = scope; CollapserKey = collapserKey; Properties = properties; }
public HystrixCollapserOptions(IHystrixCollapserKey key, RequestCollapserScope scope, IHystrixCollapserOptions defaults = null, IHystrixDynamicOptions dynamic = null) : base(dynamic) { this.CollapserKey = key; this.Scope = scope; this.defaults = defaults; this.MaxRequestsInBatch = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "maxRequestsInBatch", default_maxRequestsInBatch, defaults?.MaxRequestsInBatch); this.TimerDelayInMilliseconds = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "timerDelayInMilliseconds", default_timerDelayInMilliseconds, defaults?.TimerDelayInMilliseconds); this.RequestCacheEnabled = GetBoolean(HYSTRIX_COLLAPSER_PREFIX, key.Name, "requestCache.enabled", default_requestCacheEnabled, defaults?.RequestCacheEnabled); this.MetricsRollingStatisticalWindowInMilliseconds = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingStats.timeInMilliseconds", default_metricsRollingStatisticalWindow, defaults?.MetricsRollingStatisticalWindowInMilliseconds); this.MetricsRollingStatisticalWindowBuckets = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingStats.numBuckets", default_metricsRollingStatisticalWindowBuckets, defaults?.MetricsRollingStatisticalWindowBuckets); this.MetricsRollingPercentileEnabled = GetBoolean(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingPercentile.enabled", default_metricsRollingPercentileEnabled, defaults?.MetricsRollingPercentileEnabled); this.MetricsRollingPercentileWindowInMilliseconds = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingPercentile.timeInMilliseconds", default_metricsRollingPercentileWindow, defaults?.MetricsRollingPercentileWindowInMilliseconds); this.MetricsRollingPercentileWindowBuckets = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingPercentile.numBuckets", default_metricsRollingPercentileWindowBuckets, defaults?.MetricsRollingPercentileWindowBuckets); this.MetricsRollingPercentileBucketSize = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingPercentile.bucketSize", default_metricsRollingPercentileBucketSize, defaults?.MetricsRollingPercentileBucketSize); }
public HystrixCollapserOptions(IHystrixCollapserKey key, RequestCollapserScope scope, IHystrixCollapserOptions defaults = null, IHystrixDynamicOptions dynamic = null) : base(dynamic) { this.CollapserKey = key; this.Scope = scope; this.defaults = defaults; MaxRequestsInBatch = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "maxRequestsInBatch", DEFAULT_MAX_REQUESTS_IN_BATCH, defaults?.MaxRequestsInBatch); TimerDelayInMilliseconds = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "timerDelayInMilliseconds", DEFAULT_TIMER_DELAY_IN_MILLISECONDS, defaults?.TimerDelayInMilliseconds); RequestCacheEnabled = GetBoolean(HYSTRIX_COLLAPSER_PREFIX, key.Name, "requestCache.enabled", DEFAULT_REQUEST_CACHE_ENABLED, defaults?.RequestCacheEnabled); MetricsRollingStatisticalWindowInMilliseconds = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingStats.timeInMilliseconds", DEFAULT_METRICS_ROLLING_STATISTICAL_WINDOW, defaults?.MetricsRollingStatisticalWindowInMilliseconds); MetricsRollingStatisticalWindowBuckets = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingStats.numBuckets", DEFAULT_METRICS_ROLLING_STATISTICAL_WINDOW_BUCKETS, defaults?.MetricsRollingStatisticalWindowBuckets); MetricsRollingPercentileEnabled = GetBoolean(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingPercentile.enabled", DEFAULT_METRICS_ROLLING_PERCENTILE_ENABLED, defaults?.MetricsRollingPercentileEnabled); MetricsRollingPercentileWindowInMilliseconds = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingPercentile.timeInMilliseconds", DEFAULT_METRICS_ROLLING_PERCENTILE_WINDOW, defaults?.MetricsRollingPercentileWindowInMilliseconds); MetricsRollingPercentileWindowBuckets = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingPercentile.numBuckets", DEFAULT_METRICS_ROLLING_PERCENTILE_WINDOW_BUCKETS, defaults?.MetricsRollingPercentileWindowBuckets); MetricsRollingPercentileBucketSize = GetInteger(HYSTRIX_COLLAPSER_PREFIX, key.Name, "metrics.rollingPercentile.bucketSize", DEFAULT_METRICS_ROLLING_PERCENTILE_BUCKET_SIZE, defaults?.MetricsRollingPercentileBucketSize); }
protected HystrixCollapser(IHystrixCollapserKey collapserKey, RequestCollapserScope scope, ICollapserTimer timer, IHystrixCollapserOptions optionsDefault, HystrixCollapserMetrics metrics) { if (collapserKey == null || collapserKey.Name.Trim().Equals("")) { string defaultKeyName = GetDefaultNameFromClass(GetType()); collapserKey = HystrixCollapserKeyDefault.AsKey(defaultKeyName); } IHystrixCollapserOptions options = HystrixOptionsFactory.GetCollapserOptions(collapserKey, optionsDefault); this.collapserFactory = new RequestCollapserFactory(collapserKey, scope, timer, options); this.requestCache = HystrixRequestCache.GetInstance(collapserKey); if (metrics == null) { this.metrics = HystrixCollapserMetrics.GetInstance(collapserKey, options); } else { this.metrics = metrics; } HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForCollapser(collapserKey, this.metrics, options); }
protected HystrixCollapser(IHystrixCollapserOptions options) : this(options.CollapserKey, options.Scope, new RealCollapserTimer(), options, null) { }
public virtual IHystrixMetricsPublisherCollapser GetMetricsPublisherForCollapser(IHystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, IHystrixCollapserOptions properties) { return(new HystrixMetricsPublisherCollapserDefault(collapserKey, metrics, properties)); }
public override string GetCollapserOptionsCacheKey(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions builder) { return(null); }
public UserServiceCollapser(IHystrixCollapserOptions options, ILoggerFactory logFactory) : base(options) { _logger = logFactory.CreateLogger <UserServiceCollapser>(); _loggerFactory = logFactory; }
public static CumulativeCollapserEventCounterStream GetInstance(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions properties) { int counterMetricWindow = properties.MetricsRollingStatisticalWindowInMilliseconds; int numCounterBuckets = properties.MetricsRollingStatisticalWindowBuckets; int counterBucketSizeInMs = counterMetricWindow / numCounterBuckets; return(GetInstance(collapserKey, numCounterBuckets, counterBucketSizeInMs)); }
public static RollingCollapserBatchSizeDistributionStream GetInstance(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions properties) { var percentileMetricWindow = properties.MetricsRollingPercentileWindowInMilliseconds; var numPercentileBuckets = properties.MetricsRollingPercentileWindowBuckets; var percentileBucketSizeInMs = percentileMetricWindow / numPercentileBuckets; return(GetInstance(collapserKey, numPercentileBuckets, percentileBucketSizeInMs)); }
public HystrixMetricsPublisherCollapserDefault(IHystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, IHystrixCollapserOptions properties) { // do nothing by default }
public RequestCollapserRequestVariable(HystrixCollapser <BatchReturnType, ResponseType, RequestArgumentType> commandCollapser, IHystrixCollapserOptions properties, ICollapserTimer timer, HystrixConcurrencyStrategy concurrencyStrategy) : base(() => new RequestCollapser <BatchReturnType, ResponseType, RequestArgumentType>(commandCollapser, properties, timer, concurrencyStrategy), (collapser) => collapser.Shutdown()) { }
internal IHystrixMetricsPublisherCollapser GetPublisherForCollapser(IHystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, IHystrixCollapserOptions properties) { return(collapserPublishers.GetOrAddEx(collapserKey.Name, (k) => { IHystrixMetricsPublisherCollapser publisher = HystrixPlugins.MetricsPublisher.GetMetricsPublisherForCollapser(collapserKey, metrics, properties); publisher.Initialize(); return publisher; })); }
public static IHystrixMetricsPublisherCollapser CreateOrRetrievePublisherForCollapser(IHystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, IHystrixCollapserOptions properties) { return(SINGLETON.GetPublisherForCollapser(collapserKey, metrics, properties)); }
protected HystrixCollapser(IHystrixCollapserKey collapserKey, RequestCollapserScope scope, ICollapserTimer timer, IHystrixCollapserOptions options) : this(collapserKey, scope, timer, options, null) { }
public virtual string GetCollapserOptionsCacheKey(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions builder) { return(collapserKey.Name); }
protected HystrixCollapser(IHystrixCollapserKey collapserKey, RequestCollapserScope scope, ICollapserTimer timer, IHystrixCollapserOptions optionsDefault, HystrixCollapserMetrics metrics) { if (collapserKey == null || string.IsNullOrWhiteSpace(collapserKey.Name)) { var defaultKeyName = GetDefaultNameFromClass(GetType()); collapserKey = HystrixCollapserKeyDefault.AsKey(defaultKeyName); } var options = HystrixOptionsFactory.GetCollapserOptions(collapserKey, optionsDefault); _collapserFactory = new RequestCollapserFactory(collapserKey, scope, timer, options); _requestCache = HystrixRequestCache.GetInstance(collapserKey); if (metrics == null) { _metrics = HystrixCollapserMetrics.GetInstance(collapserKey, options); } else { _metrics = metrics; } HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForCollapser(collapserKey, _metrics, options); }
public static HystrixCollapserConfiguration Sample(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions collapserProperties) { CollapserMetricsConfig collapserMetricsConfig = new CollapserMetricsConfig( collapserProperties.MetricsRollingPercentileWindowBuckets, collapserProperties.MetricsRollingPercentileWindowInMilliseconds, collapserProperties.MetricsRollingPercentileEnabled, collapserProperties.MetricsRollingStatisticalWindowBuckets, collapserProperties.MetricsRollingStatisticalWindowInMilliseconds); return(new HystrixCollapserConfiguration( collapserKey, collapserProperties.MaxRequestsInBatch, collapserProperties.TimerDelayInMilliseconds, collapserProperties.RequestCacheEnabled, collapserMetricsConfig)); }
public virtual IHystrixCollapserOptions GetCollapserOptions(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions builder) { return(new HystrixCollapserOptions(collapserKey, builder)); }
public FortuneServiceCollapser(IHystrixCollapserOptions options, IFortuneService fortuneService, ILoggerFactory logFactory) : base(options) { _logger = logFactory.CreateLogger <FortuneServiceCollapser>(); _loggerFactory = logFactory; _fortuneService = fortuneService; }
public HystrixCollapserOptions(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions defaults = null, IHystrixDynamicOptions dynamic = null) : this(collapserKey, RequestCollapserScope.REQUEST, defaults, dynamic) { }
private static HystrixCollapserConfiguration SampleCollapserConfiguration(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions collapserProperties) { return(HystrixCollapserConfiguration.Sample(collapserKey, collapserProperties)); }
public static HystrixCollapserMetrics GetInstance(IHystrixCollapserKey key, IHystrixCollapserOptions properties) { return(Metrics.GetOrAddEx(key.Name, (k) => new HystrixCollapserMetrics(key, properties))); }
public RequestBatch(IHystrixCollapserOptions properties, HystrixCollapser <BatchReturnType, RequestResponseType, RequestArgumentType> commandCollapser, int maxBatchSize) { this.properties = properties; this.commandCollapser = commandCollapser; this.maxBatchSize = maxBatchSize; }
public override IHystrixCollapserOptions GetCollapserOptions(IHystrixCollapserKey collapserKey, IHystrixCollapserOptions builder) { throw new InvalidOperationException("not expecting collapser properties"); }
public UserServiceCollapser(IHystrixCollapserOptions options, ILogger <UserServiceCollapser> logger) : base(options) { _logger = logger; }
public static IHystrixCollapserOptions GetCollapserOptions(IHystrixCollapserKey key, IHystrixCollapserOptions builder) { var hystrixPropertiesStrategy = HystrixPlugins.OptionsStrategy; var cacheKey = hystrixPropertiesStrategy.GetCollapserOptionsCacheKey(key, builder); if (cacheKey != null) { return(CollapserProperties.GetOrAddEx(cacheKey, (k) => hystrixPropertiesStrategy.GetCollapserOptions(key, builder))); } else { // no cacheKey so we generate it with caching return(hystrixPropertiesStrategy.GetCollapserOptions(key, builder)); } }
public MultiPriceCommandCollapser(IHystrixCollapserOptions options, IPriceService service, ILogger <MultiPriceCommandCollapser> logger, ILoggerFactory logFactory) : base(options) { _service = service; _logger = logger; _logFactory = logFactory; }