You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by pvillard31 <gi...@git.apache.org> on 2018/04/27 15:59:59 UTC

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

GitHub user pvillard31 opened a pull request:

    https://github.com/apache/nifi/pull/2663

    NIFI-5122 - Add Record Writer for S2S RTs

    Thank you for submitting a contribution to Apache NiFi.
    
    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?
    
    ### 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?
    - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [ ] 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.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/pvillard31/nifi NIFI-5122

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/2663.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2663
    
----
commit e0279d8768e3217cf7853d9d5d17c36a81c4c45e
Author: Pierre Villard <pi...@...>
Date:   2018-04-27T15:41:39Z

    NIFI-5122 - Add Record Writer for S2S RTs

----


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r184788317
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java ---
    @@ -76,10 +81,16 @@
     
         private volatile long lastSentBulletinId = -1L;
     
    +    public SiteToSiteBulletinReportingTask() throws IOException {
    +        final InputStream schema = getClass().getClassLoader().getResourceAsStream("schema-bulletins.avsc");
    +        recordSchema = AvroTypeUtil.createSchema(new Schema.Parser().parse(schema));
    +    }
    +
         @Override
         protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
             final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors());
             properties.add(PLATFORM);
    +        properties.add(RECORD_WRITER);
    --- End diff --
    
    Yeah I asked myself this question... I was not sure if it'd make sense to move it to the abstract base class in case some users implemented custom impl... but that wouldn't break anything (just the addition of an unused property) so it's probably cleaner to have it in the abstract class. What's your feeling?


---

[GitHub] nifi issue #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on the issue:

    https://github.com/apache/nifi/pull/2663
  
    @pvillard31 @mattyb149 I'll merge today if one of you gets back to me on this.


---

[GitHub] nifi issue #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on the issue:

    https://github.com/apache/nifi/pull/2663
  
    Cleared the cache, and it didn't change anything. However, all three of the s2s tasks I tried (metrics, bulletin and provenance) seemed to work just fine when reporting to a second instance of NiFi. So as far as I am concerned, if you and @mattyb149  don't think the validating issue is a big deal or tied to this I'm ok with merging.


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r191668970
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/resources/docs/org.apache.nifi.reporting.SiteToSiteStatusReportingTask/additionalDetails.html ---
    @@ -50,7 +50,7 @@ <h2>Record writer</h2>
     	{ "name" : "actorHostname", "type" : "string"},
     	{ "name" : "componentType", "type" : "string"},
     	{ "name" : "componentName", "type" : "string"},
    -	{ "name" : "parentId", "type" : "string"},
    +	{ "name" : "parentId", "type" : ["string", "null"]},
    --- End diff --
    
    I think I remember vaguely something like that but I think it was an issue on our side with the Record API (can't find a JIRA though). I looked at other projects I've been working on and I've schemas with "null" being first or second and I had no issue.


---

[GitHub] nifi issue #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on the issue:

    https://github.com/apache/nifi/pull/2663
  
    Thanks for the feedback @mattyb149, I just pushed another commit, let me know if it's what you had in mind :)


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r191634954
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/resources/docs/org.apache.nifi.reporting.SiteToSiteStatusReportingTask/additionalDetails.html ---
    @@ -50,7 +50,7 @@ <h2>Record writer</h2>
     	{ "name" : "actorHostname", "type" : "string"},
     	{ "name" : "componentType", "type" : "string"},
     	{ "name" : "componentName", "type" : "string"},
    -	{ "name" : "parentId", "type" : "string"},
    +	{ "name" : "parentId", "type" : ["string", "null"]},
    --- End diff --
    
    That looks VERY familiar but I think even the first time we dealt with Avro it might have been 1.7.x after it had been fixed (plus that had to do with default values being supported with unions). Maybe I'm thinking of a NiFi Record API bug with unions and defaults. But either way, if this LGTY it LGTM :)


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r190853722
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/resources/docs/org.apache.nifi.reporting.SiteToSiteStatusReportingTask/additionalDetails.html ---
    @@ -0,0 +1,122 @@
    +<!DOCTYPE html>
    +<html lang="en">
    +    <!--
    +      Licensed to the Apache Software Foundation (ASF) under one or more
    +      contributor license agreements.  See the NOTICE file distributed with
    +      this work for additional information regarding copyright ownership.
    +      The ASF licenses this file to You under the Apache License, Version 2.0
    +      (the "License"); you may not use this file except in compliance with
    +      the License.  You may obtain a copy of the License at
    +          http://www.apache.org/licenses/LICENSE-2.0
    +      Unless required by applicable law or agreed to in writing, software
    +      distributed under the License is distributed on an "AS IS" BASIS,
    +      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +      See the License for the specific language governing permissions and
    +      limitations under the License.
    +    -->
    +    <head>
    +        <meta charset="utf-8" />
    +        <title>SiteToSiteStatusReportingTask</title>
    +
    +        <link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css" />
    +    </head>
    +
    +    <body>
    +    	<p>
    +    		The Site-to-Site Bulletin Reporting Task allows the user to publish Status events using the Site To Site protocol. 
    --- End diff --
    
    Fixed


---

[GitHub] nifi issue #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on the issue:

    https://github.com/apache/nifi/pull/2663
  
    @pvillard31 @mattyb149 Reviewed it and the changes look fine, but noticed something weird when I fired up a full build w/ it. When I'd add one of these tasks, the status would stay spinning at "validating..." until I hit start. Did either of you see that? Didn't seem to actually break anything yet.


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/nifi/pull/2663


---

[GitHub] nifi issue #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on the issue:

    https://github.com/apache/nifi/pull/2663
  
    @MikeThomsen - I know @mcgilman recently fixed something weird in the UI around CS/RT dialogs. Could you try cleaning your cache or using a private session to confirm?


---

[GitHub] nifi issue #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on the issue:

    https://github.com/apache/nifi/pull/2663
  
    Reviewing...


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r191607896
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/resources/docs/org.apache.nifi.reporting.SiteToSiteStatusReportingTask/additionalDetails.html ---
    @@ -50,7 +50,7 @@ <h2>Record writer</h2>
     	{ "name" : "actorHostname", "type" : "string"},
     	{ "name" : "componentType", "type" : "string"},
     	{ "name" : "componentName", "type" : "string"},
    -	{ "name" : "parentId", "type" : "string"},
    +	{ "name" : "parentId", "type" : ["string", "null"]},
    --- End diff --
    
    If you mean [this bug](https://issues.apache.org/jira/browse/AVRO-1118) looks like it was fixed a long time ago.


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r184757759
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java ---
    @@ -153,8 +164,12 @@ public void onTrigger(final ReportingContext context) {
                 attributes.put("reporting.task.type", this.getClass().getSimpleName());
                 attributes.put("mime.type", "application/json");
     
    -            final byte[] data = jsonArray.toString().getBytes(StandardCharsets.UTF_8);
    -            transaction.send(data, attributes);
    +            if(context.getProperty(RECORD_WRITER).isSet()) {
    --- End diff --
    
    The first one you did also has a customValidate method, can we put that logic into the base class (not necessarily in the exact customValidate() method but something all of these can call)? If we add the property to the base class, then it could be in the base class's customValidate(), your call :)


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r187685161
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/resources/docs/org.apache.nifi.reporting.SiteToSiteStatusReportingTask/additionalDetails.html ---
    @@ -0,0 +1,122 @@
    +<!DOCTYPE html>
    +<html lang="en">
    +    <!--
    +      Licensed to the Apache Software Foundation (ASF) under one or more
    +      contributor license agreements.  See the NOTICE file distributed with
    +      this work for additional information regarding copyright ownership.
    +      The ASF licenses this file to You under the Apache License, Version 2.0
    +      (the "License"); you may not use this file except in compliance with
    +      the License.  You may obtain a copy of the License at
    +          http://www.apache.org/licenses/LICENSE-2.0
    +      Unless required by applicable law or agreed to in writing, software
    +      distributed under the License is distributed on an "AS IS" BASIS,
    +      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +      See the License for the specific language governing permissions and
    +      limitations under the License.
    +    -->
    +    <head>
    +        <meta charset="utf-8" />
    +        <title>SiteToSiteStatusReportingTask</title>
    +
    +        <link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css" />
    +    </head>
    +
    +    <body>
    +    	<p>
    +    		The Site-to-Site Bulletin Reporting Task allows the user to publish Status events using the Site To Site protocol. 
    +    		The component type and name filter regexes form a union: only components matching both regexes will be reported. 
    +    		However, all process groups are recursively searched for matching components, regardless of whether the process 
    +    		group matches the component filters.
    +    	</p>
    +    	
    +    	<h2>Record writer</h2>
    +   	
    +    	<p>
    +    		The user can define a Record Writer and directly specify the output format and data with the assumption that the 
    +    		input schema is the following:
    +    	</p>
    +
    +		<pre>
    +			<code>
    +{
    +  "type" : "record",
    +  "name" : "status",
    +  "namespace" : "status",
    +  "fields" : [
    +    // common fields for all components
    +	{ "name" : "statusId", "type" : "string"},
    +	{ "name" : "timestampMillis", "type": { "type": "long", "logicalType": "timestamp-millis" } },
    +	{ "name" : "timestamp", "type" : "string"},
    +	{ "name" : "actorHostname", "type" : "string"},
    +	{ "name" : "componentType", "type" : "string"},
    +	{ "name" : "componentName", "type" : "string"},
    +	{ "name" : "parentId", "type" : "string"},
    --- End diff --
    
    Currently in https://github.com/apache/nifi/pull/2663/files#diff-f1f37886c50fa0946558aed14f835e27R147 it is sending in null for the parentId all the time. I think we should determine the parentId if possible, and (at least) make the field in the schema nullable.


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r185001042
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/resources/docs/org.apache.nifi.reporting.SiteToSiteStatusReportingTask/additionalDetails.html ---
    @@ -0,0 +1,122 @@
    +<!DOCTYPE html>
    +<html lang="en">
    +    <!--
    +      Licensed to the Apache Software Foundation (ASF) under one or more
    +      contributor license agreements.  See the NOTICE file distributed with
    +      this work for additional information regarding copyright ownership.
    +      The ASF licenses this file to You under the Apache License, Version 2.0
    +      (the "License"); you may not use this file except in compliance with
    +      the License.  You may obtain a copy of the License at
    +          http://www.apache.org/licenses/LICENSE-2.0
    +      Unless required by applicable law or agreed to in writing, software
    +      distributed under the License is distributed on an "AS IS" BASIS,
    +      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +      See the License for the specific language governing permissions and
    +      limitations under the License.
    +    -->
    +    <head>
    +        <meta charset="utf-8" />
    +        <title>SiteToSiteStatusReportingTask</title>
    +
    +        <link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css" />
    +    </head>
    +
    +    <body>
    +    	<p>
    +    		The Site-to-Site Bulletin Reporting Task allows the user to publish Status events using the Site To Site protocol. 
    --- End diff --
    
    Minor copy-paste error here, should be Site-to-Site Status Reporting Task. I can update while merging.


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r190854010
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/resources/docs/org.apache.nifi.reporting.SiteToSiteStatusReportingTask/additionalDetails.html ---
    @@ -0,0 +1,122 @@
    +<!DOCTYPE html>
    +<html lang="en">
    +    <!--
    +      Licensed to the Apache Software Foundation (ASF) under one or more
    +      contributor license agreements.  See the NOTICE file distributed with
    +      this work for additional information regarding copyright ownership.
    +      The ASF licenses this file to You under the Apache License, Version 2.0
    +      (the "License"); you may not use this file except in compliance with
    +      the License.  You may obtain a copy of the License at
    +          http://www.apache.org/licenses/LICENSE-2.0
    +      Unless required by applicable law or agreed to in writing, software
    +      distributed under the License is distributed on an "AS IS" BASIS,
    +      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +      See the License for the specific language governing permissions and
    +      limitations under the License.
    +    -->
    +    <head>
    +        <meta charset="utf-8" />
    +        <title>SiteToSiteStatusReportingTask</title>
    +
    +        <link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css" />
    +    </head>
    +
    +    <body>
    +    	<p>
    +    		The Site-to-Site Bulletin Reporting Task allows the user to publish Status events using the Site To Site protocol. 
    +    		The component type and name filter regexes form a union: only components matching both regexes will be reported. 
    +    		However, all process groups are recursively searched for matching components, regardless of whether the process 
    +    		group matches the component filters.
    +    	</p>
    +    	
    +    	<h2>Record writer</h2>
    +   	
    +    	<p>
    +    		The user can define a Record Writer and directly specify the output format and data with the assumption that the 
    +    		input schema is the following:
    +    	</p>
    +
    +		<pre>
    +			<code>
    +{
    +  "type" : "record",
    +  "name" : "status",
    +  "namespace" : "status",
    +  "fields" : [
    +    // common fields for all components
    +	{ "name" : "statusId", "type" : "string"},
    +	{ "name" : "timestampMillis", "type": { "type": "long", "logicalType": "timestamp-millis" } },
    +	{ "name" : "timestamp", "type" : "string"},
    +	{ "name" : "actorHostname", "type" : "string"},
    +	{ "name" : "componentType", "type" : "string"},
    +	{ "name" : "componentName", "type" : "string"},
    +	{ "name" : "parentId", "type" : "string"},
    --- End diff --
    
    That's not what I'm seeing: only the status of the root process group does have a null parentId which makes sense. But I do see the correct parentId on the other components. I updated the schema/doc to allow the null value though.


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r184757401
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java ---
    @@ -76,10 +81,16 @@
     
         private volatile long lastSentBulletinId = -1L;
     
    +    public SiteToSiteBulletinReportingTask() throws IOException {
    +        final InputStream schema = getClass().getClassLoader().getResourceAsStream("schema-bulletins.avsc");
    +        recordSchema = AvroTypeUtil.createSchema(new Schema.Parser().parse(schema));
    +    }
    +
         @Override
         protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
             final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors());
             properties.add(PLATFORM);
    +        properties.add(RECORD_WRITER);
    --- End diff --
    
    Is the intent here to allow all S2S Reporting Tasks to use the record writer if they want, or do we want to make it "mandatory" by including it in the properties from the abstract base class?


---

[GitHub] nifi pull request #2663: NIFI-5122 - Add Record Writer for S2S RTs

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2663#discussion_r191553752
  
    --- Diff: nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/resources/docs/org.apache.nifi.reporting.SiteToSiteStatusReportingTask/additionalDetails.html ---
    @@ -50,7 +50,7 @@ <h2>Record writer</h2>
     	{ "name" : "actorHostname", "type" : "string"},
     	{ "name" : "componentType", "type" : "string"},
     	{ "name" : "componentName", "type" : "string"},
    -	{ "name" : "parentId", "type" : "string"},
    +	{ "name" : "parentId", "type" : ["string", "null"]},
    --- End diff --
    
    Isn't there some Avro bug where the null has to come first? If that's been fixed, I'm good with this, otherwise we might have to switch it around.


---