incubator-lokahi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tob...@apache.org
Subject svn commit: r424058 - in /incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent: callable/context/ interfaces/ jmx/ task/ tomcat/
Date Thu, 20 Jul 2006 20:47:26 GMT
Author: toback
Date: Thu Jul 20 13:47:26 2006
New Revision: 424058

URL: http://svn.apache.org/viewvc?rev=424058&view=rev
Log:
Changes to fix the gathering of context status.

Fix to make undeploy context match what parameters that it needs.

Added:
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/StatusOfContextCallable.java
  (with props)
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/StatusOfContextTask.java
  (with props)
Modified:
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/UndeployContextCallable.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/interfaces/AgentTomcat.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/jmx/JMXTomcat.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/UndeployContextTask.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/tomcat/HttpTomcat.java

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/StatusOfContextCallable.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/StatusOfContextCallable.java?rev=424058&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/StatusOfContextCallable.java
(added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/StatusOfContextCallable.java
Thu Jul 20 13:47:26 2006
@@ -0,0 +1,41 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you 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.lokahi.core.agent.callable.context;
+
+import org.apache.lokahi.core.agent.interfaces.AgentTomcat;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author Stephen Toback
+ * @version $Id$
+ */
+public class StatusOfContextCallable implements Callable<String> {
+  private AgentTomcat tc;
+  private String contextName;
+
+  public StatusOfContextCallable(AgentTomcat tc, String contextName) {
+    this.tc = tc;
+    this.contextName = contextName;
+  }
+
+  public String call() throws Exception {
+	return tc.getStatusOfContext(contextName);
+  }
+}

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/StatusOfContextCallable.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/UndeployContextCallable.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/UndeployContextCallable.java?rev=424058&r1=424057&r2=424058&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/UndeployContextCallable.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/callable/context/UndeployContextCallable.java
Thu Jul 20 13:47:26 2006
@@ -29,12 +29,10 @@
 public class UndeployContextCallable implements Callable<Boolean> {
   private AgentTomcat tc;
   private String contextName;
-  private String docBase;
 
-  public UndeployContextCallable(AgentTomcat tc, String contextName, String docBase) {
+  public UndeployContextCallable(AgentTomcat tc, String contextName) {
     this.tc = tc;
     this.contextName = contextName;
-    this.docBase = docBase;
   }
 
   public Boolean call() throws Exception {

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/interfaces/AgentTomcat.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/interfaces/AgentTomcat.java?rev=424058&r1=424057&r2=424058&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/interfaces/AgentTomcat.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/interfaces/AgentTomcat.java
Thu Jul 20 13:47:26 2006
@@ -52,6 +52,8 @@
   String getStandardOutLog();
 
   String[] getStartCommand();
+
+  String getStatusOfContext(String context);
 }
 
 

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/jmx/JMXTomcat.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/jmx/JMXTomcat.java?rev=424058&r1=424057&r2=424058&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/jmx/JMXTomcat.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/jmx/JMXTomcat.java
Thu Jul 20 13:47:26 2006
@@ -208,8 +208,8 @@
   public boolean addContext(String path, String docBase) {
     boolean ret = false;
     try {
-      if (!this.getContexts().keySet().contains(checkContextName(path)))
-        ret = this.invokeVoidMethod(this.getCatalinaMBean(), "createStandardContext", new
Object[]{this.getHost().toString(), checkContextName(path), docBase}, new String[]{"String",
"String", "String"});
+      if (!this.getContexts().keySet().contains(checkContextName(path))) //TODO fix this
line
+        ret = this.invokeVoidMethod(this.getCatalinaMBean(), "createStandardContext", new
Object[]{this.getHost().toString(), checkContextName(path), docBase, false, false, false,
false}, new String[]{"java.lang.String", "java.lang.String", "java.lang.String", "boolean",
"boolean", "boolean", "boolean"});
     } catch (MalformedObjectNameException e) {
       if (logger.isInfoEnabled()) {
         logger.info("Exception: " + e.getMessage());
@@ -273,7 +273,7 @@
   public boolean removeContext(String context) {
     boolean ret = false;
     try {
-      ret = this.invokeVoidMethod(this.getCatalinaMBean(), "removeContext", new Object[]{this.getContextObjectName(context).toString()},
new String[]{"String"});
+      ret = this.invokeVoidMethod(this.getCatalinaMBean(), "removeContext", new Object[]{this.getContextObjectName(context).toString()},
new String[]{"java.lang.String"});
     } catch (MalformedObjectNameException e) {
       if (logger.isInfoEnabled()) {
         logger.info("Exception: " + e.getMessage());
@@ -310,6 +310,47 @@
     return ret;
   }
 
+  public String getStatusOfContext(String context) {
+    Integer temp = -97;
+
+	  try {
+		temp = (Integer) this.getMbsc().getAttribute(this.getContextObjectName(context), "state");
+	  } catch (InstanceNotFoundException e) {
+	    if (logger.isInfoEnabled()) {
+	      logger.info("Exception: " + e.getMessage());
+	    }
+	  } catch (MBeanException e) {
+	    if (logger.isInfoEnabled()) {
+	      logger.info("Exception: " + e.getMessage());
+	    }
+	  } catch (ReflectionException e) {
+	    if (logger.isInfoEnabled()) {
+	      logger.info("Exception: " + e.getMessage());
+	    }
+	  } catch (AttributeNotFoundException e) {
+	      if (logger.isInfoEnabled()) {
+	        logger.info("Exception: " + e.getMessage());
+	      }
+	  } catch (IOException e) {
+	    if (logger.isInfoEnabled()) {
+	      logger.info("Exception: " + e.getMessage());
+	    }
+	  } catch (MalformedObjectNameException e) {
+	    if (logger.isInfoEnabled()) {
+	      logger.info("Exception: " + e.getMessage());
+	    }
+	  }
+    String ret = "Unable to determine status of context ";
+    if (temp == 1) {
+      ret = "Context is running. ";
+    } else if (temp == 0) {
+      ret = "Context is stopped. ";
+    }
+    ret += context;
+
+   return ret;
+  }
+
   protected void buildVmName() {
     try {
       ObjectName service = new ObjectName("Catalina:type=Server");
@@ -370,7 +411,7 @@
 
   public String[] getStartCommand() {
     String sa = (javaHome + "/bin/java " + this.getJavaOptions() + ' ' + this.getStartClass()
+ " start");
-	  return sa.replaceAll("  +"," ").split(" ");
+    return sa.replaceAll("  +"," ").split(" ");
   }
 
   private boolean invokeVoidMethod(ObjectName obj, String method, Object[] params, String[]
signature) {
@@ -383,25 +424,29 @@
       }
     } catch (InstanceNotFoundException e) {
       if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
+        logger.info("INF Exception: " + e.getMessage());
       }
     } catch (MBeanException e) {
       if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
+        logger.info("MBE Exception: " + e.getMessage());
       }
     } catch (ReflectionException e) {
       if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
+        logger.info("RE Exception: " + e.getMessage());
+        logger.info("cause" + e.getCause().toString());
       }
     } catch (NullPointerException e) {
       if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
+        logger.info("NPE Exception: " + e.getMessage());
       }
     } catch (IOException e) {
       if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
+    	  logger.info("IO Exception: " + e.getMessage());
       }
+    } catch (Exception e) {
+    	logger.info("Exception: " + e.getMessage());
     }
+
     return ret;
 
   }

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/StatusOfContextTask.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/StatusOfContextTask.java?rev=424058&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/StatusOfContextTask.java
(added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/StatusOfContextTask.java
Thu Jul 20 13:47:26 2006
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you 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.lokahi.core.agent.task;
+
+import org.apache.lokahi.core.agent.AbstractAgentTask;
+import org.apache.lokahi.core.agent.callable.context.StatusOfContextCallable;
+import org.apache.lokahi.core.agent.dao.AgentJob;
+import org.apache.lokahi.core.agent.dao.TaskType;
+import org.apache.lokahi.core.agent.interfaces.AgentTomcat;
+import org.apache.lokahi.core.agent.util.ProcessFactory;
+import org.apache.lokahi.core.agent.util.TMCTaskException;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+
+/**
+ * @author Stephen Toback
+ * @version $Id$
+ */
+public class StatusOfContextTask extends AbstractAgentTask<String> {
+
+  public StatusOfContextTask(int jobId, TaskType t, AgentTomcat tc, String contextName) {
+    this.task = new FutureTask<String>(new StatusOfContextCallable(tc, contextName));
+    this.setJobId(jobId);
+    this.setType(t);
+  }
+
+  public StatusOfContextTask(AgentJob j) {
+    AgentTomcat tc = ProcessFactory.getTomcatByHttpPort(j.getOptions()[0]);
+    this.task = new FutureTask<String>(new StatusOfContextCallable(tc, j.getOptions()[1]));
+    this.setJobId(j.getPk());
+    this.setType(j.getType());
+  }
+
+  public StatusOfContextTask() {
+  }
+
+  public String getResult() throws TMCTaskException, ExecutionException, InterruptedException
{
+    return task.get();
+  }
+}
+
+
+

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/StatusOfContextTask.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/UndeployContextTask.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/UndeployContextTask.java?rev=424058&r1=424057&r2=424058&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/UndeployContextTask.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/task/UndeployContextTask.java
Thu Jul 20 13:47:26 2006
@@ -37,14 +37,14 @@
 
   /** @deprecated  */
   public UndeployContextTask(int jobId, TaskType t, AgentTomcat tc, String contextName, String
docBase) {
-    this.task = new FutureTask<Boolean>(new UndeployContextCallable(tc, contextName,
docBase));
+    this.task = new FutureTask<Boolean>(new UndeployContextCallable(tc, contextName));
     this.setJobId(jobId);
     this.setType(t);
   }
 
   public UndeployContextTask(AgentJob j) {
     AgentTomcat tc = ProcessFactory.getTomcatByHttpPort(j.getOptions()[0]);
-    this.task = new FutureTask<Boolean>(new UndeployContextCallable(tc, j.getOptions()[1],
j.getOptions()[2]));
+    this.task = new FutureTask<Boolean>(new UndeployContextCallable(tc, j.getOptions()[1]));
     this.setJobId(j.getPk());
     this.setType(j.getType());
   }

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/tomcat/HttpTomcat.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/tomcat/HttpTomcat.java?rev=424058&r1=424057&r2=424058&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/tomcat/HttpTomcat.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/tomcat/HttpTomcat.java
Thu Jul 20 13:47:26 2006
@@ -169,6 +169,10 @@
 	  return sa.replaceAll("  +"," ").split(" ");
   }
 
+  public String getStatusOfContext(String context) {
+    return this.getSessions(context);
+  }
+
   public Map<String, String> getEnv() {
     return env;
   }



Mime
View raw message