@SideEffectFree @TriggerSerially @TriggerWhenEmpty @InputRequirement(value=INPUT_REQUIRED) @Tags(value={"monitor","flow","active","inactive","activity","detection"}) @CapabilityDescription(value="Monitors the flow for activity and sends out an indicator when the flow has not had any data for some specified amount of time and again when the flow\'s activity is restored") @WritesAttribute(attribute="inactivityStartMillis",description="The time at which Inactivity began, in the form of milliseconds since Epoch") @WritesAttribute(attribute="inactivityDurationMillis",description="The number of milliseconds that the inactivity has spanned") @Stateful(scopes=CLUSTER, description="MonitorActivity stores the last timestamp at each node as state, so that it can examine activity at cluster wide.If \'Copy Attribute\' is set to true, then flow file attributes are also persisted.") public class MonitorActivity extends AbstractProcessor
Modifier and Type | Field and Description |
---|---|
static PropertyDescriptor |
ACTIVITY_RESTORED_MESSAGE |
static PropertyDescriptor |
CONTINUALLY_SEND_MESSAGES |
static PropertyDescriptor |
COPY_ATTRIBUTES |
private AtomicBoolean |
inactive |
static PropertyDescriptor |
INACTIVITY_MESSAGE |
private AtomicLong |
lastInactiveMessage |
private AtomicLong |
latestReportedNodeState |
private AtomicLong |
latestSuccessTransfer |
static PropertyDescriptor |
MONITORING_SCOPE |
private List<PropertyDescriptor> |
properties |
static Relationship |
REL_ACTIVITY_RESTORED |
static Relationship |
REL_INACTIVE |
static Relationship |
REL_SUCCESS |
private Set<Relationship> |
relationships |
static AllowableValue |
REPORT_NODE_ALL |
static AllowableValue |
REPORT_NODE_PRIMARY |
static PropertyDescriptor |
REPORTING_NODE |
static AllowableValue |
SCOPE_CLUSTER |
static AllowableValue |
SCOPE_NODE |
static String |
STATE_KEY_LATEST_SUCCESS_TRANSFER |
static PropertyDescriptor |
THRESHOLD |
static Charset |
UTF8 |
Constructor and Description |
---|
MonitorActivity() |
Modifier and Type | Method and Description |
---|---|
Set<Relationship> |
getRelationships() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
private boolean |
isClusterScope(ProcessContext context,
boolean logInvalidConfig) |
void |
onScheduled(ProcessContext context) |
void |
onStopped(ProcessContext context) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
protected void |
resetLastSuccessfulTransfer() |
protected void |
setLastSuccessfulTransfer(long timestamp) |
private boolean |
shouldReportOnlyOnPrimary(boolean isClusterScope,
ProcessContext context) |
private boolean |
shouldThisNodeReport(boolean isClusterScope,
boolean isReportOnlyOnPrimary) |
onTrigger
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue
customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
public static final AllowableValue SCOPE_NODE
public static final AllowableValue SCOPE_CLUSTER
public static final AllowableValue REPORT_NODE_ALL
public static final AllowableValue REPORT_NODE_PRIMARY
public static final PropertyDescriptor THRESHOLD
public static final PropertyDescriptor CONTINUALLY_SEND_MESSAGES
public static final PropertyDescriptor ACTIVITY_RESTORED_MESSAGE
public static final PropertyDescriptor INACTIVITY_MESSAGE
public static final PropertyDescriptor COPY_ATTRIBUTES
public static final PropertyDescriptor MONITORING_SCOPE
public static final PropertyDescriptor REPORTING_NODE
public static final Relationship REL_SUCCESS
public static final Relationship REL_INACTIVE
public static final Relationship REL_ACTIVITY_RESTORED
public static final Charset UTF8
private List<PropertyDescriptor> properties
private Set<Relationship> relationships
private final AtomicLong latestSuccessTransfer
private final AtomicLong latestReportedNodeState
private final AtomicBoolean inactive
private final AtomicLong lastInactiveMessage
public static final String STATE_KEY_LATEST_SUCCESS_TRANSFER
protected void init(ProcessorInitializationContext context)
init
in class AbstractSessionFactoryProcessor
public Set<Relationship> getRelationships()
getRelationships
in interface Processor
getRelationships
in class AbstractSessionFactoryProcessor
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors
in class AbstractConfigurableComponent
@OnScheduled public void onScheduled(ProcessContext context)
protected void resetLastSuccessfulTransfer()
protected final void setLastSuccessfulTransfer(long timestamp)
private boolean isClusterScope(ProcessContext context, boolean logInvalidConfig)
private boolean shouldReportOnlyOnPrimary(boolean isClusterScope, ProcessContext context)
public void onTrigger(ProcessContext context, ProcessSession session)
onTrigger
in class AbstractProcessor
@OnStopped public void onStopped(ProcessContext context)
private boolean shouldThisNodeReport(boolean isClusterScope, boolean isReportOnlyOnPrimary)
Copyright © 2020 Apache NiFi Project. All rights reserved.