nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegz <...@git.apache.org>
Subject [GitHub] nifi pull request #563: NIFI-2078: External state management.
Date Wed, 06 Jul 2016 23:10:09 GMT
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/563#discussion_r69828024
  
    --- Diff: nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-processors/src/main/java/org/apache/nifi/processors/kafka/GetKafka.java
---
    @@ -481,4 +496,51 @@ private void releaseFlowFile(FlowFile flowFile, ProcessSession session,
Map<Stri
                 session.transfer(flowFile, REL_SUCCESS);
             }
         }
    +
    +    @Override
    +    public StateMap getState() throws IOException {
    +        if (!isReadyToAccessState()) {
    +            return null;
    +        }
    +        final Map<String, String> partitionOffsets = KafkaUtils.retrievePartitionOffsets(zookeeperConnectionString,
topic, groupId);
    +
    +        return new StandardStateMap(partitionOffsets, System.currentTimeMillis());
    +    }
    +
    +    private boolean isReadyToAccessState() {
    +        if(StringUtils.isEmpty(zookeeperConnectionString)
    +                || StringUtils.isEmpty(topic)
    +                || StringUtils.isEmpty(groupId)) {
    +            return false;
    +        }
    +        return true;
    --- End diff --
    
    Wouldn't it be simpler to do:
    ```java
    return !StringUtils.isEmpty(zookeeperConnectionString) && !StringUtils.isEmpty(topic)
&& StringUtils.isEmpty(groupId);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message