@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 |
private AtomicBoolean |
connectedWhenLastTriggered |
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 |
|---|---|
protected long |
getLatestSuccessTransfer() |
Set<Relationship> |
getRelationships() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
private boolean |
isClusterScope(ProcessContext context,
boolean logInvalidConfig) |
private boolean |
isReconnectedToCluster(boolean isConnectedToCluster)
Will return true when the last known state is "not connected" and the current state is "connected".
|
void |
onScheduled(ProcessContext context) |
void |
onStopped(ProcessContext context) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private void |
reconcileState(ProcessContext context) |
protected void |
resetLastSuccessfulTransfer() |
protected void |
setLastSuccessfulTransfer(long timestamp) |
private boolean |
shouldReportOnlyOnPrimary(boolean isClusterScope,
ProcessContext context) |
private boolean |
shouldThisNodeReport(boolean isClusterScope,
boolean isReportOnlyOnPrimary,
ProcessContext context) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTruecustomValidate, equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validatepublic 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 AtomicBoolean connectedWhenLastTriggered
private final AtomicLong lastInactiveMessage
public static final String STATE_KEY_LATEST_SUCCESS_TRANSFER
protected void init(ProcessorInitializationContext context)
init in class AbstractSessionFactoryProcessorpublic Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponent@OnScheduled public void onScheduled(ProcessContext context)
protected void resetLastSuccessfulTransfer()
protected final void setLastSuccessfulTransfer(long timestamp)
protected final long getLatestSuccessTransfer()
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 isReconnectedToCluster(boolean isConnectedToCluster)
isConnectedToCluster - Current state of the connection.private void reconcileState(ProcessContext context)
private boolean shouldThisNodeReport(boolean isClusterScope,
boolean isReportOnlyOnPrimary,
ProcessContext context)
Copyright © 2023 Apache NiFi Project. All rights reserved.