本文整理汇总了Java中java.lang.management.LockInfo类的典型用法代码示例。如果您正苦于以下问题:Java LockInfo类的具体用法?Java LockInfo怎么用?Java LockInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LockInfo类属于java.lang.management包,在下文中一共展示了LockInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: threadLockedSynchronizers
import java.lang.management.LockInfo; //导入依赖的package包/类
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;
}
}
示例2: initData
import java.lang.management.LockInfo; //导入依赖的package包/类
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);
}
}
示例3: setLockInfo
import java.lang.management.LockInfo; //导入依赖的package包/类
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());
}
}
示例4: extractRuntime
import java.lang.management.LockInfo; //导入依赖的package包/类
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));
}
示例5: outputWaitingInfo
import java.lang.management.LockInfo; //导入依赖的package包/类
@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");
}
}
示例6: printLockInfo
import java.lang.management.LockInfo; //导入依赖的package包/类
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");
}
示例7: printLockInfo
import java.lang.management.LockInfo; //导入依赖的package包/类
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();
}
示例8: printLockInfo
import java.lang.management.LockInfo; //导入依赖的package包/类
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();
}
示例9: dumpThreadInfoWithLocks
import java.lang.management.LockInfo; //导入依赖的package包/类
/**
* 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();
}
示例10: printLockInfo
import java.lang.management.LockInfo; //导入依赖的package包/类
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();
}
示例11: toCompositeData
import java.lang.management.LockInfo; //导入依赖的package包/类
public static CompositeData toCompositeData(LockInfo li) {
if (li == null) {
return null;
}
LockInfoCompositeData licd = new LockInfoCompositeData(li);
return licd.getCompositeData();
}
示例12: toLockInfo
import java.lang.management.LockInfo; //导入依赖的package包/类
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);
}
示例13: toOpenTypeData
import java.lang.management.LockInfo; //导入依赖的package包/类
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");
}
示例14: lockedSynchronizers
import java.lang.management.LockInfo; //导入依赖的package包/类
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;
}
示例15: generateThreadStack
import java.lang.management.LockInfo; //导入依赖的package包/类
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();
}