incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monte...@apache.org
Subject svn commit: r777156 - in /incubator/kato/trunk/org.apache.kato.tools.katoview: .settings/ src/com/ibm/dtfj/dtfjview/ src/org/apache/kato/dtfjview/commands/ src/org/apache/kato/dtfjview/heapdump/ src/org/apache/kato/katoview/commands/ src/org/apache/kat...
Date Thu, 21 May 2009 15:37:25 GMT
Author: monteith
Date: Thu May 21 15:37:24 2009
New Revision: 777156

URL: http://svn.apache.org/viewvc?rev=777156&view=rev
Log:
Add new "tomcat version" command. more to follow.

Added:
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/TomcatCommand.java
  (with props)
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaClassVisitor.java
  (with props)
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaRuntimeVisitor.java
  (with props)
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/KatoSearch.java
  (with props)
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/tomcat/
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/tomcat/TomcatVersionCommand.java
  (with props)
Removed:
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/com/ibm/dtfj/dtfjview/
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/dtfjview/commands/
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/dtfjview/heapdump/
Modified:
    incubator/kato/trunk/org.apache.kato.tools.katoview/.settings/org.eclipse.jdt.core.prefs
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java

Modified: incubator/kato/trunk/org.apache.kato.tools.katoview/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/.settings/org.eclipse.jdt.core.prefs?rev=777156&r1=777155&r2=777156&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/.settings/org.eclipse.jdt.core.prefs
(original)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/.settings/org.eclipse.jdt.core.prefs
Thu May 21 15:37:24 2009
@@ -1,12 +1,12 @@
-#Sat Jul 05 12:52:01 BST 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
+#Thu May 21 16:26:02 BST 2009
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error

Modified: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java?rev=777156&r1=777155&r2=777156&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java
(original)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java
Thu May 21 15:37:24 2009
@@ -35,9 +35,9 @@
 		child_commands.add(new MinusCommand(o));
 		child_commands.add(new FindCommand(o));
 		child_commands.add(new DeadlockCommand(o));
+		child_commands.add(new TomcatCommand(o));
 		child_commands.add(new SetCommand(o));
-		child_commands.add(new ShowCommand(o));
-		child_commands.add(new QuitCommand(o));
+		child_commands.add(new ShowCommand(o));		
 		child_commands.add(new WhatisCommand(o));
 		child_commands.add(new CdCommand(o));
 		child_commands.add(new PwdCommand(o));
@@ -46,6 +46,7 @@
 		child_commands.add(new HelpCommand(o, this));
 		child_commands.add(new XCommand(o));
 		child_commands.add(new ExitCommand(o));
+		child_commands.add(new QuitCommand(o));
 	}
 	
 	public void printHelp(String indent, int descOffset, Stack currArgs, Stack prevArgs)

Added: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/TomcatCommand.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/TomcatCommand.java?rev=777156&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/TomcatCommand.java
(added)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/TomcatCommand.java
Thu May 21 15:37:24 2009
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+package org.apache.kato.katoview.commands;
+
+import java.util.Vector;
+
+import org.apache.kato.katoview.Output;
+import org.apache.kato.katoview.commands.tomcat.TomcatVersionCommand;
+
+/**
+ * Provides commands for querying a Tomcat 5.5 server.
+ * 
+ *
+ */
+public class TomcatCommand extends Command {
+	private static final String COMMAND_NAME="tomcat";
+	private static final String DESCRIPTION="Tomcat support commands";
+	private static final String LONG_DESCRIPTION="Tomcat support commands";
+	
+	protected TomcatCommand(Output o) {
+		super(o, COMMAND_NAME, DESCRIPTION, LONG_DESCRIPTION);
+		child_commands = new Vector();
+		child_commands.add(new TomcatVersionCommand(o));
+
+	}
+	
+}

Propchange: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/TomcatCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaClassVisitor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaClassVisitor.java?rev=777156&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaClassVisitor.java
(added)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaClassVisitor.java
Thu May 21 15:37:24 2009
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+package org.apache.kato.katoview.commands.helpers;
+
+import org.apache.kato.image.KatoException;
+import org.apache.kato.java.JavaClass;
+
+/**
+ * Interface for visiting classes.
+ *
+ */
+public interface JavaClassVisitor {
+	/**
+	 * Visits classes.
+	 * 
+	 * @param clazz
+	 * @return false if visitor is to exit.
+	 * @throws KatoException
+	 */
+	public boolean visit(JavaClass clazz) throws KatoException;
+}

Propchange: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaClassVisitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaRuntimeVisitor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaRuntimeVisitor.java?rev=777156&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaRuntimeVisitor.java
(added)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaRuntimeVisitor.java
Thu May 21 15:37:24 2009
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+package org.apache.kato.katoview.commands.helpers;
+
+import org.apache.kato.image.KatoException;
+import org.apache.kato.java.JavaRuntime;
+
+/**
+ * Passed to methods to visit all runtimes in an image.
+ *
+ */
+public interface JavaRuntimeVisitor {
+	public void visit(JavaRuntime runtime) throws KatoException;
+}

Propchange: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/JavaRuntimeVisitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/KatoSearch.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/KatoSearch.java?rev=777156&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/KatoSearch.java
(added)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/KatoSearch.java
Thu May 21 15:37:24 2009
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+package org.apache.kato.katoview.commands.helpers;
+
+import java.util.List;
+
+import org.apache.kato.image.CorruptData;
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.Image;
+import org.apache.kato.image.ImageAddressSpace;
+import org.apache.kato.image.ImageProcess;
+import org.apache.kato.image.KatoException;
+import org.apache.kato.java.JavaClass;
+import org.apache.kato.java.JavaClassLoader;
+import org.apache.kato.java.JavaField;
+import org.apache.kato.java.JavaRuntime;
+
+/**
+ * Provides utility classes for retrieving things from dumps
+ * 
+ *
+ */
+public class KatoSearch {
+	/**
+	 * Passed JavaRuntimes to a visitor given an image.
+	 * 
+	 * @param image
+	 * @param visitor
+	 */
+	public static void visitRuntimes(Image image, JavaRuntimeVisitor visitor) throws KatoException
{
+		List spaces = image.getAddressSpaces();
+		
+		for(Object nextSpace : spaces) {			
+			if(nextSpace instanceof CorruptData) {
+				continue;
+			}
+			
+			ImageAddressSpace space = (ImageAddressSpace) nextSpace;
+			
+			List processes = space.getProcesses();
+			
+			for (Object nextProcess : processes) {
+				
+				if (nextProcess instanceof CorruptData) {
+					continue;
+				}
+				
+				ImageProcess process = (ImageProcess) nextProcess;
+				
+				List runtimes = process.getRuntimes();
+				
+				for (Object nextRuntime : runtimes) {
+					
+					if (nextRuntime instanceof CorruptData) {
+						continue;
+					}
+					
+					if (nextRuntime instanceof JavaRuntime) {
+						JavaRuntime runtime = (JavaRuntime) nextRuntime;
+						
+						visitor.visit(runtime);
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * Visits all classes in a passed runtime.
+	 * 
+	 * @param runtime
+	 * @param visitor
+	 * @throws KatoException 
+	 */
+	public static void visitClasses(JavaRuntime runtime, JavaClassVisitor visitor)  {
+		List classLoaders = runtime.getJavaClassLoaders();
+		
+CLASSLOADERS:
+		for (Object nextLoader : classLoaders) {			
+			if (nextLoader instanceof CorruptData) {
+				continue;
+			}
+			
+			JavaClassLoader loader = (JavaClassLoader) nextLoader;
+			
+			List classes = loader.getDefinedClasses();
+			
+			for (Object nextClazz : classes) {
+				
+				if (nextClazz instanceof CorruptData) {
+					continue;
+				}
+				
+				JavaClass clazz = (JavaClass) nextClazz;
+				try {
+					boolean rc = visitor.visit(clazz);
+					if (rc == false) {
+						break CLASSLOADERS;
+					}
+				} catch (KatoException e) {
+					
+				}
+			}
+		}
+	}
+	
+	/**
+	 * Returns a field of a given name from a class.
+	 * 
+	 * 
+	 * @param clazz JavaClass to search for field
+	 * @param name name of field to retrieve.
+	 * @return JavaField if found, else returns null.
+	 */
+	public static JavaField getField(JavaClass clazz, String name)  {
+		List fields = clazz.getDeclaredFields();
+		
+		for (Object nextField : fields) {
+			
+			if (nextField instanceof CorruptData) {
+				break;
+			}
+			
+			JavaField field = (JavaField) nextField;
+			try {
+				if (name.equals(field.getName())) {
+					return field;
+				}
+			} catch (CorruptDataException e) {
+				// Try again.
+			}
+		}
+		
+		return null;
+	}
+}

Propchange: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/helpers/KatoSearch.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/tomcat/TomcatVersionCommand.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/tomcat/TomcatVersionCommand.java?rev=777156&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/tomcat/TomcatVersionCommand.java
(added)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/tomcat/TomcatVersionCommand.java
Thu May 21 15:37:24 2009
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+package org.apache.kato.katoview.commands.tomcat;
+
+import java.util.HashMap;
+import java.util.Stack;
+
+import org.apache.kato.image.Image;
+import org.apache.kato.image.KatoException;
+import org.apache.kato.java.JavaClass;
+import org.apache.kato.java.JavaField;
+import org.apache.kato.java.JavaRuntime;
+import org.apache.kato.katoview.Output;
+import org.apache.kato.katoview.commands.Command;
+import org.apache.kato.katoview.commands.helpers.JavaClassVisitor;
+import org.apache.kato.katoview.commands.helpers.JavaRuntimeVisitor;
+import org.apache.kato.katoview.commands.helpers.KatoSearch;
+
+/**
+ * Retrieves the version of Tomcat in the dump, or displays an error.
+ *
+ */
+public class TomcatVersionCommand extends Command {
+	private static final String SHORT_DESCRIPTION = "Returns version of Tomcat in the dump.";
+	private static final String COMMAND_NAME = "version";
+	private static final String LONG_DESCRIPTION = "Looks for Tomcat within the dump and reports
the version.";
+	
+	// Look for this class.
+	private static final String SERVER_INFO_CLASS="org/apache/catalina/util/ServerInfo"; 
+	private static final String SERVER_NUMBER = "serverNumber",
+								SERVER_BUILT = "serverBuilt",
+								SERVER_INFO = "serverInfo";
+	
+	public TomcatVersionCommand(Output o) {
+		super(o, COMMAND_NAME, SHORT_DESCRIPTION, LONG_DESCRIPTION);
+		
+		child_commands = null;
+	}
+
+	public void doCommand(Stack args, Image loadedImage, HashMap properties) {
+		try {
+			KatoSearch.visitRuntimes(loadedImage, new PrintVersion());
+		} catch (KatoException e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * A visitor for finding the correct class and then return
+	 *
+	 */
+	private class PrintVersion implements JavaRuntimeVisitor, JavaClassVisitor {
+		boolean found = false;
+		
+		public void visit(JavaRuntime runtime) throws KatoException {
+			found = false;
+			KatoSearch.visitClasses(runtime, this);
+			
+			if (found == false) {
+				out.println("ERROR: Couldn't find a Tomcat server");				
+			}
+		}
+
+		public boolean visit(JavaClass clazz) throws KatoException {
+			if (clazz.getName().equals(SERVER_INFO_CLASS)) {
+				JavaField serverNumberField = KatoSearch.getField(clazz, SERVER_NUMBER);
+				JavaField serverBuiltField = KatoSearch.getField(clazz, SERVER_BUILT);
+				JavaField serverInfoField = KatoSearch.getField(clazz, SERVER_INFO);
+				
+				
+				out.println("Found Tomcat server: ");
+				if (serverInfoField != null) {
+					out.println("\tInfo: "+serverInfoField.getString(null));						
+				}
+				if (serverBuiltField != null) {
+					out.println("\tBuilt: "+serverBuiltField.getString(null));						
+				}
+				if (serverNumberField != null) {
+					out.println("\tNumber: "+serverNumberField.getString(null));						
+				}
+				found = true; // indicate we found a server.
+				
+				return false; // Stop searching through classes.
+			}
+			return true;
+		}
+		
+	}
+}
\ No newline at end of file

Propchange: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/tomcat/TomcatVersionCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message