incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r827913 - in /incubator/kato/branches/experimental/kato.javaview: ./ src/main/java/org/apache/kato/javaview/api/ src/main/java/org/apache/kato/javaview/impl/ src/test/java/test/apache/kato/javaview/
Date Wed, 21 Oct 2009 08:02:28 GMT
Author: spoole
Date: Wed Oct 21 08:02:27 2009
New Revision: 827913

URL: http://svn.apache.org/viewvc?rev=827913&view=rev
Log:
changes to javaview for safe keeping.  

Added:
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/ListbackedQueryResult.java
Modified:
    incubator/kato/branches/experimental/kato.javaview/.classpath
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/IJavaClassLoader.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderHierarchyBuilder.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java

Modified: incubator/kato/branches/experimental/kato.javaview/.classpath
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/.classpath?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/.classpath (original)
+++ incubator/kato/branches/experimental/kato.javaview/.classpath Wed Oct 21 08:02:27 2009
@@ -6,5 +6,6 @@
 	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/ibm.jsr326.j9"/>
 	<classpathentry kind="output" path="target/classes"/>
-</classpath>
\ No newline at end of file
+</classpath>

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/IJavaClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/IJavaClassLoader.java?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/IJavaClassLoader.java
(original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/IJavaClassLoader.java
Wed Oct 21 08:02:27 2009
@@ -13,10 +13,10 @@
  ******************************************************************************/
 package org.apache.kato.javaview.api;
 
-import java.util.Set;
 
 public interface IJavaClassLoader {
 
-	public Set<IJavaClassLoader> getParents();
-	public Set<IJavaClassLoader> getChildren();
+	public QueryResult<IJavaClassLoader> getParents();
+	public QueryResult<IJavaClassLoader> getChildren();
+	public long getID();
 }

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java
(original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java
Wed Oct 21 08:02:27 2009
@@ -17,18 +17,7 @@
 
 
 public interface QueryResult<T> extends Iterable<T>{
-
 	
-	// Return a subset of type <T> based on the "filter" string
-    // an XPath query.
-	QueryResult<T> filterSet(String filter);
-
-    // Reduce this result set using the filter passed.
-    void applyFilter(String filter);
-
-    // Run a query on the string.
-    QueryResult<?> query(String filter);
-    
     T getElement(long elementNumber) throws IOException;
     
     long getSize() throws IOException;

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderHierarchyBuilder.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderHierarchyBuilder.java?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderHierarchyBuilder.java
(original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderHierarchyBuilder.java
Wed Oct 21 08:02:27 2009
@@ -14,14 +14,20 @@
 package org.apache.kato.javaview.impl;
 
 import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
+import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.DiagnosticException;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaClassLoader;
+import javax.tools.diagnostics.runtime.java.JavaObject;
 
 import org.apache.kato.javaview.api.IJavaClassLoader;
+import org.apache.kato.javaview.api.QueryResult;
+
+
 
 
 
@@ -142,9 +148,10 @@
 		
 	
 		
-		public Set<IJavaClassLoader> getParents() {
-			
-			return parents;
+		public QueryResult<IJavaClassLoader> getParents() {
+			LinkedList<IJavaClassLoader> list=new LinkedList<IJavaClassLoader>();
+			list.addAll(parents);
+			return new ListbackedQueryResult<IJavaClassLoader>(list);
 		}
 	
 		public boolean hasParents() {
@@ -163,8 +170,24 @@
 			return definingLoader;
 		}
 		@Override
-		public Set<IJavaClassLoader> getChildren() {
-			return kids;
+		public QueryResult<IJavaClassLoader> getChildren() {
+			LinkedList<IJavaClassLoader> list=new LinkedList<IJavaClassLoader>();
+			list.addAll(kids);
+			return new ListbackedQueryResult<IJavaClassLoader>(list);
+
+		}
+		@Override
+		public long getID() {
+			
+			JavaObject obj;
+			try {
+				obj = definingLoader.getObject();
+			} catch (CorruptDataException e) {
+				return 1;
+			}
+			if(obj==null) return 1;
+			return obj.getID().getAddress();
+			
 		}
 		
 		

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java
(original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java
Wed Oct 21 08:02:27 2009
@@ -14,9 +14,8 @@
 
 package org.apache.kato.javaview.impl;
 
-import java.util.Set;
-
 import org.apache.kato.javaview.api.IJavaClassLoader;
+import org.apache.kato.javaview.api.QueryResult;
 
 class JavaClassLoaderImpl implements IJavaClassLoader {
 
@@ -32,19 +31,23 @@
 	
 	}
 	
-	@Override
-	public Set<IJavaClassLoader> getChildren() {
 	
+
+	@Override
+	public QueryResult<IJavaClassLoader> getChildren() {
+		// TODO Auto-generated method stub
 		return null;
 	}
 
 	@Override
-	public Set<IJavaClassLoader> getParents() {
+	public QueryResult<IJavaClassLoader> getParents() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
-	public long getLoaderID() {
+	@Override
+	public long getID() {
+		
 		return id;
 	}
 

Added: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/ListbackedQueryResult.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/ListbackedQueryResult.java?rev=827913&view=auto
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/ListbackedQueryResult.java
(added)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/ListbackedQueryResult.java
Wed Oct 21 08:02:27 2009
@@ -0,0 +1,72 @@
+package org.apache.kato.javaview.impl;
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.kato.javaview.api.QueryResult;
+
+public class ListbackedQueryResult<T> implements QueryResult<T>{
+
+	private List<T>  data=null;
+	
+	public ListbackedQueryResult(List<T> data) {
+		if(data==null) throw new IllegalArgumentException("data is null");
+		this.data=data;
+	}
+	@Override
+	public void applyFilter(String filter) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public void dispose() throws IOException {
+		if(data==null) throw new IOException("dispose already called");
+		data=null;
+	}
+
+	@Override
+	public QueryResult<T> filterSet(String filter) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public T getElement(long elementNumber) throws IOException {
+		
+		return data.get((int) elementNumber);
+	}
+
+	@Override
+	public long getSize() throws IOException {
+		
+		return data.size();
+	}
+
+	@Override
+	public QueryResult<?> query(String filter) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Iterator<T> iterator() {
+		
+		return data.iterator();
+	}
+
+}

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java
(original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java
Wed Oct 21 08:02:27 2009
@@ -40,4 +40,7 @@
 	public void close() throws IOException;
 
 	public QueryResult<IJavaClass> getAllClasses() throws IOException;
+
+	public void addClassLoaderRelationship(JavaClassLoaderImpl parent,
+			JavaClassLoaderImpl child);
 }

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java
(original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java
Wed Oct 21 08:02:27 2009
@@ -19,13 +19,16 @@
 import java.util.List;
 
 import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DiagnosticException;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaClassLoader;
 import javax.tools.diagnostics.runtime.java.JavaHeap;
 import javax.tools.diagnostics.runtime.java.JavaObject;
 import javax.tools.diagnostics.runtime.java.JavaRuntime;
 
-import org.apache.kato.javaview.api.IJavaView;
+import org.apache.kato.javaview.api.IJavaClassLoader;
+import org.apache.kato.javaview.api.QueryResult;
+import org.apache.kato.javaview.impl.JavaClassLoaderHierarchyBuilder.Loader;
 
 
 
@@ -49,7 +52,7 @@
 		addClassLoaders(jrt,s);
 		addInstances(jrt,s);
 		
-	
+		
 		
 		return  s;
 		
@@ -97,38 +100,69 @@
 		
 		
 		
+		JavaClassLoaderHierarchyBuilder builder=new JavaClassLoaderHierarchyBuilder();
+		JavaClassLoaderHierarchy h=null;
+		try {
+			h=builder.buildHierarchy(runtime.getJavaClassLoaders());
+		} catch (DiagnosticException e1) {
+			
+			e1.printStackTrace();
+			return;
+		}
+		
 		int count=0;
-		for(JavaClassLoader jcl:runtime.getJavaClassLoaders()) {
+		for(Loader loader:h.getAllLoaders()) {
 			
 			
 			long id=1;
 			count++;
+			JavaClassLoader jcl=loader.getDefiningLoader();
+			JavaClassLoaderImpl i=buildLoader(store,jcl);
 			
-			JavaObject o;
-			try {
-				o = jcl.getObject();
-			
-			if(o!=null) id=o.getID().getAddress();
-			JavaClassLoaderImpl i=new JavaClassLoaderImpl(store,id);
 			store.addJavaClassLoader(i);
 			
-			// add classes...
-			
-			addClasses(store, jcl.getCachedClasses());
-			addClasses(store, jcl.getDefinedClasses());
-			
-			
-			
-			
+			// 	add classes...
+			try {
+				addClasses(store, jcl.getDefinedClasses());
 			} catch (CorruptDataException e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
+		
+			QueryResult<IJavaClassLoader> kids=loader.getChildren();
+			for(IJavaClassLoader kid:kids) {
+				JavaClassLoaderImpl kidImpl=new JavaClassLoaderImpl(store, kid.getID());
+				store.addClassLoaderRelationship(i,kidImpl);
+			}
+			
 		}
 		System.out.println("Added "+count+" loaders");
 		
 	}
 
+	
+
+	private static JavaClassLoaderImpl buildLoader(PersistentStore store,JavaClassLoader jcl)
{
+		
+		long id=1;
+		JavaObject o;
+		try {
+			o = jcl.getObject();
+			if(o!=null) id=o.getID().getAddress();
+			
+			return new JavaClassLoaderImpl(store,id);
+			
+			
+		
+		
+		} catch (CorruptDataException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+		
+	}
+
 	private static void addClasses(PersistentStore store, List<JavaClass> list)
 			throws CorruptDataException {
 		for(JavaClass clazz:list) {

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java
(original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java
Wed Oct 21 08:02:27 2009
@@ -16,6 +16,7 @@
 
 	Connection connection=null;
 	PreparedStatement insertInstance=null;
+	PreparedStatement insertClassLoaderRelationship=null;
 	PreparedStatement getClass=null;
 	PreparedStatement getClassLoader=null;
 	PreparedStatement insertClass=null;
@@ -47,7 +48,7 @@
 	@Override
 	public void addJavaClassLoader(JavaClassLoaderImpl i) {
 		try {
-			insertClassLoader.setLong(1, i.getLoaderID());
+			insertClassLoader.setLong(1, i.getID());
 			insertClassLoader.executeUpdate();
 			
 		} catch (SQLException e) {
@@ -150,6 +151,7 @@
 			statement.execute("drop table instances");
 			statement.execute("drop table classes");
 			statement.execute("drop table loaders");
+			statement.execute("drop table loaderrel");
 			} catch(SQLException se) {
 				;
 			}
@@ -158,7 +160,7 @@
 			statement.execute("create table instances ( id bigint PRIMARY KEY, classid bigint )");
 			statement.execute("create table classes   ( id bigint PRIMARY KEY, loaderid bigint, name
varchar(255) )");
 			statement.execute("create table loaders   ( id bigint PRIMARY KEY)");
-			
+			statement.execute("create table loaderrel ( parent bigint , child bigint)");
 			statement.close();
 			
 			// create prepared statements
@@ -167,6 +169,8 @@
 			insertClass       =connection.prepareStatement("insert into classes values(?,?,?)");
 			insertClassLoader =connection.prepareStatement("insert into loaders values(?)");
 			
+			insertClassLoaderRelationship=connection.prepareStatement("insert into loaderrel values(?,?)");
+			
 			getClass          =connection.prepareStatement("select * from classes where id=?");
 			getClassLoader    =connection.prepareStatement("select * from loaders where id=?");
 		} catch (SQLException e) {
@@ -247,4 +251,20 @@
 		}
 	
 	}
+
+	@Override
+	public void addClassLoaderRelationship(JavaClassLoaderImpl parent,
+			JavaClassLoaderImpl child) {
+		
+		try {
+			insertClassLoaderRelationship.setLong(1, parent.getID());
+			insertClassLoaderRelationship.setLong(2, child.getID());
+			insertClassLoaderRelationship.executeUpdate();
+			
+		} catch (SQLException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+	}
 }

Modified: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java?rev=827913&r1=827912&r2=827913&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java
(original)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java
Wed Oct 21 08:02:27 2009
@@ -16,6 +16,7 @@
 import java.io.File;
 import java.io.IOException;
 
+import javax.tools.diagnostics.FactoryRegistry;
 import javax.tools.diagnostics.runtime.java.JavaRuntime;
 
 import org.apache.kato.javaview.api.IJavaClass;
@@ -27,14 +28,13 @@
 
 public class TestPersistanceStoreScale extends AbstractPersistentStoreTestCase {
 
-	static String testname=TestPersistanceStoreScale.class.getCanonicalName();
 	
 	public void testLoadPersistentStore() throws IOException {
 		
+		File file=new File("/home/spoole/Desktop/core.20090614.204433.20785.0001.dmp.core");
 		
-		File f=new File("foo");
+		JavaRuntime jrt=FactoryRegistry.getDefaultRegistry().getJavaRuntime(file);
 		
-		JavaRuntime jrt=new SmallMockJavaRuntime(f);
 		PersistentStore store=getStore(jrt);
 		
 		QueryResult<IJavaClass>  clazzes=store.getAllClasses();



Mime
View raw message