@EventDriven @Tags(value={"sort","order"}) @InputRequirement(value=INPUT_REQUIRED) @TriggerSerially @CapabilityDescription(value="Enforces expected ordering of FlowFiles that belong to the same data group within a single node. Although PriorityAttributePrioritizer can be used on a connection to ensure that flow files going through that connection are in priority order, depending on error-handling, branching, and other flow designs, it is possible for FlowFiles to get out-of-order. EnforceOrder can be used to enforce original ordering for those FlowFiles. [IMPORTANT] In order to take effect of EnforceOrder, FirstInFirstOutPrioritizer should be used at EVERY downstream relationship UNTIL the order of FlowFiles physically get FIXED by operation such as MergeContent or being stored to the final destination.") @Stateful(scopes=LOCAL, description="EnforceOrder uses following states per ordering group: \'<groupId>.target\' is a order number which is being waited to arrive next. When a FlowFile with a matching order arrives, or a FlowFile overtakes the FlowFile being waited for because of wait timeout, target order will be updated to (FlowFile.order + 1). \'<groupId>.max is the maximum order number for a group. \'<groupId>.updatedAt\' is a timestamp when the order of a group was updated last time. These managed states will be removed automatically once a group is determined as inactive, see \'Inactive Timeout\' for detail.") @WritesAttribute(attribute="EnforceOrder.startedAt",description="All FlowFiles going through this processor will have this attribute. This value is used to determine wait timeout.") @WritesAttribute(attribute="EnforceOrder.result",description="All FlowFiles going through this processor will have this attribute denoting which relationship it was routed to.") @WritesAttribute(attribute="EnforceOrder.detail",description="FlowFiles routed to \'failure\' or \'skipped\' relationship will have this attribute describing details.") @WritesAttribute(attribute="EnforceOrder.expectedOrder",description="FlowFiles routed to \'wait\' or \'skipped\' relationship will have this attribute denoting expected order when the FlowFile was processed.") public class EnforceOrder extends AbstractProcessor
Modifier and Type | Class and Description |
---|---|
private class |
EnforceOrder.OrderingContext |
Modifier and Type | Field and Description |
---|---|
static String |
ATTR_DETAIL |
static String |
ATTR_EXPECTED_ORDER |
static String |
ATTR_RESULT |
static String |
ATTR_STARTED_AT |
static PropertyDescriptor |
BATCH_COUNT |
static PropertyDescriptor |
GROUP_IDENTIFIER |
static PropertyDescriptor |
INACTIVE_TIMEOUT |
static PropertyDescriptor |
INITIAL_ORDER |
static PropertyDescriptor |
MAX_ORDER |
static PropertyDescriptor |
ORDER_ATTRIBUTE |
static Relationship |
REL_FAILURE |
static Relationship |
REL_OVERTOOK |
static Relationship |
REL_SKIPPED |
static Relationship |
REL_SUCCESS |
static Relationship |
REL_WAIT |
private Set<Relationship> |
relationships |
private static Function<String,String> |
STATE_MAX_ORDER |
private static String |
STATE_SUFFIX_UPDATED_AT |
private static Function<String,String> |
STATE_TARGET_ORDER |
private static Function<String,String> |
STATE_UPDATED_AT |
static PropertyDescriptor |
WAIT_TIMEOUT |
Constructor and Description |
---|
EnforceOrder() |
Modifier and Type | Method and Description |
---|---|
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
Set<Relationship> |
getRelationships() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
onTrigger
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
public static final String ATTR_STARTED_AT
public static final String ATTR_EXPECTED_ORDER
public static final String ATTR_RESULT
public static final String ATTR_DETAIL
private static final String STATE_SUFFIX_UPDATED_AT
public static final PropertyDescriptor GROUP_IDENTIFIER
public static final PropertyDescriptor ORDER_ATTRIBUTE
public static final PropertyDescriptor INITIAL_ORDER
public static final PropertyDescriptor MAX_ORDER
public static final PropertyDescriptor WAIT_TIMEOUT
public static final PropertyDescriptor INACTIVE_TIMEOUT
public static final PropertyDescriptor BATCH_COUNT
public static final Relationship REL_SUCCESS
public static final Relationship REL_FAILURE
public static final Relationship REL_WAIT
public static final Relationship REL_OVERTOOK
public static final Relationship REL_SKIPPED
private final Set<Relationship> relationships
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors
in class AbstractConfigurableComponent
public Set<Relationship> getRelationships()
getRelationships
in interface Processor
getRelationships
in class AbstractSessionFactoryProcessor
protected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate
in class AbstractConfigurableComponent
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger
in class AbstractProcessor
ProcessException
Copyright © 2020 Apache NiFi Project. All rights reserved.