You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apex.apache.org by bhupeshchawda <gi...@git.apache.org> on 2016/05/14 00:05:31 UTC

[GitHub] incubator-apex-malhar pull request: SPOI-8049-Fixed getters and se...

GitHub user bhupeshchawda opened a pull request:

    https://github.com/apache/incubator-apex-malhar/pull/274

    SPOI-8049-Fixed getters and setters for topics and clusters

    

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

    $ git pull https://github.com/bhupeshchawda/incubator-apex-malhar SPOI-8049-kafka-setter-1

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

    https://github.com/apache/incubator-apex-malhar/pull/274.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 #274
    
----
commit 1cb9cfacb2bee27a9bd14e78e39b6ae5502cf81b
Author: bhupesh <bh...@gmail.com>
Date:   2016-05-13T23:48:53Z

    SPOI-8049-Fixed getters and setters for topics and clusters

----


---
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.
---

[GitHub] incubator-apex-malhar pull request: SPOI-8049-Fixed getters and se...

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

    https://github.com/apache/incubator-apex-malhar/pull/274#discussion_r63266582
  
    --- Diff: kafka/src/main/java/org/apache/apex/malhar/kafka/AbstractKafkaInputOperator.java ---
    @@ -413,33 +413,39 @@ public int getInitialPartitionCount()
         return initialPartitionCount;
       }
     
    -  public void setClusters(String clusters)
    -  {
    -    this.clusters = clusters.split(";");
    -  }
    -
       /**
        *  Same setting as bootstrap.servers property to KafkaConsumer
        *  refer to http://kafka.apache.org/documentation.html#newconsumerconfigs
    -   *  To support multi cluster, you can have multiple bootstrap.servers separated by ";"
    +   *  To support multi cluster, you can have multiple elements in the array
        */
    -  public String getClusters()
    +  public void setClusters(String[] clusters)
       {
    -    return Joiner.on(';').join(clusters);
    +    this.clusters = clusters;
       }
     
    -  public void setTopics(String topics)
    +  public String[] getClusters()
       {
    -    this.topics = Iterables.toArray(Splitter.on(',').trimResults().omitEmptyStrings().split(topics), String.class);
    +    return clusters;
       }
     
       /**
    -   * The topics the operator consumes, separate by','
    +   * The topics the operator consumes
        * Topic name can only contain ASCII alphanumerics, '.', '_' and '-'
        */
    -  public String getTopics()
    +  public void setTopics(String[] topics)
    +  {
    +    ArrayList<String> temp = new ArrayList<>();
    +    for (String topic: Arrays.asList(topics)) {
    --- End diff --
    
    Why not iterate topics directly ?


---
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.
---

[GitHub] incubator-apex-malhar pull request: SPOI-8049-Fixed getters and se...

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

    https://github.com/apache/incubator-apex-malhar/pull/274#discussion_r63268719
  
    --- Diff: kafka/src/main/java/org/apache/apex/malhar/kafka/AbstractKafkaInputOperator.java ---
    @@ -413,33 +413,39 @@ public int getInitialPartitionCount()
         return initialPartitionCount;
       }
     
    -  public void setClusters(String clusters)
    -  {
    -    this.clusters = clusters.split(";");
    -  }
    -
       /**
        *  Same setting as bootstrap.servers property to KafkaConsumer
        *  refer to http://kafka.apache.org/documentation.html#newconsumerconfigs
    -   *  To support multi cluster, you can have multiple bootstrap.servers separated by ";"
    +   *  To support multi cluster, you can have multiple elements in the array
        */
    -  public String getClusters()
    +  public void setClusters(String[] clusters)
       {
    -    return Joiner.on(';').join(clusters);
    +    this.clusters = clusters;
       }
     
    -  public void setTopics(String topics)
    +  public String[] getClusters()
       {
    -    this.topics = Iterables.toArray(Splitter.on(',').trimResults().omitEmptyStrings().split(topics), String.class);
    +    return clusters;
       }
     
       /**
    -   * The topics the operator consumes, separate by','
    +   * The topics the operator consumes
        * Topic name can only contain ASCII alphanumerics, '.', '_' and '-'
        */
    -  public String getTopics()
    +  public void setTopics(String[] topics)
    +  {
    +    ArrayList<String> temp = new ArrayList<>();
    +    for (String topic: Arrays.asList(topics)) {
    +      if (topic != null && topic.length() != 0) {
    +        temp.add(topic);
    +      }
    +    }
    +    temp.toArray(this.topics);
    --- End diff --
    
    Won't **this.topics** be null here since this function is supposed to initialize it ? If so, the **toArray()** call will throw a NPE.


---
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.
---

[GitHub] incubator-apex-malhar pull request: SPOI-8049-Fixed getters and se...

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

    https://github.com/apache/incubator-apex-malhar/pull/274#discussion_r63391011
  
    --- Diff: kafka/src/main/java/org/apache/apex/malhar/kafka/AbstractKafkaInputOperator.java ---
    @@ -413,33 +413,39 @@ public int getInitialPartitionCount()
         return initialPartitionCount;
       }
     
    -  public void setClusters(String clusters)
    -  {
    -    this.clusters = clusters.split(";");
    -  }
    -
       /**
        *  Same setting as bootstrap.servers property to KafkaConsumer
        *  refer to http://kafka.apache.org/documentation.html#newconsumerconfigs
    -   *  To support multi cluster, you can have multiple bootstrap.servers separated by ";"
    +   *  To support multi cluster, you can have multiple elements in the array
        */
    -  public String getClusters()
    +  public void setClusters(String[] clusters)
       {
    -    return Joiner.on(';').join(clusters);
    +    this.clusters = clusters;
    --- End diff --
    
    Clusters are separated by comma. If we have multiple host:port pairs in each cluster, they can be specified as follows: "host1:port1, host2:port2", "host3:port3" where we use quotes to separate clusters.


---
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.
---

[GitHub] incubator-apex-malhar pull request: SPOI-8049-Fixed getters and se...

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

    https://github.com/apache/incubator-apex-malhar/pull/274#discussion_r63266713
  
    --- Diff: kafka/src/main/java/org/apache/apex/malhar/kafka/AbstractKafkaInputOperator.java ---
    @@ -413,33 +413,39 @@ public int getInitialPartitionCount()
         return initialPartitionCount;
       }
     
    -  public void setClusters(String clusters)
    -  {
    -    this.clusters = clusters.split(";");
    -  }
    -
       /**
        *  Same setting as bootstrap.servers property to KafkaConsumer
        *  refer to http://kafka.apache.org/documentation.html#newconsumerconfigs
    -   *  To support multi cluster, you can have multiple bootstrap.servers separated by ";"
    +   *  To support multi cluster, you can have multiple elements in the array
        */
    -  public String getClusters()
    +  public void setClusters(String[] clusters)
       {
    -    return Joiner.on(';').join(clusters);
    +    this.clusters = clusters;
       }
     
    -  public void setTopics(String topics)
    +  public String[] getClusters()
       {
    -    this.topics = Iterables.toArray(Splitter.on(',').trimResults().omitEmptyStrings().split(topics), String.class);
    +    return clusters;
       }
     
       /**
    -   * The topics the operator consumes, separate by','
    +   * The topics the operator consumes
        * Topic name can only contain ASCII alphanumerics, '.', '_' and '-'
        */
    -  public String getTopics()
    +  public void setTopics(String[] topics)
    +  {
    +    ArrayList<String> temp = new ArrayList<>();
    +    for (String topic: Arrays.asList(topics)) {
    --- End diff --
    
    Yeah, will change it.
    Was trying out something to do it without the loop, but forgot to revert the list.


---
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.
---

[GitHub] incubator-apex-malhar pull request: SPOI-8049-Fixed getters and se...

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

    https://github.com/apache/incubator-apex-malhar/pull/274


---
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.
---

[GitHub] incubator-apex-malhar pull request: SPOI-8049-Fixed getters and se...

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

    https://github.com/apache/incubator-apex-malhar/pull/274#discussion_r63382545
  
    --- Diff: kafka/src/main/java/org/apache/apex/malhar/kafka/AbstractKafkaInputOperator.java ---
    @@ -413,33 +413,39 @@ public int getInitialPartitionCount()
         return initialPartitionCount;
       }
     
    -  public void setClusters(String clusters)
    -  {
    -    this.clusters = clusters.split(";");
    -  }
    -
       /**
        *  Same setting as bootstrap.servers property to KafkaConsumer
        *  refer to http://kafka.apache.org/documentation.html#newconsumerconfigs
    -   *  To support multi cluster, you can have multiple bootstrap.servers separated by ";"
    +   *  To support multi cluster, you can have multiple elements in the array
        */
    -  public String getClusters()
    +  public void setClusters(String[] clusters)
       {
    -    return Joiner.on(';').join(clusters);
    +    this.clusters = clusters;
    --- End diff --
    
    How do you separate nodes in each cluster string? 


---
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.
---