You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by MikeThomsen <gi...@git.apache.org> on 2017/11/28 18:40:22 UTC

[GitHub] nifi pull request #2304: NIFI-4644 Fixed LookupService API to allow for more...

GitHub user MikeThomsen opened a pull request:

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

    NIFI-4644 Fixed LookupService API to allow for more than String/Strin…

    …g lookup pairs.
    
    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/MikeThomsen/nifi NIFI-4644

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

    https://github.com/apache/nifi/pull/2304.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 #2304
    
----
commit 00ffa487213c361d3851b5574f284e062a4874c7
Author: Mike Thomsen <mi...@gmail.com>
Date:   2017-11-28T15:32:11Z

    NIFI-4644 Fixed LookupService API to allow for more than String/String lookup pairs.

----


---

[GitHub] nifi issue #2304: NIFI-4644 Fixed LookupService API to allow for more than S...

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

    https://github.com/apache/nifi/pull/2304
  
    Thanks @markap14 I'll fix these and push a new version.


---

[GitHub] nifi issue #2304: NIFI-4644 Fixed LookupService API to allow for more than S...

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

    https://github.com/apache/nifi/pull/2304
  
    Ok, code review notes should all be addressed now.


---

[GitHub] nifi issue #2304: NIFI-4644 Fixed LookupService API to allow for more than S...

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

    https://github.com/apache/nifi/pull/2304
  
    @MikeThomsen I am just a bit concerned about potential implications of this change... at first glance I don't see any particular problem with it, but I feel like there may be a condition that I am overlooking... It is probably okay, but I would like to think about this just a bit more.


---

[GitHub] nifi pull request #2304: NIFI-4644 Fixed LookupService API to allow for more...

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

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


---

[GitHub] nifi issue #2304: NIFI-4644 Fixed LookupService API to allow for more than S...

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

    https://github.com/apache/nifi/pull/2304
  
    @markap14 Have you had a chance to think more this? FWIW, it doesn't seem to break any of the unit tests.


---

[GitHub] nifi issue #2304: NIFI-4644 Fixed LookupService API to allow for more than S...

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

    https://github.com/apache/nifi/pull/2304
  
    @markap14 That's fine. I posted on the mailing list that someone already found a real case where it broke their flow because it converted an integer to a string and MongoDB couldn't do the lookup. The ticket reference for that particular problem is in there if you want to take a look.


---

[GitHub] nifi issue #2304: NIFI-4644 Fixed LookupService API to allow for more than S...

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

    https://github.com/apache/nifi/pull/2304
  
    @m-hogue I think on the mailing list it said you did a lot of work on the Record API. Do you think you could take a look at this? It's an API change that was necessitated by the String,String limitation.


---

[GitHub] nifi pull request #2304: NIFI-4644 Fixed LookupService API to allow for more...

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

    https://github.com/apache/nifi/pull/2304#discussion_r153818651
  
    --- Diff: nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java ---
    @@ -237,8 +237,8 @@ public void closeReader() throws IOException {
             }
         }
     
    -    private Optional<Record> doLookup(final DatabaseReader databaseReader, final Map<String, String> coordinates) throws LookupFailureException, InvalidDatabaseException {
    -        final String ipAddress = coordinates.get(IP_KEY);
    +    private Optional<Record> doLookup(final DatabaseReader databaseReader, final Map<String, Object> coordinates) throws LookupFailureException, InvalidDatabaseException {
    +        final String ipAddress = coordinates.get(IP_KEY) instanceof String ? (String)coordinates.get(IP_KEY) : coordinates.get(IP_KEY).toString();
    --- End diff --
    
    Again, no need to check instanceof here - can just call toString()


---

[GitHub] nifi pull request #2304: NIFI-4644 Fixed LookupService API to allow for more...

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

    https://github.com/apache/nifi/pull/2304#discussion_r153818546
  
    --- Diff: nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleCsvFileLookupService.java ---
    @@ -194,12 +194,12 @@ public void onEnabled(final ConfigurationContext context) throws InitializationE
         }
     
         @Override
    -    public Optional<String> lookup(final Map<String, String> coordinates) throws LookupFailureException {
    +    public Optional<String> lookup(final Map<String, Object> coordinates) throws LookupFailureException {
             if (coordinates == null) {
                 return Optional.empty();
             }
     
    -        final String key = coordinates.get(KEY);
    +        final String key = coordinates.get(KEY) instanceof String ? (String)coordinates.get(KEY) : coordinates.get(KEY).toString();
    --- End diff --
    
    Again, no need to check instanceof here - can just call toString()


---

[GitHub] nifi issue #2304: NIFI-4644 Fixed LookupService API to allow for more than S...

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

    https://github.com/apache/nifi/pull/2304
  
    @MikeThomsen thanks for the 'bump'. I did think about it quite a bit and decided that all does appear to be okay. But to be honest, I had forgotten to merge. Sorry about that! Did some verifications manually just now and am happy with all that I'm seeing, using LookupRecord with the IP Enrichment lookup service and the SimpleKeyValueLookup Service. Thanks for the update and for hanging in there, even when I dropped the ball on the review :)


---

[GitHub] nifi pull request #2304: NIFI-4644 Fixed LookupService API to allow for more...

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

    https://github.com/apache/nifi/pull/2304#discussion_r153818623
  
    --- Diff: nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java ---
    @@ -122,12 +122,12 @@ public void onEvent(ConfigurationBuilderEvent event) {
         }
     
         @Override
    -    public Optional<String> lookup(final Map<String, String> coordinates) throws LookupFailureException {
    +    public Optional<String> lookup(final Map<String, Object> coordinates) throws LookupFailureException {
             if (coordinates == null) {
                 return Optional.empty();
             }
     
    -        final String key = coordinates.get(KEY);
    +        final String key = coordinates.get(KEY) instanceof String ? (String)coordinates.get(KEY) : coordinates.get(KEY).toString();
    --- End diff --
    
    Again, no need to check instanceof here - can just call toString()


---

[GitHub] nifi pull request #2304: NIFI-4644 Fixed LookupService API to allow for more...

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

    https://github.com/apache/nifi/pull/2304#discussion_r153818372
  
    --- Diff: nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_RecordLookupService.java ---
    @@ -114,8 +114,12 @@
         }
     
         @Override
    -    public Optional<Record> lookup(Map<String, String> coordinates) throws LookupFailureException {
    -        final String rowKey = coordinates.get(ROW_KEY_KEY);
    +    public Optional<Record> lookup(Map<String, Object> coordinates) throws LookupFailureException {
    +        if (coordinates.get(ROW_KEY_KEY) == null) {
    +            return Optional.empty();
    +        }
    +
    +        final String rowKey = coordinates.get(ROW_KEY_KEY) instanceof String ? (String)coordinates.get(ROW_KEY_KEY) : coordinates.get(ROW_KEY_KEY).toString();
    --- End diff --
    
    I don't think we need to be checking any instanceof here -- just call coordinates.get(ROW_KEY_KEY).toString() -- it is a String, then toString() will simply return 'this'.


---

[GitHub] nifi pull request #2304: NIFI-4644 Fixed LookupService API to allow for more...

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

    https://github.com/apache/nifi/pull/2304#discussion_r153818578
  
    --- Diff: nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleKeyValueLookupService.java ---
    @@ -58,12 +58,12 @@ public void cacheConfiguredValues(final ConfigurationContext context) {
         }
     
         @Override
    -    public Optional<String> lookup(final Map<String, String> coordinates) {
    +    public Optional<String> lookup(final Map<String, Object> coordinates) {
             if (coordinates == null) {
                 return Optional.empty();
             }
     
    -        final String key = coordinates.get(KEY);
    +        final String key = coordinates.get(KEY) instanceof String ? (String)coordinates.get(KEY) : coordinates.get(KEY).toString();
    --- End diff --
    
    Again, no need to check instanceof here - can just call toString()


---