Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public List<LlapServiceInstance> getAllInstancesOrdered(boolean consistentIndexe
Collections.sort(list, new Comparator<LlapServiceInstance>() {
@Override
public int compare(LlapServiceInstance o1, LlapServiceInstance o2) {
return o2.getWorkerIdentity().compareTo(o2.getWorkerIdentity());
return o1.getWorkerIdentity().compareTo(o2.getWorkerIdentity());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this change the sorting order? I think now you will see it in ascending order when compared to descending order.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously there was no order (and inconsistency instead) as o2 was compared to o2 and they are always equal.
Ascending Order (o1.compareTo(o2))
Descending Order (o2.compareTo(o1))
Please let me know if descending order is expected

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this sorting then since it was working without it.

cc @abstractdog Do you think it makes sense to use sorting here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that the comparison was incorrect and FixedServiceInstanceSet failed to comply with any sorting requirements (unlike DynamicServiceInstanceSet, which uses a TreeMap to maintain order), it doesn't really matter whether we fix the sorting or remove it entirely.

However, since the interface implies that some ordering is expected, it's reasonable to fix it now using a simple ascending order, which aligns better with intuitive expectations and brings consistency to the implementation.

}
});
return list;
Expand Down
Loading