Class HealthIndicatorDisplayValues

java.lang.Object
org.elasticsearch.health.node.HealthIndicatorDisplayValues

public class HealthIndicatorDisplayValues extends Object
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 Details

    • HealthIndicatorDisplayValues

      public HealthIndicatorDisplayValues()
  • Method Details

    • getNodeName

      public static String getNodeName(DiscoveryNode node)
      Formats the display name of a discovery node in the following way: - [id][name] or - [id] if name is null
    • getTruncatedIndices

      public 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. 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 displayed
      predicate - , the predicated by which all values will be filtered
      toString - , 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 displayed
      toString - , the desired way to convert the type 'T' to string for the purpose of this message.
    • indices

      public static String indices(int count)
      Provides the correct form (singular or plural) of the word index depending on the given count.
    • are

      public static String are(int count)
      Provides the correct form (singular or plural) of the verb to be depending on the given count.
    • these

      public static String these(int count)
      Provides the correct form (singular or plural) of the word this depending on the given count.
    • regularNoun

      public static String regularNoun(String noun, int count)
      Provides the correct form (singular or plural) of a regular noun depending on the given count.
    • regularVerb

      public static String regularVerb(String verb, int count)
      Provides the correct form (singular or plural) of a regular verb depending on the given count.
    • indicesComparatorByPriorityAndName

      public static Comparator<String> indicesComparatorByPriorityAndName(Metadata clusterMetadata)
      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