Class HopSpec

java.lang.Object
com.yahoo.messagebus.routing.HopSpec

public class HopSpec extends Object
Along with the RoutingSpec, RoutingTableSpec and RouteSpec, this holds the routing specifications for all protocols. The only way a client can configure or alter the settings of a message bus instance is through these classes.

This class contains the spec for a single hop.

Author:
Simon Thoresen Hult
  • Constructor Details

    • HopSpec

      public HopSpec(String name, String selector)
      Creates a new named hop specification.
      Parameters:
      name - A protocol-unique name for this hop.
      selector - A string that represents the selector for this hop.
    • HopSpec

      public HopSpec(String name, String selector, boolean verify)
      Creates a new named hop specification.
      Parameters:
      name - A protocol-unique name for this hop.
      selector - A string that represents the selector for this hop.
      verify - Whether or not this should be verified.
    • HopSpec

      public HopSpec(HopSpec obj)
      Implements the copy constructor.
      Parameters:
      obj - The object to copy.
  • Method Details

    • getName

      public String getName()
      Returns the protocol-unique name of this hop.
      Returns:
      The name.
    • getSelector

      public String getSelector()
      Returns the string selector that resolves the recipients of this hop.
      Returns:
      The selector.
    • hasRecipients

      public boolean hasRecipients()
      Returns whether there are any recipients that the selector can choose from.
      Returns:
      True if there is at least one recipient.
    • getNumRecipients

      public int getNumRecipients()
      Returns the number of recipients that the selector can choose from.
      Returns:
      The number of recipients.
    • getRecipient

      public String getRecipient(int i)
      Returns the recipients at the given index.
      Parameters:
      i - The index of the recipient to return.
      Returns:
      The recipient at the given index.
    • addRecipient

      public HopSpec addRecipient(String recipient)
      Adds the given recipient to this.
      Parameters:
      recipient - The recipient to add.
      Returns:
      This, to allow chaining.
    • addRecipients

      public HopSpec addRecipients(List<String> recipients)
      Adds the given recipients to this.
      Parameters:
      recipients - The recipients to add.
      Returns:
      This, to allow chaining.
    • setRecipient

      public HopSpec setRecipient(int i, String recipient)
      Sets the recipient at the given index.
      Parameters:
      i - The index at which to set the recipient.
      recipient - The recipient to set.
      Returns:
      This, to allow chaining.
    • removeRecipient

      public String removeRecipient(int i)
      Removes the recipient at the given index.
      Parameters:
      i - The index of the recipient to remove.
      Returns:
      The removed recipient.
    • clearRecipients

      public HopSpec clearRecipients()
      Clears the list of recipients that the selector may choose from.
      Returns:
      This, to allow chaining.
    • getIgnoreResult

      public boolean getIgnoreResult()
      Returns whether to ignore the result when routing through this hop.
      Returns:
      True to ignore the result.
    • setIgnoreResult

      public HopSpec setIgnoreResult(boolean ignoreResult)
      Sets whether to ignore the result when routing through this hop.
      Parameters:
      ignoreResult - Whether to ignore the result.
      Returns:
      This, to allow chaining.
    • verify

      public boolean verify(ApplicationSpec app, RoutingTableSpec table, List<String> errors)
      Verifies the content of this against the given application.
      Parameters:
      app - The application to verify against.
      table - The routing table to verify against.
      errors - The list of errors found.
      Returns:
      True if no errors where found.
    • toConfig

      public void toConfig(StringBuilder cfg, String prefix)
      Appends the content of this to the given config string builder.
      Parameters:
      cfg - The config to add to.
      prefix - The prefix to use for each add.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object