incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r898268 - in /incubator/kato/trunk/org.apache.kato: kato.api/src/main/java/javax/tools/diagnostics/runtime/java/ kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/ kato.jdump/src/main/java/org/apache/kato/jdump/builder/ kato.j...
Date Tue, 12 Jan 2010 09:46:46 GMT
Author: spoole
Date: Tue Jan 12 09:46:45 2010
New Revision: 898268

URL: http://svn.apache.org/viewvc?rev=898268&view=rev
Log:
more work on JDump to add thread info etc

Modified:
    incubator/kato/trunk/org.apache.kato/kato.api/src/main/java/javax/tools/diagnostics/runtime/java/JavaThread.java
    incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/JThread.java
    incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/Model.java
    incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/builder/DumpBuilder.java
    incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/image/ImageFactoryImpl.java
    incubator/kato/trunk/org.apache.kato/kato.tck/testcases/src/main/java/org/apache/kato/tck/tests/legacy/TestJavaThread.java

Modified: incubator/kato/trunk/org.apache.kato/kato.api/src/main/java/javax/tools/diagnostics/runtime/java/JavaThread.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.api/src/main/java/javax/tools/diagnostics/runtime/java/JavaThread.java?rev=898268&r1=898267&r2=898268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.api/src/main/java/javax/tools/diagnostics/runtime/java/JavaThread.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.api/src/main/java/javax/tools/diagnostics/runtime/java/JavaThread.java
Tue Jan 12 09:46:45 2010
@@ -76,6 +76,9 @@
      * <p>The value returned will be the same as what would have been returned by a
call
      * to {@link java.lang.Thread#getPriority()} within the Java Virtual Machine.
      * 
+     * If the thread priority is not available then a call to this method will
+     * return -1.
+     * 
      * @return the Java priority of the thread (a number between 1 and 10 inclusive)
      * @throws CorruptDataException 
      * 

Modified: incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/JThread.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/JThread.java?rev=898268&r1=898267&r2=898268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/JThread.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/JThread.java
Tue Jan 12 09:46:45 2010
@@ -14,6 +14,7 @@
 
 package org.apache.kato.model.javaruntime;
 
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.logging.Level;
@@ -30,7 +31,7 @@
 public class JThread implements JavaThread{
 	public JMonitor contendedMonitor=null;
 	public long id=0;
-	public short priority=0;
+	public short priority=-1;
 	public short daemon=0;
 	public int groupID=0;
 	public String threadName=null;
@@ -129,6 +130,7 @@
 	}
 	@Override
 	public JavaObject getObject() throws CorruptDataException {
+		
 		return object;
 	}
 	
@@ -143,7 +145,9 @@
 	
 	@Override
 	public List<JavaStackFrame> getStackFrames() {
+	
 		CLogger.logr.log(Level.FINEST,"Asked for stack frames");
+		if(frames==null) return Collections.emptyList();
 		return frames;
 	}
 	

Modified: incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/Model.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/Model.java?rev=898268&r1=898267&r2=898268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/Model.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.dump.model/src/main/java/org/apache/kato/model/javaruntime/Model.java
Tue Jan 12 09:46:45 2010
@@ -140,6 +140,7 @@
 	 * @return an unmodifiable list of objects.
 	 */
 	public List<JavaObject> getObjects() {
+		if(objectMap==null) return Collections.emptyList();
 		return Collections.unmodifiableList(objectMap.values());		
 	}
 

Modified: incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/builder/DumpBuilder.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/builder/DumpBuilder.java?rev=898268&r1=898267&r2=898268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/builder/DumpBuilder.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/builder/DumpBuilder.java
Tue Jan 12 09:46:45 2010
@@ -17,17 +17,15 @@
 import java.io.File;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
+import java.lang.management.MonitorInfo;
 import java.lang.management.ThreadInfo;
-import java.lang.management.ThreadMXBean;
-
-import javax.tools.diagnostics.runtime.java.JavaStackFrame;
 
 import org.apache.kato.jdump.JDump;
 import org.apache.kato.jdump.templates.DumpHeader;
-import org.apache.kato.jdump.templates.ThreadTemplate;
 import org.apache.kato.model.javaruntime.JJavaRuntime;
 import org.apache.kato.model.javaruntime.JLocation;
 import org.apache.kato.model.javaruntime.JMethod;
+import org.apache.kato.model.javaruntime.JMonitor;
 import org.apache.kato.model.javaruntime.JStackFrame;
 import org.apache.kato.model.javaruntime.JThread;
 import org.apache.kato.model.javaruntime.Model;
@@ -59,6 +57,7 @@
 		thread.daemon=(short) (t.isDaemon() ? 1 : 0);
 		thread.priority=(short) t.getPriority();
 		JJavaRuntime runtime=new JJavaRuntime(model, source);
+		runtime.setVersion("0.1");
 		
 		populateDump(model);
 		
@@ -73,6 +72,12 @@
  * @return
  */
 private static void populateDump(Model model) {
+	
+	addThreadInfo(model);
+	
+}
+
+private static void addThreadInfo(Model model) {
 	ThreadInfo[] threads=ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
     
 	if(threads!=null ) {
@@ -80,6 +85,9 @@
 			long id=thread.getThreadId();
 			JThread jthread=model.getThread(id);
 			jthread.setThreadName(thread.getThreadName());
+			jthread.setState(thread.getThreadState().ordinal());
+			addMonitors(model,jthread,thread);
+			
 			StackTraceElement[] stack=thread.getStackTrace();
 			if(stack!=null) {
 				for(StackTraceElement e:stack) {
@@ -98,6 +106,29 @@
 }
 
 /**
+ * @param jthread
+ * @param lockedMonitors
+ */
+private static void addMonitors(Model model,JThread jthread,ThreadInfo thread) {
+	
+	MonitorInfo[] lockedMonitors=thread.getLockedMonitors();
+	
+	for(MonitorInfo info:lockedMonitors) {
+		int id=info.getIdentityHashCode();
+		JMonitor monitor=model.getMonitor(id);
+		monitor.setOwner(jthread.id);
+		
+	}
+	
+	long blockingOn=thread.getLockOwnerId();
+	if(blockingOn!=-1) {
+		int monitor=thread.getLockInfo().getIdentityHashCode();
+		jthread.contendedMonitor=model.getMonitor(monitor);
+	}
+	
+}
+
+/**
  * @param methodName
  * @return
  */

Modified: incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/image/ImageFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/image/ImageFactoryImpl.java?rev=898268&r1=898267&r2=898268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/image/ImageFactoryImpl.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.jdump/src/main/java/org/apache/kato/jdump/image/ImageFactoryImpl.java
Tue Jan 12 09:46:45 2010
@@ -90,8 +90,7 @@
 	 */
 	@Override
 	public String[] getValidFileExtensions() {
-		// TODO Auto-generated method stub
-		return null;
+		return new String[]{"jdump"};
 	}
 
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.tck/testcases/src/main/java/org/apache/kato/tck/tests/legacy/TestJavaThread.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/testcases/src/main/java/org/apache/kato/tck/tests/legacy/TestJavaThread.java?rev=898268&r1=898267&r2=898268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/testcases/src/main/java/org/apache/kato/tck/tests/legacy/TestJavaThread.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/testcases/src/main/java/org/apache/kato/tck/tests/legacy/TestJavaThread.java
Tue Jan 12 09:46:45 2010
@@ -66,14 +66,14 @@
 			
 			try {
 				JavaObject obj=t.getObject();
-				assertNotNull("Entry "+counter+":object is null - DataUnavailable should have been thrown
instead",obj);
+				
 			} catch (CorruptDataException e) {
 			// allowed
 			}
 			
 			try {
 				int priority=t.getPriority();
-				assertTrue("Entry "+counter+":priority value ["+priority+"] is not >=1 &&
<=10",priority>=1 && priority<=10);
+				assertTrue("Entry "+counter+":priority value ["+priority+"] is not-1 or  >=1 &&
<=10",priority==-1 || (priority>=1 && priority<=10));
 			} catch (CorruptDataException e) {
 				// allowed;
 			}



Mime
View raw message