diff --git a/waltz-server/src/main/java/com/wepay/waltz/server/internal/Partition.java b/waltz-server/src/main/java/com/wepay/waltz/server/internal/Partition.java index a25b4e1..5c64e64 100644 --- a/waltz-server/src/main/java/com/wepay/waltz/server/internal/Partition.java +++ b/waltz-server/src/main/java/com/wepay/waltz/server/internal/Partition.java @@ -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; } } diff --git a/waltz-server/src/main/java/com/wepay/waltz/server/internal/WaltzServerHandler.java b/waltz-server/src/main/java/com/wepay/waltz/server/internal/WaltzServerHandler.java index a55ccde..c100b8f 100644 --- a/waltz-server/src/main/java/com/wepay/waltz/server/internal/WaltzServerHandler.java +++ b/waltz-server/src/main/java/com/wepay/waltz/server/internal/WaltzServerHandler.java @@ -235,8 +235,15 @@ public void onChannelActive() { @Override public void onChannelInactive() { synchronized (partitions) { + List 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)); } } }