Skip to content

Commit

Permalink
[Feature/extensions] Added HostAddress and Port in initial extension …
Browse files Browse the repository at this point in the history
…request (#4197)

* Added hostaddress and port in initial extension request

Signed-off-by: Owais Kazi <[email protected]>

* Spotless apply

Signed-off-by: Owais Kazi <[email protected]>

* PR comment

Signed-off-by: Owais Kazi <[email protected]>

* Added setter for port

Signed-off-by: Owais Kazi <[email protected]>

Signed-off-by: Owais Kazi <[email protected]>
  • Loading branch information
owaiskazi19 authored Aug 22, 2022
1 parent e3acafd commit 60bb959
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,28 @@ public class InitializeExtensionsRequest extends TransportRequest {
* TODO change DiscoveryNode to Extension information
*/
private final List<DiscoveryExtension> extensions;
public static final int OS_DEFAULT_PORT = 9200;
private int port;

public InitializeExtensionsRequest(DiscoveryNode sourceNode, List<DiscoveryExtension> extensions) {
this.sourceNode = sourceNode;
this.extensions = extensions;
this.port = OS_DEFAULT_PORT;
}

public InitializeExtensionsRequest(StreamInput in) throws IOException {
super(in);
sourceNode = new DiscoveryNode(in);
extensions = in.readList(DiscoveryExtension::new);
port = in.readInt();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
sourceNode.writeTo(out);
out.writeList(extensions);
out.writeInt(port);
}

public List<DiscoveryExtension> getExtensions() {
Expand All @@ -56,21 +61,31 @@ public DiscoveryNode getSourceNode() {
return sourceNode;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

@Override
public String toString() {
return "InitializeExtensionsRequest{" + "sourceNode=" + sourceNode + ", extensions=" + extensions + '}';
return "InitializeExtensionsRequest{" + "sourceNode=" + sourceNode + ", extensions=" + extensions + ", port=" + port + '}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InitializeExtensionsRequest that = (InitializeExtensionsRequest) o;
return Objects.equals(sourceNode, that.sourceNode) && Objects.equals(extensions, that.extensions);
return Objects.equals(sourceNode, that.sourceNode)
&& Objects.equals(extensions, that.extensions)
&& Objects.equals(port, that.port);
}

@Override
public int hashCode() {
return Objects.hash(sourceNode, extensions);
return Objects.hash(sourceNode, extensions, port);
}
}

0 comments on commit 60bb959

Please sign in to comment.