@EventDriven @SideEffectFree @SupportsBatching(defaultDuration=TWENTY_FIVE_MILLIS) @InputRequirement(value=INPUT_REQUIRED) @TriggerWhenAnyDestinationAvailable @Tags(value={"distribute","load balance","route","round robin","weighted"}) @CapabilityDescription(value="Distributes FlowFiles to downstream processors based on a Distribution Strategy. If using the Round Robin strategy, the default is to assign each destination a weighting of 1 (evenly distributed). However, optional properties can be added to the change this; adding a property with the name \'5\' and value \'10\' means that the relationship with name \'5\' will be receive 10 FlowFiles in each iteration instead of 1.") @DynamicProperty(name="The relationship name (positive number)", value="The relationship Weight (positive number)", description="Adding a property with the name \'5\' and value \'10\' means that the relationship with name \'5\' will receive 10 FlowFiles in each iteration instead of 1.") @DynamicRelationship(name="A number 1..<Number Of Relationships>", description="FlowFiles are sent to this relationship per the <Distribution Strategy>") @WritesAttributes(value=@WritesAttribute(attribute="distribute.load.relationship",description="The name of the specific relationship the FlowFile has been routed through")) public class DistributeLoad extends AbstractProcessor
| Modifier and Type | Class and Description |
|---|---|
private static interface |
DistributeLoad.DistributionStrategy
Implementations must be thread-safe.
|
private static class |
DistributeLoad.InvalidPropertyNameValidator |
private class |
DistributeLoad.LoadDistributionStrategy |
private class |
DistributeLoad.NextAvailableStrategy |
private class |
DistributeLoad.OverflowStrategy |
private class |
DistributeLoad.RoundRobinStrategy |
| Modifier and Type | Field and Description |
|---|---|
static PropertyDescriptor |
DISTRIBUTION_STRATEGY |
private AtomicBoolean |
doCustomValidate |
private AtomicBoolean |
doSetProps |
static PropertyDescriptor |
HOSTNAMES |
static String |
LOAD_DISTRIBUTION_SERVICE |
static PropertyDescriptor |
LOAD_DISTRIBUTION_SERVICE_TEMPLATE |
private LoadDistributionListener |
myListener |
static String |
NEXT_AVAILABLE |
static PropertyDescriptor |
NUM_RELATIONSHIPS |
static String |
OVERFLOW |
private List<PropertyDescriptor> |
properties |
static String |
RELATIONSHIP_ATTRIBUTE |
private AtomicReference<Set<Relationship>> |
relationshipsRef |
static String |
ROUND_ROBIN |
static AllowableValue |
STRATEGY_LOAD_DISTRIBUTION_SERVICE |
static AllowableValue |
STRATEGY_NEXT_AVAILABLE |
static AllowableValue |
STRATEGY_OVERFLOW |
static AllowableValue |
STRATEGY_ROUND_ROBIN |
private AtomicReference<DistributeLoad.DistributionStrategy> |
strategyRef |
private AtomicReference<List<Relationship>> |
weightedRelationshipListRef |
| Constructor and Description |
|---|
DistributeLoad() |
| Modifier and Type | Method and Description |
|---|---|
private static Relationship |
createRelationship(int num) |
void |
createWeightedList(ProcessContext context) |
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
void |
onPropertyModified(PropertyDescriptor descriptor,
String oldValue,
String newValue) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private void |
updateWeightedRelationships(Map<Integer,Integer> weightings) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, validatepublic static final String ROUND_ROBIN
public static final String NEXT_AVAILABLE
public static final String LOAD_DISTRIBUTION_SERVICE
public static final String OVERFLOW
public static final AllowableValue STRATEGY_ROUND_ROBIN
public static final AllowableValue STRATEGY_NEXT_AVAILABLE
public static final AllowableValue STRATEGY_LOAD_DISTRIBUTION_SERVICE
public static final AllowableValue STRATEGY_OVERFLOW
public static final PropertyDescriptor NUM_RELATIONSHIPS
public static final PropertyDescriptor DISTRIBUTION_STRATEGY
public static final PropertyDescriptor HOSTNAMES
public static final PropertyDescriptor LOAD_DISTRIBUTION_SERVICE_TEMPLATE
public static final String RELATIONSHIP_ATTRIBUTE
private List<PropertyDescriptor> properties
private final AtomicReference<Set<Relationship>> relationshipsRef
private final AtomicReference<DistributeLoad.DistributionStrategy> strategyRef
private final AtomicReference<List<Relationship>> weightedRelationshipListRef
private final AtomicBoolean doCustomValidate
private volatile LoadDistributionListener myListener
private final AtomicBoolean doSetProps
protected void init(ProcessorInitializationContext context)
init in class AbstractSessionFactoryProcessorprivate static Relationship createRelationship(int num)
public Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorpublic void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified in interface ConfigurableComponentonPropertyModified in class AbstractConfigurableComponentprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor in class AbstractConfigurableComponentprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponent@OnScheduled public void createWeightedList(ProcessContext context)
private void updateWeightedRelationships(Map<Integer,Integer> weightings)
public void onTrigger(ProcessContext context, ProcessSession session)
onTrigger in class AbstractProcessorCopyright © 2023 Apache NiFi Project. All rights reserved.