Class EndpointAffinity

java.lang.Object
org.apache.drill.exec.physical.EndpointAffinity

public class EndpointAffinity extends Object
EndpointAffinity captures affinity value for a given single Drillbit endpoint.
  • Constructor Details

    • EndpointAffinity

      public EndpointAffinity(CoordinationProtos.DrillbitEndpoint endpoint)
      Create EndpointAffinity instance for given Drillbit endpoint. Affinity is initialized to 0. Affinity can be added after EndpointAffinity object creation using addAffinity(double).
      Parameters:
      endpoint - Drillbit endpoint.
    • EndpointAffinity

      public EndpointAffinity(CoordinationProtos.DrillbitEndpoint endpoint, double affinity)
      Create EndpointAffinity instance for given Drillbit endpoint and affinity initialized to given affinity value. Affinity can be added after EndpointAffinity object creation using addAffinity(double).
      Parameters:
      endpoint - Drillbit endpoint.
      affinity - Initial affinity value.
    • EndpointAffinity

      public EndpointAffinity(CoordinationProtos.DrillbitEndpoint endpoint, double affinity, boolean mandatory, int maxWidth)
      Creates EndpointAffinity instance for given DrillbitEndpoint, affinity and mandatory assignment requirement flag.
      Parameters:
      endpoint - Drillbit endpoint
      affinity - Initial affinity value
      mandatory - Is this endpoint requires at least one mandatory assignment?
      maxWidth - Maximum allowed assignments for this endpoint.
  • Method Details

    • getEndpoint

      Return the Drillbit endpoint in this instance.
      Returns:
      Drillbit endpoint.
    • getAffinity

      public double getAffinity()
      Get the affinity value. Affinity value is Double.POSITIVE_INFINITY if the Drillbit endpoint requires an assignment.
      Returns:
      affinity value
    • addAffinity

      public void addAffinity(double f)
      Add given affinity value to existing affinity value.
      Parameters:
      f - Affinity value (must be a non-negative value).
      Throws:
      IllegalArgumentException - If the given affinity value is negative.
    • setAssignmentRequired

      public void setAssignmentRequired()
      Set the endpoint requires at least one assignment.
    • isAssignmentRequired

      public boolean isAssignmentRequired()
      Is this endpoint required to be in fragment endpoint assignment list?
      Returns:
      Returns true for mandatory assignment, false otherwise.
    • getMaxWidth

      public int getMaxWidth()
      Returns:
      Maximum allowed assignments for this endpoint.
    • setMaxWidth

      public void setMaxWidth(int maxWidth)
      Set the new max width as the minimum of the the given value and current max width.
      Parameters:
      maxWidth -
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object