-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
NIFI-14238 - Add CaptureBoxEvents processor #9695
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting together this new Processor @pvillard31. The Box API seems fairly straightforward. I noted several recommendations on naming. On the general approach, I'm concerned about creating a new array of JSON objects in memory, instead of streaming the currently queued events.
...undle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/CaptureBoxEvents.java
Outdated
Show resolved
Hide resolved
final JsonArray jsonEvents = Json.array(); | ||
for (BoxEvent event : eventList) { | ||
jsonEvents.add(toRecord(event)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach ends up creating a new object for every BoxEvent
, which has some memory impacts. Instead of this approach, it would be much more efficient to use a streaming JSON writer to add each event to the output stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good point!
...undle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/CaptureBoxEvents.java
Outdated
Show resolved
Hide resolved
...undle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/CaptureBoxEvents.java
Outdated
Show resolved
Hide resolved
...undle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/CaptureBoxEvents.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public boolean onException(Throwable e) { | ||
getLogger().warn("An error has been received from the stream.", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend tracking the position
so that it could be logged.
getLogger().warn("An error has been received from the stream.", e); | |
getLogger().warn("Event stream processing failed at position {}", position, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not have the position when an exception is thrown. We have it in onNextPosition
and it's already logged there. Or am I missing something?
eventStream = new EventStream(boxAPIConnection); | ||
|
||
final int eventsCapacity = context.getProperty(MAX_MESSAGE_QUEUE_SIZE).asInteger(); | ||
if (events == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the purpose of the null check to avoid clearing any queued events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I figured that in case we stop the processor, we may not want to clear the queued events. Should I instead clear the queue and just drop what we already consumed? In any case we would have ignored the events while the processor was stopped...
Summary
NIFI-14238 - Add CaptureBoxEvents processor
This pull request adds a new processor that will consume all Box events and output the content of the events as an array of JSON records. In addition to this processor, the pull request also adds another controller service to connect to the Box API using the developer token option. This option is used only for testing as this token expires after 60 minutes but it allows testing the Box components in NiFi without the need for a Business/Enterprise account.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000
NIFI-00000
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
LICENSE
andNOTICE
filesDocumentation