You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@twill.apache.org by gokulavasan <gi...@git.apache.org> on 2016/09/09 01:45:07 UTC

[GitHub] twill pull request #10: TWILL-107 Add payload support for Discoverable

GitHub user gokulavasan opened a pull request:

    https://github.com/apache/twill/pull/10

    TWILL-107 Add payload support for Discoverable

    JIRA : https://issues.apache.org/jira/browse/TWILL-107

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

    $ git pull https://github.com/gokulavasan/twill feature/twill-107

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

    https://github.com/apache/twill/pull/10.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 #10
    
----
commit 5f82fe12e12a6cf42ad7ac43cde4e9b3fb0fec53
Author: Gokul Gunasekaran <go...@cask.co>
Date:   2016-09-09T01:12:43Z

    TWILL-107 Add payload support for Discoverable
    
    Signed-off-by: Gokul Gunasekaran <go...@cask.co>

----


---
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] twill pull request #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10#discussion_r78250733
  
    --- Diff: twill-discovery-api/src/main/java/org/apache/twill/discovery/Discoverable.java ---
    @@ -19,19 +19,67 @@
     package org.apache.twill.discovery;
     
     import java.net.InetSocketAddress;
    +import java.util.Arrays;
     
     /**
      * Discoverable defines the attributes of service to be discovered.
      */
    -public interface Discoverable {
    +public class Discoverable {
    +  private final String name;
    +  private final InetSocketAddress address;
    +  private final byte[] payload;
     
    +  public Discoverable(String name, InetSocketAddress address, byte[] payload) {
    +    this.name = name;
    +    this.address = address;
    +    this.payload = payload;
    +  }
       /**
        * @return Name of the service
        */
    -  String getName();
    +  public String getName() {
    +    return name;
    +  }
     
       /**
        * @return An {@link InetSocketAddress} representing the host+port of the service.
        */
    -  InetSocketAddress getSocketAddress();
    +  public InetSocketAddress getSocketAddress() {
    +    return address;
    +  }
    +
    +  /**
    +   * @return A payload represented as a byte array
    +   */
    +  byte[] getPayload() {
    +    return payload;
    +  }
    +
    +  @Override
    +  public String toString() {
    +    return "{name=" + name + ", address=" + address + ", payload=" + payload + "}";
    +  }
    +
    +  @Override
    +  public boolean equals(Object o) {
    +    if (this == o) {
    +      return true;
    +    }
    +    if (o == null || getClass() != o.getClass()) {
    +      return false;
    +    }
    +
    +    Discoverable other = (Discoverable) o;
    +
    +    return name.equals(other.getName()) && address.equals(other.getSocketAddress()) &&
    +      Arrays.equals(payload, other.getPayload());
    +  }
    +
    +  @Override
    +  public int hashCode() {
    +    int result = name.hashCode();
    --- End diff --
    
    Use `Objects.hash(name, address, payload)` instead.


---
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] twill issue #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10
  
    Thanks for the review @chtyim. Addressed comments. Please take a look again.


---
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] twill pull request #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10#discussion_r78250500
  
    --- Diff: twill-discovery-api/src/main/java/org/apache/twill/discovery/Discoverable.java ---
    @@ -19,19 +19,67 @@
     package org.apache.twill.discovery;
     
     import java.net.InetSocketAddress;
    +import java.util.Arrays;
     
     /**
      * Discoverable defines the attributes of service to be discovered.
      */
    -public interface Discoverable {
    +public class Discoverable {
    +  private final String name;
    +  private final InetSocketAddress address;
    +  private final byte[] payload;
     
    +  public Discoverable(String name, InetSocketAddress address, byte[] payload) {
    --- End diff --
    
    Should also have a constructor that doesn't take `payload`.


---
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] twill pull request #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10#discussion_r78250557
  
    --- Diff: twill-discovery-api/src/main/java/org/apache/twill/discovery/Discoverable.java ---
    @@ -19,19 +19,67 @@
     package org.apache.twill.discovery;
     
     import java.net.InetSocketAddress;
    +import java.util.Arrays;
     
     /**
      * Discoverable defines the attributes of service to be discovered.
      */
    -public interface Discoverable {
    +public class Discoverable {
    +  private final String name;
    +  private final InetSocketAddress address;
    +  private final byte[] payload;
     
    +  public Discoverable(String name, InetSocketAddress address, byte[] payload) {
    +    this.name = name;
    +    this.address = address;
    +    this.payload = payload;
    +  }
       /**
        * @return Name of the service
        */
    -  String getName();
    +  public String getName() {
    +    return name;
    +  }
     
       /**
        * @return An {@link InetSocketAddress} representing the host+port of the service.
        */
    -  InetSocketAddress getSocketAddress();
    +  public InetSocketAddress getSocketAddress() {
    +    return address;
    +  }
    +
    +  /**
    +   * @return A payload represented as a byte array
    +   */
    +  byte[] getPayload() {
    --- End diff --
    
    Should this be a `public` method?


---
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] twill issue #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10
  
    @chtyim Squashed commits. Thanks!


---
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] twill issue #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10
  
    Thanks for the PR, @gokulavasan. Next time would love to have more information how you solve it in the PR description rather than just link to JIRA.


---
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] twill issue #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10
  
    LGTM. Please squash the commits.


---
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] twill issue #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10
  
    @hsaputra I have added some description to the PR. Sorry. Thank you for catching it. 


---
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] twill pull request #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10#discussion_r78250998
  
    --- Diff: twill-discovery-core/src/main/java/org/apache/twill/discovery/DiscoverableAdapter.java ---
    @@ -76,18 +78,9 @@ public Discoverable deserialize(JsonElement json, Type typeOfT,
           final String service = jsonObj.get("service").getAsString();
           String hostname = jsonObj.get("hostname").getAsString();
           int port = jsonObj.get("port").getAsInt();
    +      final byte[] payload = context.deserialize(jsonObj.get("payload"), BYTE_ARRAY_TYPE);
    --- End diff --
    
    No need to be final. Same for `service` above.


---
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] twill issue #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10
  
    Just couple comments.


---
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] twill pull request #10: TWILL-107 Add payload support for Discoverable

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

    https://github.com/apache/twill/pull/10


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