Skip to content

Commit

Permalink
Skipping serialization of node attributes in Leader and follower checks
Browse files Browse the repository at this point in the history
Signed-off-by: RS146BIJAY <rishavsagar4b1@gmail.com>
  • Loading branch information
RS146BIJAY committed Aug 30, 2024
1 parent b830d68 commit 97121b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.opensearch.Version;
import org.opensearch.cluster.ClusterManagerMetrics;
import org.opensearch.cluster.coordination.Coordinator.Mode;
import org.opensearch.cluster.node.DiscoveryNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,34 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(entry.getKey());
out.writeString(entry.getValue());
}

out.writeVInt(roles.size());
for (final DiscoveryNodeRole role : roles) {
final DiscoveryNodeRole compatibleRole = role.getCompatibilityRole(out.getVersion());
out.writeString(compatibleRole.roleName());
out.writeString(compatibleRole.roleNameAbbreviation());
out.writeBoolean(compatibleRole.canContainData());
}

out.writeVersion(version);
}

public void writeToWithoutAttribute(StreamOutput out) throws IOException {
out.writeString(nodeName);
out.writeString(nodeId);
out.writeString(ephemeralId);
out.writeString(hostName);
out.writeString(hostAddress);
address.writeTo(out);
out.writeVInt(0);
out.writeVInt(roles.size());
for (final DiscoveryNodeRole role : roles) {
final DiscoveryNodeRole compatibleRole = role.getCompatibilityRole(out.getVersion());
out.writeString(compatibleRole.roleName());
out.writeString(compatibleRole.roleNameAbbreviation());
out.writeBoolean(compatibleRole.canContainData());
}

out.writeVersion(version);
}

Expand Down Expand Up @@ -572,7 +593,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field(entry.getKey(), entry.getValue());
}
builder.endObject();

builder.endObject();
return builder;
}
Expand Down

0 comments on commit 97121b1

Please sign in to comment.