incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r892714 - in /incubator/kato/trunk/org.apache.kato: kato.api.vm/src/main/java/javax/tools/diagnostics/vm/ kato.common.142/src/main/java/org/apache/kato/common142/ kato.tck/harness/src/main/java/org/apache/kato/tck/harness/scenario/
Date Mon, 21 Dec 2009 07:48:17 GMT
Author: spoole
Date: Mon Dec 21 07:48:17 2009
New Revision: 892714

URL: http://svn.apache.org/viewvc?rev=892714&view=rev
Log:
first drop of a more sophisticated dump trigger process

Modified:
    incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/Dump.java
    incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpDescriptor.java
    incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpInitiatorDelegate.java
    incubator/kato/trunk/org.apache.kato/kato.common.142/src/main/java/org/apache/kato/common142/DumpTrigger.java
    incubator/kato/trunk/org.apache.kato/kato.tck/harness/src/main/java/org/apache/kato/tck/harness/scenario/StandardDumpTrigger.java

Modified: incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/Dump.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/Dump.java?rev=892714&r1=892713&r2=892714&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/Dump.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/Dump.java
Mon Dec 21 07:48:17 2009
@@ -16,6 +16,8 @@
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * <p>
@@ -28,6 +30,61 @@
  */
 public class Dump {
 
+	
+	// store for the mapping between a dump descriptor and its owning delegate
+	
+	private Set<DumpInitiatorDelegate> availableInitiators=new HashSet<DumpInitiatorDelegate>();
+	
+	// default factory - populated when getDefault is first called
+	
+	private static Dump defaultDumpFactory=null;
+	
+	
+	private DumpInitiatorDelegate defaultInitiatorDelegate=null;
+	
+	/**
+	 * Instantiate a dump factory that can be used to trigger dumps
+	 */
+	
+	public Dump() {
+		
+	}
+	/**
+	 * Get the default Dump factory.  
+	 * Returns a Dump factory populated with all available dump initiators
+	 * 
+	 * @return default dump factory
+	 */
+	public static Dump getDefault() {
+	
+		if(defaultDumpFactory==null) {
+			Dump d=new Dump();
+			d.loadStandardInitiators();
+			d.defaultInitiatorDelegate=new DummyDelegate(); // FIXME - need to make a choice
+			defaultDumpFactory=d;
+		}
+  
+		return defaultDumpFactory;
+	}
+	
+	/**
+	 * Looks for commonly available dump initiators and add them to
+	 * this instances configuration
+	 */
+	
+	public void loadStandardInitiators() {
+		
+		SignalBasedDumpInitiatorDelegate sigdump=new SignalBasedDumpInitiatorDelegate();
+		if(sigdump.available()) {
+			availableInitiators.add(sigdump);
+			
+		}
+		IBMSPIBasedDumpInitiatorDelegate ibmdelegate=new IBMSPIBasedDumpInitiatorDelegate();
+		if(ibmdelegate.available()) {
+			availableInitiators.add(ibmdelegate);
+		}
+	}
+
 	/**
 	 * Dump Delegate for IBM JVMs using the com.ibm.jvm.Dump API Note that
 	 * reflection is used to trigger a dump as otherwise compilation of this
@@ -40,7 +97,7 @@
 		private static final String COM_IBM_JVM_DUMP = "com.ibm.jvm.Dump";
 		private Method dumpMethod = null;
 
-		public boolean dump() {
+		public boolean dump(DumpDescriptor desc) {
 
 			try {
 				dumpMethod.invoke(null, new Object[0]);
@@ -67,6 +124,12 @@
 			}
 
 		}
+
+		@Override
+		public DumpHandle createDumpHandle() {
+			// TODO Auto-generated method stub
+			return null;
+		}
 	}
 
 	/**
@@ -80,7 +143,7 @@
 		private static final String ORG_APACHE_KATO_COMMON142_DUMP_TRIGGER = "org.apache.kato.common142.DumpTrigger";
 		private Method dumpMethod = null;
 
-		public boolean dump() {
+		public boolean dump(DumpDescriptor desc) {
 
 			try {
 				Boolean result = (Boolean) dumpMethod.invoke(null,
@@ -102,39 +165,57 @@
 				clazz.newInstance();
 				// store the dump method for later use
 				dumpMethod = clazz.getMethod("triggerDump", new Class[0]);
+				
+
 				return true;
 			} catch (Exception e) {
 				return false;
 			}
 
 		}
+
+		@Override
+		public DumpHandle createDumpHandle() {
+			// TODO Auto-generated method stub
+			return null;
+		}
 	}
 
 	private static final String initiatorPropertyName = "javax.tools.diagnositics.vm.dumpinitiator";
-	private static DumpInitiatorDelegate delegate = null;
+	
 
 	/**
-	 * <p>
-	 * Initiate a dump. The location and type of dump produced is implementation
-	 * specific but is guided by the provided DumpDescriptor
-	 * 
-	 * @return true if execution is successful.
+	 * Returns a Dump handle for the default dump type used by this JVM
 	 * 
-	 * @throws IllegalArgumentException if the descriptor is null
+	 * @return a valid dump handle
 	 */
-
-	public boolean execute(DumpDescriptor descriptor) {
-
-		if(descriptor==null) throw new IllegalArgumentException("descriptor is null");
-		if (delegate == null) {
-			delegate = loadDelegate();
-		}
-
-		return delegate.dump();
-
+	public DumpHandle getDumpHandle() {
+		return defaultInitiatorDelegate.createDumpHandle();
 	}
 
 	/**
+	 * Returns an initiator that can produce a dump of the required format.
+	 * If no initiator exists which can handle the format then null is returned 
+	 * 
+	 * @param format
+	 * @return supporting initiator or null
+	 */
+	public DumpInitiatorDelegate getInitiator(String format) {
+		return null;
+	}
+	
+	/**
+	 * Returns the set of available Initiators. 
+	 * 
+	 * Always returns a set. 
+	 *  
+	 * @return
+	 */
+	public Set<DumpInitiatorDelegate> getAvailableInitiators() {
+		return null;
+	}
+	
+	/**
 	 * Loads a Dump delegate class to handle dump requests
 	 * 
 	 * If the override system property {@link initiatorPropertyName} exists then
@@ -233,7 +314,7 @@
 		 * @see javax.tools.diagnostics.vm.DumpInitiatorDelegate#dump()
 		 */
 
-		public boolean dump() {
+		public boolean dump(DumpDescriptor desc) {
 
 			File dumpFile=new File("kato.dump.placebo");
 			try {
@@ -248,7 +329,14 @@
 		public boolean available() {
 			return true;
 		}
+
+		@Override
+		public DumpHandle createDumpHandle() {
+			// TODO Auto-generated method stub
+			return null;
+		}
 	}
 
 	
+	
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpDescriptor.java?rev=892714&r1=892713&r2=892714&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpDescriptor.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpDescriptor.java
Mon Dec 21 07:48:17 2009
@@ -16,13 +16,30 @@
 
 /**
  * <p>
- * Definition of the required contents of a Dump that should be produced by
- * The Dump class.
+ * Definition of the capabilities of a Dump that should be produced by
+ * passing an instance of this descriptor to the Dump class
+ * 
  * 
  * @experimental This is an experimental addition to the API and is subject to
  *               change
  * 
  */
-public class DumpDescriptor {
-
+public interface DumpDescriptor {
+	
+	/**
+	 * Returns true if the dump generated by the initiator will
+	 * contain data that will eventually be represented by the JavaClassLoader interface
+	 * 
+	 */
+	public boolean recordsClassLoaders();
+	
+	
+	/**
+	 * Returns true if the dump generated by the initiator will
+	 * contain data that will eventually be represented by the JavaClass interface
+	 * 
+	 */
+	
+	public boolean recordsClasses();
+	
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpInitiatorDelegate.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpInitiatorDelegate.java?rev=892714&r1=892713&r2=892714&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpInitiatorDelegate.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.api.vm/src/main/java/javax/tools/diagnostics/vm/DumpInitiatorDelegate.java
Mon Dec 21 07:48:17 2009
@@ -20,20 +20,22 @@
  * 
  * Classes that implement this interface can be called by the
  * Dump class to trigger a specific dump.
- * 
- * The default implementation used is determined by the JVM
- * and is recorded in the javax.tools.diagnositics.vm.dumpinitiator property
- * 
+ *  
  */
 public interface DumpInitiatorDelegate {
 
 	/**
 	 * Called to cause a dump to be initiated.
+	 * A descriptor previously provided by this initiator is used to identify 
+	 * the dump to be produced;
+	 * 
 	 * This method should only be called by the Dump class
 	 * 
+	 * @param descriptor - the descriptor to use to create the dump
+	 * 
 	 * @returns true if dump initiation succeeded 
 	 */
-	public boolean dump();
+	public boolean dump(DumpDescriptor descriptor);
 	
 	/**
 	 * Called to check that the delegate has all available resources
@@ -44,5 +46,14 @@
 	 * @return true if the delegate is available 
 	 */
 	public  boolean available();
+
+	/**
+	 * Returns a Dump handle for a default configured dump
+	 * 
+	 * @return valid dump handle
+	 */
+	public DumpHandle createDumpHandle();
+	
 	
+	 
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.common.142/src/main/java/org/apache/kato/common142/DumpTrigger.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.common.142/src/main/java/org/apache/kato/common142/DumpTrigger.java?rev=892714&r1=892713&r2=892714&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.common.142/src/main/java/org/apache/kato/common142/DumpTrigger.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.common.142/src/main/java/org/apache/kato/common142/DumpTrigger.java
Mon Dec 21 07:48:17 2009
@@ -31,7 +31,7 @@
 	}
 	 
 	
-	private DumpTrigger () {
+	public DumpTrigger () {
 		
 		String pathName=System.getProperty(libraryPathName);
 		if(pathName!=null) {

Modified: incubator/kato/trunk/org.apache.kato/kato.tck/harness/src/main/java/org/apache/kato/tck/harness/scenario/StandardDumpTrigger.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/harness/src/main/java/org/apache/kato/tck/harness/scenario/StandardDumpTrigger.java?rev=892714&r1=892713&r2=892714&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/harness/src/main/java/org/apache/kato/tck/harness/scenario/StandardDumpTrigger.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/harness/src/main/java/org/apache/kato/tck/harness/scenario/StandardDumpTrigger.java
Mon Dec 21 07:48:17 2009
@@ -15,14 +15,14 @@
 package org.apache.kato.tck.harness.scenario;
 
 import javax.tools.diagnostics.vm.Dump;
-import javax.tools.diagnostics.vm.DumpDescriptor;
+import javax.tools.diagnostics.vm.DumpHandle;
 
 public class StandardDumpTrigger implements IDumpTrigger {
 
 	public void dump() {
-		Dump d=new Dump();
-		DumpDescriptor desc=new DumpDescriptor();
-		d.execute(desc);
+		Dump d=Dump.getDefault();
+		DumpHandle handle=d.getDumpHandle();
+		handle.dump();
 		
 	}
 



Mime
View raw message