Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-6780: Add QueryNiFiReportingTask, RecordSinkService, S2S and DB impls #3826

Merged
merged 4 commits into from Oct 22, 2019

Conversation

mattyb149
Copy link
Contributor

Thank you for submitting a contribution to Apache NiFi.

Please provide a short description of the PR here:

Description of PR

Introduce RecordSinkService, to separate format and destination, refactor common S2S utils

Added QueryNiFiReportingTask to SQL query NiFi status and metrics

Expose PROCESSOR_STATUS, PROCESS_GROUP_STATUS, BULLETINS, JVM_METRICS, CONNECTION_STATUS_PREDICTIONS tables

Implement SiteToSiteReportingRecordSink and DatabaseRecordSink

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically master)?

  • Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not squash or use --force when pushing to allow for clean monitoring of changes.

For code changes:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • Have you verified that the full build is successful on both JDK 8 and JDK 11?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

@YolandaMDavis
Copy link
Contributor

YolandaMDavis commented Oct 18, 2019

@mattyb149 I ran into an exception when I attempted to query the CONNECTION_STATUS_PREDICTIONS table when predictions were not enabled. Exception is below:

QueryNiFiReportingTask[id=df116dbf-016d-1000-29b8-156a35b5fe7f] Error during transmission of query results due to Could not obtain next record from ResultSet: java.io.IOException: Could n
ot obtain next record from ResultSet
java.io.IOException: Could not obtain next record from ResultSet
        at org.apache.nifi.serialization.record.ResultSetRecordSet.next(ResultSetRecordSet.java:98)
        at org.apache.nifi.record.sink.db.DatabaseRecordSink.sendData(DatabaseRecordSink.java:252)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:87)
        at com.sun.proxy.$Proxy125.sendData(Unknown Source)
        at org.apache.nifi.reporting.sql.QueryNiFiReportingTask.onTrigger(QueryNiFiReportingTask.java:119)
        at org.apache.nifi.controller.tasks.ReportingTaskWrapper.run(ReportingTaskWrapper.java:44)
        at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.sql.SQLException: java.lang.NullPointerException
        at org.apache.calcite.avatica.util.PositionedCursor$ArrayGetter.getObject(PositionedCursor.java:65)
        at org.apache.calcite.avatica.util.AbstractCursor$AccessorImpl.getObject(AbstractCursor.java:359)
        at org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:393)
        at org.apache.nifi.serialization.record.ResultSetRecordSet.createRecord(ResultSetRecordSet.java:119)
        at org.apache.nifi.serialization.record.ResultSetRecordSet.next(ResultSetRecordSet.java:91)
        ... 16 common frames omitted
Caused by: java.lang.NullPointerException: null
        at org.apache.calcite.avatica.util.PositionedCursor$ArrayGetter.getObject(PositionedCursor.java:62)


Recommend checking for the existence of this table first if possible and having an exception that aligns with the fact that the table is missing.

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need tags, descriptions and other helpful notes for user config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂ forgot to add those, good catch, will do that now

@YolandaMDavis
Copy link
Contributor

YolandaMDavis commented Oct 18, 2019

@mattyb149 I've run several tests, confirming that the changes to existing Site-to-Site reporting task worked properly, testing queries for the QueryNiFiReporting task and testing both Site-to-Site Record Sink and Database Record Sink. Also included testing with security enabled. Beyond the areas I've highlighted things look great. Thanks for adding this feature!

One thing to note is to review the size of the resulting nars from this contribution just to ensure there are no issues with builds/travis.

…tion, refactor common S2S utils

Added QueryNiFiReportingTask to SQL query NiFi status and metrics

Add PROCESSOR_STATUS and PROCESS_GROUP_STATUS

Add CONNECTION_STATUS_PREDICTIONS

check for null predictions

Add ConnectionStatusRecursiveIterator

Fix issue w/ duplicate iterator outputs

Refactored query interfaces, fixed assembly POM

Rebased v master, fixed isBackPressureEnabled and Checkstyle/RAT errors

Add DatabaseRecordSink service (#13)

* Add DatabaseRecordSink service

* Incorporated review comments
@YolandaMDavis
Copy link
Contributor

@mattyb149 changes look good I was able to retest scenarios and saw that queries with the prediction table (yet cluster predictions disabled) generate an appropriate exception. The last suggestion I have is to clarify in docs the details of the table's availability. After that (and happy travis build) it's a +1 for me.

@YolandaMDavis
Copy link
Contributor

@mattyb149 thanks for the updates! +1 . Will merge shortly

@YolandaMDavis YolandaMDavis merged commit ace23c3 into apache:master Oct 22, 2019
patricker pushed a commit to patricker/nifi that referenced this pull request Jan 22, 2020
…impls (apache#3826)

* NIFI-6780: Introduce RecordSinkService to separate format and destination, refactor common S2S utils

Added QueryNiFiReportingTask to SQL query NiFi status and metrics

Add PROCESSOR_STATUS and PROCESS_GROUP_STATUS

Add CONNECTION_STATUS_PREDICTIONS

check for null predictions

Add ConnectionStatusRecursiveIterator

Fix issue w/ duplicate iterator outputs

Refactored query interfaces, fixed assembly POM

Rebased v master, fixed isBackPressureEnabled and Checkstyle/RAT errors

Add DatabaseRecordSink service (apache#13)

* Add DatabaseRecordSink service

* Incorporated review comments

* NIFI-6780: Add/fix docs, cleanup warnings, fixed some table definitions

* Added bundle profile, remove predictions table if not enabled

* Added doc for which tables are available when

This closes apache#3826.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants