Interface RelationshipConfiguration


public interface RelationshipConfiguration

RelationshipConfiguration can be used to convey how a Processor's configuration should be migrated from an old configuration to the latest configuration. This provides the ability to split a single Relationship into multiple, or to rename Relationships.

Note that it does not provide for the ability to merge multiple Relationships into a single Relationship, as doing so would cause unexpected data duplication. Consider, for example, that a Processor has two Connections. The first has Relationship A while the second has Relationship B. If we allows A and B to be merged together into C, anything that gets transferred to C would now need to go to both of those Connections, creating data duplication.

Additionally, there is no option to remove a Relationship. This is because if a Relationship is to be removed, it can be simply dropped from the Processor. Any existing connection that has that Relationship will be "ghosted" in the UI to show the user that it's no longer supported, but NiFi and the Processor will continue to behave as expected.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    hasRelationship(String relationshipName)
    Indicates whether or not the relationship with the given name exists in the configuration
    default boolean
    Indicates whether or not the relationship with the given name exists in the configuration
    boolean
    renameRelationship(String relationshipName, String newName)
    Changes the Relationship from the given older name to the updated name
    boolean
    splitRelationship(String relationshipName, String newRelationshipName, String... additionalRelationshipNames)
    Splits the given Relationship into multiple new relationships.
  • Method Details

    • renameRelationship

      boolean renameRelationship(String relationshipName, String newName)
      Changes the Relationship from the given older name to the updated name
      Parameters:
      relationshipName - the old name of the relationship
      newName - the new name to use
      Returns:
      true if the Relationship is renamed, false if the given Relationship does not exist
      Throws:
      IllegalStateException - if both the relationship name and the new name already are defined as relationships
    • splitRelationship

      boolean splitRelationship(String relationshipName, String newRelationshipName, String... additionalRelationshipNames)

      Splits the given Relationship into multiple new relationships. Each connection that has the Relationship as a selected Relationship will be updated to have all of the new Relationships as selected relationships instead. If the existing Relationship is auto-terminated, all of the newly defined ones will be as well. If the existing Relationship is auto-retried, so will be the new Relationships.

      It is possible to split an existing relationship into the same relationship and additional relationships. For example, it is valid to call this method as:

      
       relationshipConfiguration.splitRelationship("A", "A", "B", "C");
       

      In order to split the "A" relationship into three relationships: "A", "B", and "C". However, upon restart, NiFi will have already split the "A" relationship into three. So relationships "B" and "C" will already exist, resulting in an IllegalStateException. Therefore, if splitting a relationship into multiple that include the original relationship, it is important to guard against this by checking of the new relationships exist first:

      
       if (!relationshipConfiguration.hasRelationship("B")) {
           relationshipConfiguration.splitRelationship("A", "A", "B", "C");
       }
       

      This ensures that we do not attempt to split relationship "A" if it has already been done.

      Parameters:
      relationshipName - the name of the existing relationship
      newRelationshipName - the first of the new relationship names
      additionalRelationshipNames - additional names for the new relationship
      Returns:
      true if the Relationship is split, false if the given Relationship does not exist
      Throws:
      IllegalStateException - if the given relationship name exists and one of the given new relationships already exists
    • hasRelationship

      boolean hasRelationship(String relationshipName)
      Indicates whether or not the relationship with the given name exists in the configuration
      Parameters:
      relationshipName - the name of the relationship
      Returns:
      true if the relationship exists, false if the relationship is not known
    • hasRelationship

      default boolean hasRelationship(Relationship relationship)
      Indicates whether or not the relationship with the given name exists in the configuration
      Parameters:
      relationship - the relationship to check
      Returns:
      true if the relationship exists, false if the relationship is not known