Java Code Examples for java.lang.management.LockInfo

The following are top voted examples for showing how to use java.lang.management.LockInfo. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: terracotta-platform   File: DiagnosticUtility.java   Source Code and License 6 votes vote down vote up
private static String threadLockedSynchronizers(ThreadInfo threadInfo) {
  final String NO_SYNCH_INFO = "no locked synchronizers information available\n";
  if (null == threadInfo) { return NO_SYNCH_INFO; }
  try {
    final LockInfo[] lockInfos = threadInfo.getLockedSynchronizers();
    if (lockInfos.length > 0) {
      final StringBuffer lockedSynchBuff = new StringBuffer();
      lockedSynchBuff.append("\nLocked Synchronizers: \n");
      for (final LockInfo lockInfo : lockInfos) {
        lockedSynchBuff.append(lockInfo.getClassName()).append(" <").append(lockInfo.getIdentityHashCode())
            .append("> \n");
      }
      return lockedSynchBuff.append("\n").toString();
    } else {
      return "";
    }
  } catch (final Exception e) {
    return NO_SYNCH_INFO;
  }
}
 
Example 2
Project: SwiftCloud   File: DCDataServer.java   Source Code and License 6 votes vote down vote up
private void initData(Properties props) {
    this.db = new HashMap<String, Map<String, CRDTData<?>>>();
    this.locks = new HashMap<CRDTIdentifier, LockInfo>();
    // this.notifications = new LinkedList<NotificationRecord>();
    this.modified = new HashSet<CRDTData<?>>();

    this.version = ClockFactory.newClock();
    this.cltClock = ClockFactory.newClock();

    initDB(props);

    if (dbServer.ramOnly()) {

        CRDTIdentifier id = new CRDTIdentifier("e", "1");
        ManagedCRDT<IntegerCRDT> i = new ManagedCRDT<IntegerCRDT>(id, new IntegerCRDT(id), version.clone(), true);
        localPutCRDT(i);

        CRDTIdentifier id2 = new CRDTIdentifier("e", "2");
        ManagedCRDT<IntegerCRDT> i2 = new ManagedCRDT<IntegerCRDT>(id2, new IntegerCRDT(id2), version.clone(), true);
        localPutCRDT(i2);
    }
}
 
Example 3
Project: pinpoint   File: ThreadDumpUtils.java   Source Code and License 6 votes vote down vote up
private static void setLockInfo(TThreadDump threadDump, ThreadInfo threadInfo) {
    threadDump.setLockName(threadInfo.getLockName());
    threadDump.setLockOwnerId(threadInfo.getLockOwnerId());
    threadDump.setLockOwnerName(threadInfo.getLockOwnerName());

    LockInfo[] lockInfos = threadInfo.getLockedSynchronizers();

    if (lockInfos != null) {
        for (LockInfo lockInfo : lockInfos) {
            if (lockInfo == null) {
                continue;
            }
            threadDump.addToLockedSynchronizers(lockInfo.toString());
        }
    } else {
        threadDump.setLockedSynchronizers(Collections.<String>emptyList());
    }
}
 
Example 4
Project: dumpling   File: JmxRuntimeFactory.java   Source Code and License 6 votes vote down vote up
private @Nonnull JmxRuntime extractRuntime(@Nonnull MBeanServerConnection connection) {
    final List<ThreadInfo> threads = getRemoteThreads(connection);
    HashSet<JmxThread.Builder> builders = new HashSet<JmxThread.Builder>(threads.size());

    for (ThreadInfo thread: threads) {
        JmxThread.Builder builder = new JmxThread.Builder();
        final ThreadStatus status = fillThreadInfoData(thread, builder);

        final LockInfo lockInfo = thread.getLockInfo();
        if (lockInfo != null) {
            builder.setWaitingToLock(getSynchronizer(lockInfo));
        }

        builders.add(builder);
    }

    return new JmxRuntime(builders, new Date(), getVmName(connection));
}
 
Example 5
Project: utilsj   File: ThreadDumperJdk16.java   Source Code and License 6 votes vote down vote up
@Override
void outputWaitingInfo(ThreadInfo info, ExtraLockInfo exLockInfo, StringBuffer buffer) {
    final LockInfo lock_info = info.getLockInfo();
    if (lock_info != null)
    {
        formatLock(lock_info, "waiting on", buffer);
        if (exLockInfo != null)
        {
            if (exLockInfo.isWaitingFor(ExtraLockInfo.WaitingFor.WRITE, lock_info))
                buffer.append(" for write");
            if (exLockInfo.isWaitingFor(ExtraLockInfo.WaitingFor.READ, lock_info))
                buffer.append(" for read");
        }
        buffer.append(".");
        long lock_owner = info.getLockOwnerId();
        if (lock_owner!=-1)
        {
            buffer.append(" Locked by \"");
            buffer.append(info.getLockOwnerName());
            buffer.append("\" tid=");
            buffer.append(lock_owner);
        }
        buffer.append("\n");
    }
}
 
Example 6
Project: incubator-netbeans   File: NbTestCase.java   Source Code and License 5 votes vote down vote up
private static void printLockInfo(LockInfo[] locks, StringBuilder sb) {
    sb.append("\tLocked synchronizers: count = " + locks.length).append("\n");
    for (LockInfo li : locks) {
        sb.append("\t  - " + li).append("\n");
    }
    sb.append("\n");
}
 
Example 7
Project: incubator-netbeans   File: Detector.java   Source Code and License 5 votes vote down vote up
private void printLockInfo(LockInfo[] locks, PrintStream out) {
   out.println(INDENT + "Locked synchronizers: count = " + locks.length); // NOI18N
   for (LockInfo li : locks) {
       out.println(INDENT + "  - " + li); // NOI18N
   }
   out.println();
}
 
Example 8
Project: hadoop-oss   File: TimedOutTestsListener.java   Source Code and License 5 votes vote down vote up
private static void printLockInfo(LockInfo[] locks, PrintWriter out) {
  out.println(INDENT + "Locked synchronizers: count = " + locks.length);
  for (LockInfo li : locks) {
    out.println(INDENT + "  - " + li);
  }
  out.println();
}
 
Example 9
Project: OpenJSharp   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
/**
 * Prints the thread dump information with locks info to System.out.
 */
private void dumpThreadInfoWithLocks() {
   System.out.println("Full Java thread dump with locks info");

   ThreadInfo[] tinfos = tmbean.dumpAllThreads(true, true);
   for (ThreadInfo ti : tinfos) {
       printThreadInfo(ti);
       LockInfo[] syncs = ti.getLockedSynchronizers();
       printLockInfo(syncs);
   }
   System.out.println();
}
 
Example 10
Project: OpenJSharp   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
private void printLockInfo(LockInfo[] locks) {
   System.out.println(INDENT + "Locked synchronizers: count = " + locks.length);
   for (LockInfo li : locks) {
       System.out.println(INDENT + "  - " + li);
   }
   System.out.println();
}
 
Example 11
Project: OpenJSharp   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static CompositeData toCompositeData(LockInfo li) {
    if (li == null) {
        return null;
    }

    LockInfoCompositeData licd = new LockInfoCompositeData(li);
    return licd.getCompositeData();
}
 
Example 12
Project: OpenJSharp   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static LockInfo toLockInfo(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) {
        throw new IllegalArgumentException(
            "Unexpected composite type for LockInfo");
    }

    String className = getString(cd, CLASS_NAME);
    int identityHashCode = getInt(cd, IDENTITY_HASH_CODE);
    return new LockInfo(className, identityHashCode);
}
 
Example 13
Project: OpenJSharp   File: MappedMXBeanType.java   Source Code and License 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example 14
Project: OpenJSharp   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public LockInfo[] lockedSynchronizers() {
    CompositeData[] lockedSyncsData =
        (CompositeData[]) cdata.get(LOCKED_SYNCS);

    // The LockedSynchronizers item cannot be null, but if it is we will
    // get a NullPointerException when we ask for its length.
    LockInfo[] locks = new LockInfo[lockedSyncsData.length];
    for (int i = 0; i < lockedSyncsData.length; i++) {
        CompositeData cdi = lockedSyncsData[i];
        locks[i] = LockInfo.from(cdi);
    }
    return locks;
}
 
Example 15
Project: monarch   File: LocalThread.java   Source Code and License 5 votes vote down vote up
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();
}
 
Example 16
Project: monarch   File: LocalLockInfo.java   Source Code and License 5 votes vote down vote up
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());
  }
}
 
Example 17
Project: hadoop   File: TimedOutTestsListener.java   Source Code and License 5 votes vote down vote up
private static void printLockInfo(LockInfo[] locks, PrintWriter out) {
  out.println(INDENT + "Locked synchronizers: count = " + locks.length);
  for (LockInfo li : locks) {
    out.println(INDENT + "  - " + li);
  }
  out.println();
}
 
Example 18
Project: jdk8u-jdk   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
/**
 * Prints the thread dump information with locks info to System.out.
 */
private void dumpThreadInfoWithLocks() {
   System.out.println("Full Java thread dump with locks info");

   ThreadInfo[] tinfos = tmbean.dumpAllThreads(true, true);
   for (ThreadInfo ti : tinfos) {
       printThreadInfo(ti);
       LockInfo[] syncs = ti.getLockedSynchronizers();
       printLockInfo(syncs);
   }
   System.out.println();
}
 
Example 19
Project: jdk8u-jdk   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
private void printLockInfo(LockInfo[] locks) {
   System.out.println(INDENT + "Locked synchronizers: count = " + locks.length);
   for (LockInfo li : locks) {
       System.out.println(INDENT + "  - " + li);
   }
   System.out.println();
}
 
Example 20
Project: jdk8u-jdk   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static CompositeData toCompositeData(LockInfo li) {
    if (li == null) {
        return null;
    }

    LockInfoCompositeData licd = new LockInfoCompositeData(li);
    return licd.getCompositeData();
}
 
Example 21
Project: jdk8u-jdk   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static LockInfo toLockInfo(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) {
        throw new IllegalArgumentException(
            "Unexpected composite type for LockInfo");
    }

    String className = getString(cd, CLASS_NAME);
    int identityHashCode = getInt(cd, IDENTITY_HASH_CODE);
    return new LockInfo(className, identityHashCode);
}
 
Example 22
Project: jdk8u-jdk   File: MappedMXBeanType.java   Source Code and License 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example 23
Project: jdk8u-jdk   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public LockInfo[] lockedSynchronizers() {
    CompositeData[] lockedSyncsData =
        (CompositeData[]) cdata.get(LOCKED_SYNCS);

    // The LockedSynchronizers item cannot be null, but if it is we will
    // get a NullPointerException when we ask for its length.
    LockInfo[] locks = new LockInfo[lockedSyncsData.length];
    for (int i = 0; i < lockedSyncsData.length; i++) {
        CompositeData cdi = lockedSyncsData[i];
        locks[i] = LockInfo.from(cdi);
    }
    return locks;
}
 
Example 24
Project: jdk8u-jdk   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
private static void checkLockInfo(LockInfo li)
    throws Exception {
    if (!li.getClassName().equals(lockInfo.getClassName())) {
        throw new RuntimeException("Class Name = " +
            li.getClassName() + " expected = " + lockInfo.getClassName());
    }
    if (li.getIdentityHashCode() != lockInfo.getIdentityHashCode()) {
        throw new RuntimeException("Class Name = " +
            li.getIdentityHashCode() + " expected = " +
            lockInfo.getIdentityHashCode());
    }
}
 
Example 25
Project: openjdk-jdk10   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static CompositeData toCompositeData(LockInfo li) {
    if (li == null) {
        return null;
    }

    LockInfoCompositeData licd = new LockInfoCompositeData(li);
    return licd.getCompositeData();
}
 
Example 26
Project: openjdk-jdk10   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static LockInfo toLockInfo(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) {
        throw new IllegalArgumentException(
            "Unexpected composite type for LockInfo");
    }

    String className = getString(cd, CLASS_NAME);
    int identityHashCode = getInt(cd, IDENTITY_HASH_CODE);
    return new LockInfo(className, identityHashCode);
}
 
Example 27
Project: openjdk-jdk10   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public LockInfo[] lockedSynchronizers() {
    CompositeData[] lockedSyncsData =
        (CompositeData[]) cdata.get(LOCKED_SYNCS);

    // The LockedSynchronizers item cannot be null, but if it is we will
    // get a NullPointerException when we ask for its length.
    LockInfo[] locks = new LockInfo[lockedSyncsData.length];
    for (int i = 0; i < lockedSyncsData.length; i++) {
        CompositeData cdi = lockedSyncsData[i];
        locks[i] = LockInfo.from(cdi);
    }
    return locks;
}
 
Example 28
Project: openjdk-jdk10   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
private static void checkLockInfo(LockInfo li)
    throws Exception {
    if (!li.getClassName().equals(lockInfo.getClassName())) {
        throw new RuntimeException("Class Name = " +
            li.getClassName() + " expected = " + lockInfo.getClassName());
    }
    if (li.getIdentityHashCode() != lockInfo.getIdentityHashCode()) {
        throw new RuntimeException("Class Name = " +
            li.getIdentityHashCode() + " expected = " +
            lockInfo.getIdentityHashCode());
    }
}
 
Example 29
Project: lazycat   File: Diagnostics.java   Source Code and License 5 votes vote down vote up
/**
 * Formats the thread dump for one thread.
 *
 * @param ti
 *            the ThreadInfo describing the thread
 * @return the formatted thread dump
 */
private static String getThreadDump(ThreadInfo ti) {
	StringBuilder sb = new StringBuilder(getThreadDumpHeader(ti));
	for (LockInfo li : ti.getLockedSynchronizers()) {
		sb.append(INDENT2 + "locks " + li.toString() + CRLF);
	}
	boolean start = true;
	StackTraceElement[] stes = ti.getStackTrace();
	Object[] monitorDepths = new Object[stes.length];
	MonitorInfo[] mis = ti.getLockedMonitors();
	for (int i = 0; i < mis.length; i++) {
		monitorDepths[mis[i].getLockedStackDepth()] = mis[i];
	}
	for (int i = 0; i < stes.length; i++) {
		StackTraceElement ste = stes[i];
		sb.append(INDENT2 + "at " + ste.toString() + CRLF);
		if (start) {
			if (ti.getLockName() != null) {
				sb.append(INDENT2 + "- waiting on (a " + ti.getLockName() + ")");
				if (ti.getLockOwnerName() != null) {
					sb.append(" owned by " + ti.getLockOwnerName() + " Id=" + ti.getLockOwnerId());
				}
				sb.append(CRLF);
			}
			start = false;
		}
		if (monitorDepths[i] != null) {
			MonitorInfo mi = (MonitorInfo) monitorDepths[i];
			sb.append(INDENT2 + "- locked (a " + mi.toString() + ")" + " index " + mi.getLockedStackDepth()
					+ " frame " + mi.getLockedStackFrame().toString());
			sb.append(CRLF);

		}
	}
	return sb.toString();
}
 
Example 30
Project: ditb   File: TimedOutTestsListener.java   Source Code and License 5 votes vote down vote up
private static void printLockInfo(LockInfo[] locks, PrintWriter out) {
  out.println(INDENT + "Locked synchronizers: count = " + locks.length);
  for (LockInfo li : locks) {
    out.println(INDENT + "  - " + li);
  }
  out.println();
}
 
Example 31
Project: openjdk9   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
/**
 * Prints the thread dump information with locks info to System.out.
 */
private void dumpThreadInfoWithLocks() {
   System.out.println("Full Java thread dump with locks info");

   ThreadInfo[] tinfos = tmbean.dumpAllThreads(true, true);
   for (ThreadInfo ti : tinfos) {
       printThreadInfo(ti);
       LockInfo[] syncs = ti.getLockedSynchronizers();
       printLockInfo(syncs);
   }
   System.out.println();
}
 
Example 32
Project: openjdk9   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
private void printLockInfo(LockInfo[] locks) {
   System.out.println(INDENT + "Locked synchronizers: count = " + locks.length);
   for (LockInfo li : locks) {
       System.out.println(INDENT + "  - " + li);
   }
   System.out.println();
}
 
Example 33
Project: openjdk9   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static CompositeData toCompositeData(LockInfo li) {
    if (li == null) {
        return null;
    }

    LockInfoCompositeData licd = new LockInfoCompositeData(li);
    return licd.getCompositeData();
}
 
Example 34
Project: openjdk9   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static LockInfo toLockInfo(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) {
        throw new IllegalArgumentException(
            "Unexpected composite type for LockInfo");
    }

    String className = getString(cd, CLASS_NAME);
    int identityHashCode = getInt(cd, IDENTITY_HASH_CODE);
    return new LockInfo(className, identityHashCode);
}
 
Example 35
Project: openjdk9   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public LockInfo[] lockedSynchronizers() {
    CompositeData[] lockedSyncsData =
        (CompositeData[]) cdata.get(LOCKED_SYNCS);

    // The LockedSynchronizers item cannot be null, but if it is we will
    // get a NullPointerException when we ask for its length.
    LockInfo[] locks = new LockInfo[lockedSyncsData.length];
    for (int i = 0; i < lockedSyncsData.length; i++) {
        CompositeData cdi = lockedSyncsData[i];
        locks[i] = LockInfo.from(cdi);
    }
    return locks;
}
 
Example 36
Project: openjdk9   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
private static void checkLockInfo(LockInfo li)
    throws Exception {
    if (!li.getClassName().equals(lockInfo.getClassName())) {
        throw new RuntimeException("Class Name = " +
            li.getClassName() + " expected = " + lockInfo.getClassName());
    }
    if (li.getIdentityHashCode() != lockInfo.getIdentityHashCode()) {
        throw new RuntimeException("Class Name = " +
            li.getIdentityHashCode() + " expected = " +
            lockInfo.getIdentityHashCode());
    }
}
 
Example 37
Project: aliyun-oss-hadoop-fs   File: TimedOutTestsListener.java   Source Code and License 5 votes vote down vote up
private static void printLockInfo(LockInfo[] locks, PrintWriter out) {
  out.println(INDENT + "Locked synchronizers: count = " + locks.length);
  for (LockInfo li : locks) {
    out.println(INDENT + "  - " + li);
  }
  out.println();
}
 
Example 38
Project: FPAgar   File: StatsUtils.java   Source Code and License 5 votes vote down vote up
public static CharSequence getThreadStats(boolean lockedMonitors, boolean lockedSynchronizers, boolean stackTrace)
{
	StringBuilder list = new StringBuilder();

	for(ThreadInfo info : threadMXbean.dumpAllThreads(lockedMonitors, lockedSynchronizers))
	{
		list.append("Thread #").append(info.getThreadId()).append(" (").append(info.getThreadName()).append(")").append("\n");
		list.append("=================================================\n");
		list.append("\tgetThreadState: ...... ").append(info.getThreadState()).append("\n");
		for(MonitorInfo monitorInfo : info.getLockedMonitors())
		{
			list.append("\tLocked monitor: ....... ").append(monitorInfo).append("\n");
			list.append("\t\t[").append(monitorInfo.getLockedStackDepth()).append(".]: at ").append(monitorInfo.getLockedStackFrame()).append("\n");
		}

		for(LockInfo lockInfo : info.getLockedSynchronizers())
			list.append("\tLocked synchronizer: ...").append(lockInfo).append("\n");

		if(stackTrace)
		{
			list.append("\tgetStackTace: ..........\n");
			for(StackTraceElement trace : info.getStackTrace())
				list.append("\t\tat ").append(trace).append("\n");
		}
		list.append("=================================================\n");
	}

	return list;
}
 
Example 39
Project: gemfirexd-oss   File: CF6Impl.java   Source Code and License 5 votes vote down vote up
@Override
public LI[] getLockedSynchronizers(ThreadInfo info) {
  LockInfo[] monitors = info.getLockedSynchronizers();
  if(monitors == null) {
    return null;
  }
  LI[] results = new LI[monitors.length];
  for(int i = 0; i < monitors.length; i++) {
    results[i] = new LI(monitors[i].getClassName(), monitors[i].getIdentityHashCode());
  }
  return results;
}
 
Example 40
Project: gemfirexd-oss   File: CF6Impl.java   Source Code and License 5 votes vote down vote up
@Override
public LI getLockInfo(ThreadInfo threadInfo) {
  LockInfo lockInfo= threadInfo.getLockInfo();
  if(lockInfo == null) {
    return null;
  }
  
  return new LI(lockInfo.getClassName(), lockInfo.getIdentityHashCode());
}
 
Example 41
Project: big-c   File: TimedOutTestsListener.java   Source Code and License 5 votes vote down vote up
private static void printLockInfo(LockInfo[] locks, PrintWriter out) {
  out.println(INDENT + "Locked synchronizers: count = " + locks.length);
  for (LockInfo li : locks) {
    out.println(INDENT + "  - " + li);
  }
  out.println();
}
 
Example 42
Project: jdk8u_jdk   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
/**
 * Prints the thread dump information with locks info to System.out.
 */
private void dumpThreadInfoWithLocks() {
   System.out.println("Full Java thread dump with locks info");

   ThreadInfo[] tinfos = tmbean.dumpAllThreads(true, true);
   for (ThreadInfo ti : tinfos) {
       printThreadInfo(ti);
       LockInfo[] syncs = ti.getLockedSynchronizers();
       printLockInfo(syncs);
   }
   System.out.println();
}
 
Example 43
Project: jdk8u_jdk   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
private void printLockInfo(LockInfo[] locks) {
   System.out.println(INDENT + "Locked synchronizers: count = " + locks.length);
   for (LockInfo li : locks) {
       System.out.println(INDENT + "  - " + li);
   }
   System.out.println();
}
 
Example 44
Project: jdk8u_jdk   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static CompositeData toCompositeData(LockInfo li) {
    if (li == null) {
        return null;
    }

    LockInfoCompositeData licd = new LockInfoCompositeData(li);
    return licd.getCompositeData();
}
 
Example 45
Project: jdk8u_jdk   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static LockInfo toLockInfo(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) {
        throw new IllegalArgumentException(
            "Unexpected composite type for LockInfo");
    }

    String className = getString(cd, CLASS_NAME);
    int identityHashCode = getInt(cd, IDENTITY_HASH_CODE);
    return new LockInfo(className, identityHashCode);
}
 
Example 46
Project: jdk8u_jdk   File: MappedMXBeanType.java   Source Code and License 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example 47
Project: jdk8u_jdk   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public LockInfo[] lockedSynchronizers() {
    CompositeData[] lockedSyncsData =
        (CompositeData[]) cdata.get(LOCKED_SYNCS);

    // The LockedSynchronizers item cannot be null, but if it is we will
    // get a NullPointerException when we ask for its length.
    LockInfo[] locks = new LockInfo[lockedSyncsData.length];
    for (int i = 0; i < lockedSyncsData.length; i++) {
        CompositeData cdi = lockedSyncsData[i];
        locks[i] = LockInfo.from(cdi);
    }
    return locks;
}
 
Example 48
Project: jdk8u_jdk   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
private static void checkLockInfo(LockInfo li)
    throws Exception {
    if (!li.getClassName().equals(lockInfo.getClassName())) {
        throw new RuntimeException("Class Name = " +
            li.getClassName() + " expected = " + lockInfo.getClassName());
    }
    if (li.getIdentityHashCode() != lockInfo.getIdentityHashCode()) {
        throw new RuntimeException("Class Name = " +
            li.getIdentityHashCode() + " expected = " +
            lockInfo.getIdentityHashCode());
    }
}
 
Example 49
Project: lookaside_java-1.8.0-openjdk   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
/**
 * Prints the thread dump information with locks info to System.out.
 */
private void dumpThreadInfoWithLocks() {
   System.out.println("Full Java thread dump with locks info");

   ThreadInfo[] tinfos = tmbean.dumpAllThreads(true, true);
   for (ThreadInfo ti : tinfos) {
       printThreadInfo(ti);
       LockInfo[] syncs = ti.getLockedSynchronizers();
       printLockInfo(syncs);
   }
   System.out.println();
}
 
Example 50
Project: lookaside_java-1.8.0-openjdk   File: ThreadMonitor.java   Source Code and License 5 votes vote down vote up
private void printLockInfo(LockInfo[] locks) {
   System.out.println(INDENT + "Locked synchronizers: count = " + locks.length);
   for (LockInfo li : locks) {
       System.out.println(INDENT + "  - " + li);
   }
   System.out.println();
}
 
Example 51
Project: lookaside_java-1.8.0-openjdk   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static CompositeData toCompositeData(LockInfo li) {
    if (li == null) {
        return null;
    }

    LockInfoCompositeData licd = new LockInfoCompositeData(li);
    return licd.getCompositeData();
}
 
Example 52
Project: lookaside_java-1.8.0-openjdk   File: LockInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public static LockInfo toLockInfo(CompositeData cd) {
    if (cd == null) {
        throw new NullPointerException("Null CompositeData");
    }

    if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) {
        throw new IllegalArgumentException(
            "Unexpected composite type for LockInfo");
    }

    String className = getString(cd, CLASS_NAME);
    int identityHashCode = getInt(cd, IDENTITY_HASH_CODE);
    return new LockInfo(className, identityHashCode);
}
 
Example 53
Project: lookaside_java-1.8.0-openjdk   File: MappedMXBeanType.java   Source Code and License 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example 54
Project: lookaside_java-1.8.0-openjdk   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
public LockInfo[] lockedSynchronizers() {
    CompositeData[] lockedSyncsData =
        (CompositeData[]) cdata.get(LOCKED_SYNCS);

    // The LockedSynchronizers item cannot be null, but if it is we will
    // get a NullPointerException when we ask for its length.
    LockInfo[] locks = new LockInfo[lockedSyncsData.length];
    for (int i = 0; i < lockedSyncsData.length; i++) {
        CompositeData cdi = lockedSyncsData[i];
        locks[i] = LockInfo.from(cdi);
    }
    return locks;
}
 
Example 55
Project: lookaside_java-1.8.0-openjdk   File: ThreadInfoCompositeData.java   Source Code and License 5 votes vote down vote up
private static void checkLockInfo(LockInfo li)
    throws Exception {
    if (!li.getClassName().equals(lockInfo.getClassName())) {
        throw new RuntimeException("Class Name = " +
            li.getClassName() + " expected = " + lockInfo.getClassName());
    }
    if (li.getIdentityHashCode() != lockInfo.getIdentityHashCode()) {
        throw new RuntimeException("Class Name = " +
            li.getIdentityHashCode() + " expected = " +
            lockInfo.getIdentityHashCode());
    }
}
 
Example 56
Project: javaee-actuator   File: DumpResource.java   Source Code and License 5 votes vote down vote up
private JsonArrayBuilder buildLockedSynchronizers(LockInfo[] lockedSynchronizers) {
    JsonArrayBuilder lockedSynchronizersArrayJson = Json.createArrayBuilder();
    for (LockInfo lockedSynchronizer : lockedSynchronizers) {
        JsonObjectBuilder lockedSynchronizerJson = Json.createObjectBuilder();
        lockedSynchronizerJson.add("className", nullSafe(lockedSynchronizer.getClassName()))
                .add("identityHashCode", lockedSynchronizer.getIdentityHashCode());
        lockedSynchronizersArrayJson.add(lockedSynchronizerJson);
    }
    return lockedSynchronizersArrayJson;
}
 
Example 57
Project: javaee-actuator   File: DumpResource.java   Source Code and License 5 votes vote down vote up
private JsonObjectBuilder buildLockInfo(LockInfo lockInfo) {
    JsonObjectBuilder lockInfoJson = Json.createObjectBuilder();
    if (lockInfo != null) {
        lockInfoJson.add("className", nullSafe(lockInfo.getClassName()));
        lockInfoJson.add("identityHashCode", lockInfo.getIdentityHashCode());
    }
    return lockInfoJson;
}
 
Example 58
Project: tda   File: MBeanDumper.java   Source Code and License 5 votes vote down vote up
/**
 * Prints the thread dump information with locks info to System.out.
 */
private void dumpThreadInfoWithLocks(StringBuilder dump) {
   dump.append(getDumpDate());
   dump.append(dumpPrefix);
   dump.append("\n");

   ThreadInfo[] tinfos = tmbean.dumpAllThreads(true, true);
   for (int i = 0; i < tinfos.length; i++) {
       ThreadInfo ti = tinfos[i];
       printThreadInfo(ti, dump);
       LockInfo[] syncs = ti.getLockedSynchronizers();
       printLockInfo(syncs, dump);
   }
   dump.append("\n");
}
 
Example 59
Project: tda   File: MBeanDumper.java   Source Code and License 5 votes vote down vote up
private void printLockInfo(LockInfo[] locks, StringBuilder dump) {
   dump.append(INDENT + "Locked synchronizers: count = " + locks.length);
   dump.append("\n");
   for (int i = 0; i < locks.length; i++) {
       LockInfo li = locks[i];
       dump.append(INDENT + "  - " + li);
       dump.append("\n");
   }
   dump.append("\n");
}
 
Example 60
Project: dsl-devkit   File: TestRunRecording.java   Source Code and License 5 votes vote down vote up
/**
 * Prints the owned locks for the thread.
 * Must have explicitly obtained Monitor and Synchronizer information for anything to show up from here.
 *
 * @param info
 *          the {@code:ThreadInfo} for the thread in question, must not be {@code:null}
 * @return the owned lock information
 */
private static String getOwnedLockInfo(final ThreadInfo info) {
  StringBuilder trace = new StringBuilder("  Holding locks for:\r\n");
  for (LockInfo lock : info.getLockedSynchronizers()) {
    trace.append("    " + lock.toString() + "\r\n");
  }
  for (MonitorInfo monitor : info.getLockedMonitors()) {
    trace.append("    " + monitor.toString() + "\r\n");
  }
  return trace.toString();
}