Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -160,11 +160,9 @@ class GroupMetadataManager(brokerId: Int,

// return true iff group is owned and the group doesn't exist
def groupNotExists(groupId: String) = inLock(partitionLock) {
isGroupLocal(groupId) && (!groupMetadataCache.contains(groupId) || {
groupMetadataCache.get(groupId) match {
case group => group != null && group.inLock(group.is(Dead))
}
})
isGroupLocal(groupId) && getGroup(groupId).forall { group =>
group.inLock(group.is(Dead))
}
}

// visible for testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,23 @@ class GroupMetadataManagerTest {
}
}

@Test
def testGroupNotExists() {
// group is not owned
assertFalse(groupMetadataManager.groupNotExists(groupId))

groupMetadataManager.addPartitionOwnership(groupPartitionId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Following this and prior to adding the group, we should see groupNotExists return true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'll add that. Thanks!

val group = new GroupMetadata(groupId, initialState = Empty)
groupMetadataManager.addGroup(group)

// group is owned but not Dead
assertFalse(groupMetadataManager.groupNotExists(groupId))

group.transitionTo(Dead)
// group is owned and Dead
assertTrue(groupMetadataManager.groupNotExists(groupId))
}

private def appendConsumerOffsetCommit(buffer: ByteBuffer, baseOffset: Long, offsets: Map[TopicPartition, Long]) = {
val builder = MemoryRecords.builder(buffer, CompressionType.NONE, TimestampType.LOG_APPEND_TIME, baseOffset)
val commitRecords = createCommittedOffsetRecords(offsets)
Expand Down