Skip to content

Commit

Permalink
Merge pull request #154 from wepay/Display-Partitions-that-WaltzServe…
Browse files Browse the repository at this point in the history
…rHandler-didnt-remove

Show partitions that weren't removed by WaltzServerHandler.
  • Loading branch information
hrdlotom authored Dec 8, 2021
2 parents a8ac9f3 + 7541e54 commit 42cad27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,16 @@ public void setPartitionClient(PartitionClient client) {
/**
* Removes the client from the list of clients that are part of this partition.
* @param client The client that has to be removed from this partition.
* @return True if the partition is removed, otherwise returns False.
*/
public void removePartitionClient(PartitionClient client) {
public boolean removePartitionClient(PartitionClient client) {
synchronized (partitionClientSeqNums) {
Long currentSeqNum = partitionClientSeqNums.get(client.clientId());
if (currentSeqNum != null && currentSeqNum.equals(client.seqNum())) {
partitionClientSeqNums.remove(client.clientId());
return true;
}
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,15 @@ public void onChannelActive() {
@Override
public void onChannelInactive() {
synchronized (partitions) {
List<Integer> partitionClientsNotRemoved = new ArrayList<>();
for (Partition partition : partitions.values()) {
partition.removePartitionClient(handler);
if (!partition.removePartitionClient(handler)) {
partitionClientsNotRemoved.add(partition.partitionId);
}
}
if (!partitionClientsNotRemoved.isEmpty()) {
LOGGER.info(String.format("WaltzServerHandler ClientId: %d, SeqNum: %d, partitionClientsNotRemoved: %s",
handler.clientId, handler.seqNum, partitionClientsNotRemoved));
}
}
}
Expand Down

0 comments on commit 42cad27

Please sign in to comment.