-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for different thread dump (closes #5)
- Loading branch information
Showing
19 changed files
with
475 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dev.oblac.tdv.app | ||
|
||
import dev.oblac.tdv.analyzer.ThreadDumpAnalysis | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.Test | ||
|
||
class AppTest0005 { | ||
|
||
companion object { | ||
private lateinit var tda: ThreadDumpAnalysis | ||
@BeforeAll | ||
@JvmStatic | ||
fun setup() { | ||
tda = process("../issues/0005-tdump.txt.gz") | ||
} | ||
} | ||
|
||
@Test | ||
fun testStats() { | ||
assertEquals(54, tda.stats.all.totalThreads) | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
parser/src/main/kotlin/dev/oblac/tdv/parser/SkipToThreads.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dev.oblac.tdv.parser | ||
|
||
/** | ||
* The whole purpose of this function is to skip | ||
* the bunch of lines that are not related to threads. | ||
*/ | ||
internal object SkipToThreads : (ThreadDumpIterator) -> Unit { | ||
override fun invoke(tdi: ThreadDumpIterator) { | ||
tdi.skipEmptyLines() | ||
|
||
// Try if the there is no headers | ||
if (AppHeader.parse(tdi.peek(), tdi).isSuccess) { | ||
return | ||
} | ||
|
||
// we want to skip all kind of header lines | ||
tdi.skipNonEmptyLines() | ||
tdi.skipEmptyLines() | ||
|
||
// skip all SMR info | ||
tdi.peek().let { | ||
if (it == "Threads class SMR info:") { | ||
skipSMR(tdi) | ||
} | ||
} | ||
|
||
tdi.skipEmptyLines() | ||
} | ||
|
||
private fun skipSMR(tdi: ThreadDumpIterator) { | ||
fun detectSmr(line: String): Boolean { | ||
return line.startsWith("_java_thread_list=") | ||
|| line.startsWith("_to_delete_list=") | ||
|| line.startsWith("next-> ") | ||
} | ||
tdi.skip() | ||
|
||
while (true) { | ||
val nextLine = tdi.peek() | ||
if (!detectSmr(nextLine)) { | ||
break | ||
} | ||
tdi.skipUntilMatch("}") | ||
tdi.skip() | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.