use of org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.SharedPageLockTracker in project ignite by apache.
the class ToStringDumpHelperTest method toStringSharedPageLockTrackerTest.
/**
*/
@Test
public void toStringSharedPageLockTrackerTest() throws Exception {
SharedPageLockTracker pageLockTracker = new SharedPageLockTracker();
PageLockListener tracker = pageLockTracker.registerStructure("dummy");
tracker.onReadLock(1, 2, 3, 4);
tracker.onReadUnlock(1, 2, 3, 4);
Thread asyncLockUnlock = new Thread(() -> tracker.onReadLock(4, 32, 1, 64), "async-lock-unlock");
asyncLockUnlock.start();
asyncLockUnlock.join();
long threadIdInLog = asyncLockUnlock.getId();
SharedPageLockTrackerDump pageLockDump = pageLockTracker.dump();
// Hack to have same timestamp in test.
for (ThreadPageLockState state : pageLockDump.threadPageLockStates) GridTestUtils.setFieldValue(state.pageLockDump, PageLockDump.class, "time", TIME);
assertNotNull(pageLockDump);
String dumpStr = ToStringDumpHelper.toStringDump(pageLockDump);
String expectedLog = "Page locks dump:" + U.nl() + U.nl() + "Thread=[name=async-lock-unlock, id=" + threadIdInLog + "], state=TERMINATED" + U.nl() + "Locked pages = [32[0000000000000020](r=1|w=0)]" + U.nl() + "Locked pages log: name=async-lock-unlock time=(1596173397167, " + ToStringDumpHelper.DATE_FMT.format(Instant.ofEpochMilli(TIME)) + ")" + U.nl() + "L=1 -> Read lock pageId=32, structureId=dummy [pageIdHex=0000000000000020, partId=0, pageIdx=32, flags=00000000]" + U.nl() + U.nl() + U.nl() + U.nl();
assertEquals(expectedLog, dumpStr);
}
use of org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.SharedPageLockTracker in project ignite by apache.
the class ToFileDumpProcessorTest method toFileDump.
/**
*/
@Test
public void toFileDump() throws Exception {
Path homeDir = Paths.get(U.defaultWorkDirectory());
System.out.println("IGNITE_HOME:" + homeDir);
SharedPageLockTracker pageLockTracker = new SharedPageLockTracker();
try (PageLockListener tracker = pageLockTracker.registerStructure("dummy")) {
tracker.onBeforeReadLock(1, 2, 3);
tracker.onReadLock(1, 2, 3, 4);
}
SharedPageLockTrackerDump pageLockDump = pageLockTracker.dump();
assertNotNull(pageLockDump);
file = Paths.get(ToFileDumpProcessor.toFileDump(pageLockDump, homeDir, "test"));
System.out.println("Dump saved:" + file);
try (Stream<Path> stream = Files.list(homeDir)) {
assertTrue(stream.map(Path::toAbsolutePath).anyMatch(file::equals));
}
String actDumpStr = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
assertEquals(ToStringDumpHelper.toStringDump(pageLockDump), actDumpStr);
}
Aggregations