private LinkedHashMap<String, Object> asJSON(LockInfo lockInfo) { LinkedHashMap<String, Object> lockedOn = new LinkedHashMap<>(); if (lockInfo != null) { lockedOn.put("Class", lockInfo.getClassName()); lockedOn.put("IdentityHashCode", lockInfo.getIdentityHashCode()); } return lockedOn; }
/** * Create data transfer object for given lock info. * * @param li Lock info. */ public VisorThreadLockInfo(LockInfo li) { assert li != null; clsName = li.getClassName(); identityHashCode = li.getIdentityHashCode(); }
private void printLock( StringBuilder sb, LockInfo lock ) { sb.append('<').append(Integer.toHexString(lock.getIdentityHashCode())).append("> (a ").append(lock.getClassName()).append(')'); }
private void printLock( StringBuilder sb, LockInfo lock ) { sb.append('<').append(Integer.toHexString(lock.getIdentityHashCode())).append("> (a ").append(lock.getClassName()).append(')'); }
private void printLock( StringBuilder sb, LockInfo lock ) { sb.append('<').append(Integer.toHexString(lock.getIdentityHashCode())).append("> (a ").append(lock.getClassName()).append(')'); }
private void printLock( StringBuilder sb, LockInfo lock ) { sb.append('<').append(Integer.toHexString(lock.getIdentityHashCode())).append("> (a ").append(lock.getClassName()).append(')'); }
private void printLock( StringBuilder sb, LockInfo lock ) { sb.append('<').append(Integer.toHexString(lock.getIdentityHashCode())).append("> (a ").append(lock.getClassName()).append(')'); }
private String generateThreadStack(ThreadInfo info) { // This is annoying, but the to string method on info sucks. StringBuilder result = new StringBuilder(); result.append(info.getThreadName()).append(" ID=0x") .append(Long.toHexString(info.getThreadId())).append("(").append(info.getThreadId()) .append(") state=").append(info.getThreadState()); if (info.getLockInfo() != null) { result.append("\n\twaiting to lock <" + info.getLockInfo() + ">"); } for (StackTraceElement element : info.getStackTrace()) { result.append("\n\tat " + element); for (MonitorInfo monitor : info.getLockedMonitors()) { if (element.equals(monitor.getLockedStackFrame())) { result.append("\n\tlocked <" + monitor + ">"); } } } if (info.getLockedSynchronizers().length > 0) { result.append("\nLocked synchronizers:"); for (LockInfo sync : info.getLockedSynchronizers()) { result.append( "\n" + sync.getClassName() + "@" + Integer.toHexString(sync.getIdentityHashCode())); } } return result.toString(); }
public LocalLockInfo(Serializable locatility, LockInfo sync) { super(); this.locatility = locatility; // LockInfo and Monitor info aren't serializable, so copy the information from // them. For backwards compatibility, use the LI class which is used // in older versions of gemfire. if (sync instanceof MonitorInfo) { this.info = new LI(sync.getClassName(), sync.getIdentityHashCode(), ((MonitorInfo) sync).getLockedStackFrame()); } else { this.info = new LI(sync.getClassName(), sync.getIdentityHashCode()); } }
final LockInfo lock = tt.getLockInfo(); if (lock != null && state != Thread.State.BLOCKED) { out.printf("%n - waiting on <0x%08x> (a %s)", lock.getIdentityHashCode(), lock.getClassName()); out.printf("%n - locked <0x%08x> (a %s)", lock.getIdentityHashCode(), lock.getClassName()); } else if (lock != null && state == Thread.State.BLOCKED) { out.printf("%n - waiting to lock <0x%08x> (a %s)", lock.getIdentityHashCode(), lock.getClassName());
if (lock != null && t.getThreadState() != Thread.State.BLOCKED) { writer.printf("%n - waiting on <0x%08x> (a %s)", lock.getIdentityHashCode(), lock.getClassName()); writer.printf("%n - locked <0x%08x> (a %s)", lock.getIdentityHashCode(), lock.getClassName()); } else if (lock != null && t.getThreadState() == Thread.State.BLOCKED) { writer.printf("%n - waiting to lock <0x%08x> (a %s)", lock.getIdentityHashCode(), lock.getClassName());
if (lockInfo != null) { builder.setLockInfo(ThreadDump.LockInfo.newBuilder() .setIdentityHashCode(lockInfo.getIdentityHashCode()) .setClassName(lockInfo.getClassName())); long lockOwnerId = threadInfo.getLockOwnerId();
@Override public void printLock(StringBuilder sb, LockInfo lock) { String id = Integer.toHexString(lock.getIdentityHashCode()); String className = lock.getClassName(); sb.append("<" + id + "> (a " + className + ")"); // NOI18N }
private static ModelNode getDetypedLockInfo(final LockInfo lockInfo) { final ModelNode result = new ModelNode(); if (lockInfo != null) { result.get(PlatformMBeanConstants.CLASS_NAME).set(lockInfo.getClassName()); result.get(PlatformMBeanConstants.IDENTITY_HASH_CODE).set(lockInfo.getIdentityHashCode()); } return result; }
private static ModelNode getDetypedLockInfo(final LockInfo lockInfo) { final ModelNode result = new ModelNode(); if (lockInfo != null) { result.get(PlatformMBeanConstants.CLASS_NAME).set(lockInfo.getClassName()); result.get(PlatformMBeanConstants.IDENTITY_HASH_CODE).set(lockInfo.getIdentityHashCode()); } return result; }
public static long getMonitorOwner(Object obj) { if (Thread.holdsLock(obj)) return Thread.currentThread().getId(); for (java.lang.management.ThreadInfo ti : java.lang.management.ManagementFactory.getThreadMXBean() .dumpAllThreads(true, false)) { for (java.lang.management.MonitorInfo mi : ti.getLockedMonitors()) { if (mi.getIdentityHashCode() == System.identityHashCode(obj)) { return ti.getThreadId(); } } } return 0; }
private void printLock(StringBuilder sb,LockInfo lock) { String id = Integer.toHexString(lock.getIdentityHashCode()); String className = lock.getClassName(); sb.append("<").append(id).append("> (a ").append(className).append(")"); // NOI18N }
for (ThreadInfo info : infos) { LockInfo lockInfo = info.getLockInfo(); if (lockInfo != null && lockInfo.getClassName().equals(lock.getClass().getName()) && lockInfo.getIdentityHashCode() == System.identityHashCode(lock)) { System.out.println("Thread waiting on " + lock + " : " + info.getThreadName()); } }
/** Create data transfer object for given lock info. */ public static VisorThreadLockInfo from(LockInfo li) { assert li != null; return new VisorThreadLockInfo(li.getClassName(), li.getIdentityHashCode()); }
protected void printDeadlockedThreadInfo(ThreadWriter threadWriter, ThreadInfo info) { threadWriter.println("\"{0}\":", new Object[] { info.getThreadName() }); threadWriter.println(" waiting to lock monitor {0} (object {1}, a {2}),", new Object[] { "7f8a5595d180" /* ? */, Integer.toHexString(info.getLockInfo().getIdentityHashCode()), info.getLockInfo().getClassName() }); threadWriter.println(" which is held by \"{0}\"", new Object[] { info.getLockOwnerName() }); }