|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the "Elastic License |
| 4 | + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side |
| 5 | + * Public License v 1"; you may not use this file except in compliance with, at |
| 6 | + * your election, the "Elastic License 2.0", the "GNU Affero General Public |
| 7 | + * License v3.0 only", or the "Server Side Public License, v 1". |
| 8 | + */ |
| 9 | + |
| 10 | +package org.elasticsearch.cluster.routing.allocation; |
| 11 | + |
| 12 | +import org.elasticsearch.action.ActionListener; |
| 13 | +import org.elasticsearch.cluster.routing.RerouteService; |
| 14 | +import org.elasticsearch.common.Priority; |
| 15 | +import org.elasticsearch.common.settings.Setting; |
| 16 | +import org.elasticsearch.common.unit.RatioValue; |
| 17 | +import org.elasticsearch.core.TimeValue; |
| 18 | + |
| 19 | +/** |
| 20 | + * Settings definitions for the write load allocation decider and associated infrastructure |
| 21 | + */ |
| 22 | +public class WriteLoadConstraintSettings { |
| 23 | + |
| 24 | + private static final String SETTING_PREFIX = "cluster.routing.allocation.write_load_decider."; |
| 25 | + |
| 26 | + public enum WriteLoadDeciderStatus { |
| 27 | + /** |
| 28 | + * The decider is disabled |
| 29 | + */ |
| 30 | + DISABLED, |
| 31 | + /** |
| 32 | + * Only the low-threshold is enabled (write-load will not trigger rebalance) |
| 33 | + */ |
| 34 | + LOW_ONLY, |
| 35 | + /** |
| 36 | + * The decider is enabled |
| 37 | + */ |
| 38 | + ENABLED |
| 39 | + } |
| 40 | + |
| 41 | + public static final Setting<WriteLoadDeciderStatus> WRITE_LOAD_DECIDER_ENABLED_SETTING = Setting.enumSetting( |
| 42 | + WriteLoadDeciderStatus.class, |
| 43 | + SETTING_PREFIX + "enabled", |
| 44 | + WriteLoadDeciderStatus.DISABLED, |
| 45 | + Setting.Property.Dynamic, |
| 46 | + Setting.Property.NodeScope |
| 47 | + ); |
| 48 | + |
| 49 | + /** |
| 50 | + * The threshold over which we consider write thread pool utilization "high" |
| 51 | + */ |
| 52 | + public static final Setting<RatioValue> WRITE_LOAD_DECIDER_HIGH_UTILIZATION_THRESHOLD_SETTING = new Setting<>( |
| 53 | + SETTING_PREFIX + "high_utilization_threshold", |
| 54 | + "90%", |
| 55 | + RatioValue::parseRatioValue, |
| 56 | + Setting.Property.Dynamic, |
| 57 | + Setting.Property.NodeScope |
| 58 | + ); |
| 59 | + |
| 60 | + /** |
| 61 | + * The duration for which we need to see "high" utilization before we consider the low threshold exceeded |
| 62 | + */ |
| 63 | + public static final Setting<TimeValue> WRITE_LOAD_DECIDER_HIGH_UTILIZATION_DURATION_SETTING = Setting.timeSetting( |
| 64 | + SETTING_PREFIX + "high_utilization_duration", |
| 65 | + TimeValue.timeValueMinutes(10), |
| 66 | + Setting.Property.Dynamic, |
| 67 | + Setting.Property.NodeScope |
| 68 | + ); |
| 69 | + |
| 70 | + /** |
| 71 | + * When the decider is {@link WriteLoadDeciderStatus#ENABLED}, the write-load monitor will call |
| 72 | + * {@link RerouteService#reroute(String, Priority, ActionListener)} when we see tasks being delayed by this amount of time |
| 73 | + * (but no more often than {@link #WRITE_LOAD_DECIDER_REROUTE_INTERVAL_SETTING}) |
| 74 | + */ |
| 75 | + public static final Setting<TimeValue> WRITE_LOAD_DECIDER_QUEUE_LATENCY_THRESHOLD_SETTING = Setting.timeSetting( |
| 76 | + SETTING_PREFIX + "queue_latency_threshold", |
| 77 | + TimeValue.timeValueSeconds(30), |
| 78 | + Setting.Property.Dynamic, |
| 79 | + Setting.Property.NodeScope |
| 80 | + ); |
| 81 | + |
| 82 | + /** |
| 83 | + * How often the data node calculates the write-loads for the individual shards |
| 84 | + */ |
| 85 | + public static final Setting<TimeValue> WRITE_LOAD_DECIDER_SHARD_WRITE_LOAD_POLLING_INTERVAL_SETTING = Setting.timeSetting( |
| 86 | + SETTING_PREFIX + "shard_write_load_polling_interval", |
| 87 | + TimeValue.timeValueSeconds(60), |
| 88 | + Setting.Property.Dynamic, |
| 89 | + Setting.Property.NodeScope |
| 90 | + ); |
| 91 | + |
| 92 | + /** |
| 93 | + * The minimum amount of time between successive calls to reroute to address write load hot-spots |
| 94 | + */ |
| 95 | + public static final Setting<TimeValue> WRITE_LOAD_DECIDER_REROUTE_INTERVAL_SETTING = Setting.timeSetting( |
| 96 | + SETTING_PREFIX + "reroute_interval", |
| 97 | + TimeValue.timeValueSeconds(60), |
| 98 | + Setting.Property.Dynamic, |
| 99 | + Setting.Property.NodeScope |
| 100 | + ); |
| 101 | +} |
0 commit comments