Module org.elasticsearch.server
Package org.elasticsearch.health.node
Class HealthIndicatorDisplayValues
java.lang.Object
org.elasticsearch.health.node.HealthIndicatorDisplayValues
This class provides helper methods to construct display messages for the health indicators. There are a lot of
messages generated by the health indicators namely, symptoms, impacts and diagnoses. The aim of this is to
make the code less error-prone and more readable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
are
(int count) Provides the correct form (singular or plural) of the verb to be depending on the given count.static String
getNodeName
(DiscoveryNode node) Formats the display name of a discovery node in the following way: - [id][name] or - [id] if name is nullstatic <T> String
getSortedUniqueValuesString
(Collection<T> values, Function<T, String> toString) Creates a string that displays all the values sorted in the natural order.static <T> String
getSortedUniqueValuesString
(Collection<T> values, Predicate<T> predicate, Function<T, String> toString) Creates a string that displays all the values that fulfilled the predicate sorted in the natural order.static String
getTruncatedIndices
(Set<String> indices, Metadata clusterMetadata) Creates a string that displays max 10 indices from the given set to be used as examples in logging or user messages.static String
indices
(int count) Provides the correct form (singular or plural) of the word index depending on the given count.static Comparator<String>
indicesComparatorByPriorityAndName
(Metadata clusterMetadata) Sorts index names by their priority first, then alphabetically by name.static String
regularNoun
(String noun, int count) Provides the correct form (singular or plural) of a regular noun depending on the given count.static String
regularVerb
(String verb, int count) Provides the correct form (singular or plural) of a regular verb depending on the given count.static String
these
(int count) Provides the correct form (singular or plural) of the word this depending on the given count.
-
Constructor Details
-
HealthIndicatorDisplayValues
public HealthIndicatorDisplayValues()
-
-
Method Details
-
getNodeName
Formats the display name of a discovery node in the following way: - [id][name] or - [id] if name is null -
getTruncatedIndices
Creates a string that displays max 10 indices from the given set to be used as examples in logging or user messages. The indices are sorted by priority and then by name to ensure a deterministic message. If there are more indices than 10, it adds the '...' suffix. -
getSortedUniqueValuesString
public static <T> String getSortedUniqueValuesString(Collection<T> values, Predicate<T> predicate, Function<T, String> toString) Creates a string that displays all the values that fulfilled the predicate sorted in the natural order.- Parameters:
values
- , the values to be displayedpredicate
- , the predicated by which all values will be filteredtoString
- , the desired way to convert the type 'T' to string for the purpose of this message.
-
getSortedUniqueValuesString
public static <T> String getSortedUniqueValuesString(Collection<T> values, Function<T, String> toString) Creates a string that displays all the values sorted in the natural order.- Parameters:
values
- , the values to be displayedtoString
- , the desired way to convert the type 'T' to string for the purpose of this message.
-
indices
Provides the correct form (singular or plural) of the word index depending on the given count. -
are
Provides the correct form (singular or plural) of the verb to be depending on the given count. -
these
Provides the correct form (singular or plural) of the word this depending on the given count. -
regularNoun
Provides the correct form (singular or plural) of a regular noun depending on the given count. -
regularVerb
Provides the correct form (singular or plural) of a regular verb depending on the given count. -
indicesComparatorByPriorityAndName
Sorts index names by their priority first, then alphabetically by name. If the priority cannot be determined for an index then a priority of -1 is used to sort it behind other index names.- Parameters:
clusterMetadata
- Used to look up index priority.- Returns:
- Comparator instance
-