-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add separate flood stage limit for frozen #71855
Merged
henningandersen
merged 10 commits into
elastic:master
from
henningandersen:enhance_frozen_flood_stage
Apr 20, 2021
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1f35be1
Frozen default cache size
henningandersen ced0293
Add separate flood stage limit for frozen
henningandersen 92452eb
Merge remote-tracking branch 'origin/master' into enhance_frozen_floo…
henningandersen 84f5a37
checkstyle after merge
henningandersen c6bbdda
Remove overlap to #71896
henningandersen da33a82
Slightly more friendly on large full disks.
henningandersen 634ed3d
Merge remote-tracking branch 'origin/master' into enhance_frozen_floo…
henningandersen 4d168b4
Remove most overlap to #71844
henningandersen 22e49ed
Dedicated frozen nodes
henningandersen 97486af
Merge branch 'master' into enhance_frozen_flood_stage
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
server/src/main/java/org/elasticsearch/common/unit/RelativeByteSizeValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.common.unit; | ||
|
||
import org.elasticsearch.ElasticsearchParseException; | ||
|
||
/** | ||
* A byte size value that allows specification using either of: | ||
* 1. Absolute value (200GB for instance) | ||
* 2. Relative percentage value (95%) | ||
* 3. Relative ratio value (0.95) | ||
*/ | ||
public class RelativeByteSizeValue { | ||
|
||
public static final String MAX_HEADROOM_PREFIX = "max_headroom="; | ||
private final ByteSizeValue absolute; | ||
private final RatioValue ratio; | ||
|
||
public RelativeByteSizeValue(ByteSizeValue absolute) { | ||
this.absolute = absolute; | ||
this.ratio = null; | ||
} | ||
|
||
public RelativeByteSizeValue(RatioValue ratio) { | ||
this.absolute = null; | ||
this.ratio = ratio; | ||
} | ||
|
||
public boolean isAbsolute() { | ||
return absolute != null; | ||
} | ||
|
||
public ByteSizeValue getAbsolute() { | ||
return absolute; | ||
} | ||
|
||
public RatioValue getRatio() { | ||
return ratio; | ||
} | ||
|
||
/** | ||
* Calculate the size to use, optionally catering for a max headroom. | ||
* @param total the total size to use | ||
* @param maxHeadroom the max headroom to cater for or null (or -1) to ignore. | ||
* @return the size to use | ||
*/ | ||
public ByteSizeValue calculateValue(ByteSizeValue total, ByteSizeValue maxHeadroom) { | ||
if (ratio != null) { | ||
long ratioBytes = (long) Math.ceil(ratio.getAsRatio() * total.getBytes()); | ||
if (maxHeadroom != null && maxHeadroom.getBytes() != -1) { | ||
return ByteSizeValue.ofBytes(Math.max(ratioBytes, total.getBytes() - maxHeadroom.getBytes())); | ||
} else { | ||
return ByteSizeValue.ofBytes(ratioBytes); | ||
} | ||
} else { | ||
return absolute; | ||
} | ||
} | ||
|
||
public boolean isNonZeroSize() { | ||
if (ratio != null) { | ||
return ratio.getAsRatio() > 0.0d; | ||
} else { | ||
return absolute.getBytes() > 0; | ||
} | ||
} | ||
|
||
public static RelativeByteSizeValue parseRelativeByteSizeValue(String value, String settingName) { | ||
try { | ||
RatioValue ratio = RatioValue.parseRatioValue(value); | ||
if (ratio.getAsPercent() != 0.0d || value.endsWith("%")) { | ||
return new RelativeByteSizeValue(ratio); | ||
} else { | ||
return new RelativeByteSizeValue(ByteSizeValue.ZERO); | ||
} | ||
} catch (ElasticsearchParseException e) { | ||
// ignore, see if it parses as bytes | ||
} | ||
try { | ||
return new RelativeByteSizeValue(ByteSizeValue.parseBytesSizeValue(value, settingName)); | ||
// todo: fix NumberFormatException case in ByteSizeValue. | ||
} catch (NumberFormatException | ElasticsearchParseException e) { | ||
throw new ElasticsearchParseException("unable to parse [{}={}] as either percentage or bytes", e, | ||
settingName, value); | ||
} | ||
} | ||
|
||
public String getStringRep() { | ||
if (ratio != null) { | ||
return ratio.toString(); | ||
} else { | ||
return absolute.getStringRep(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire class and associated test is also in #71844, only difference is that this method was made public here.