You are viewing a plain text version of this content. The canonical link for it is here.
Posted to lokahi-commits@incubator.apache.org by to...@apache.org on 2006/06/23 19:03:04 UTC
svn commit: r416797 - in
/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent:
TMCAgent.java dao/AgentJob.java runnable/JobScheduler.java
runnable/ReportingThread.java
Author: toback
Date: Fri Jun 23 12:03:04 2006
New Revision: 416797
URL: http://svn.apache.org/viewvc?rev=416797&view=rev
Log:
Updates to agent to enable jobs to be reported back, and handle jobs with prereqs.
Added:
incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/ReportingThread.java
Modified:
incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/TMCAgent.java
incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/dao/AgentJob.java
incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/JobScheduler.java
Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/TMCAgent.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/TMCAgent.java?rev=416797&r1=416796&r2=416797&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/TMCAgent.java (original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/TMCAgent.java Fri Jun 23 12:03:04 2006
@@ -16,6 +16,7 @@
package org.apache.lokahi.core.agent;
import org.apache.lokahi.core.agent.runnable.JobScheduler;
+import org.apache.lokahi.core.agent.runnable.ReportingThread;
import org.apache.lokahi.core.common.database.DerbyBroker;
import org.apache.axis.transport.http.SimpleAxisServer;
import org.apache.log4j.Logger;
@@ -31,7 +32,7 @@
* Main thread that controls the Agent's sub threads.
*
* @author Stephen Toback
- * @version $Id: TMCAgent.java,v 1.1 2006/03/02 19:19:44 drtobes Exp $
+ * @version $id$
*/
public class TMCAgent {
static final Logger logger = Logger.getLogger(TMCAgent.class);
@@ -98,6 +99,7 @@
//start the Job Scheduler
new Thread(new JobScheduler(), "JobScheduler");
+ new Thread(new ReportingThread(), "ReportingThread");
System.out.println("Job Scheduler started.");
}
Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/dao/AgentJob.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/dao/AgentJob.java?rev=416797&r1=416796&r2=416797&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/dao/AgentJob.java (original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/dao/AgentJob.java Fri Jun 23 12:03:04 2006
@@ -201,6 +201,10 @@
return j;
}
+ public boolean canRunNow() {
+ return (parentName == null || "".equals(parentName));
+ }
+
public static Collection<AgentJob> getJobs(State s) {
Collection<AgentJob> c = new TMCCollectionImpl<AgentJob>();
for (AgentJob j : broker.values()) {
Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/JobScheduler.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/JobScheduler.java?rev=416797&r1=416796&r2=416797&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/JobScheduler.java (original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/JobScheduler.java Fri Jun 23 12:03:04 2006
@@ -26,7 +26,7 @@
/**
* @author Stephen Toback
- * @version $Id: JobScheduler.java,v 1.2 2006/03/06 22:31:44 drtobes Exp $
+ * @version $id$
*/
public class JobScheduler implements Runnable {
static final Logger logger = Logger.getLogger(JobScheduler.class);
@@ -48,6 +48,7 @@
while (shouldRun()) {
Collection<AgentJob> jobs = AgentJob.getJobs(State.NEW);
for (AgentJob j : jobs) {
+ if (j.canRunNow()) {
AgentTask task = TaskFactory.getTask(j);
if (task != null) {
Runnable r = task.getRunnable();
@@ -73,6 +74,7 @@
}
}
}
+ }
}
try {
Thread.sleep(1000);
Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/ReportingThread.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/ReportingThread.java?rev=416797&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/ReportingThread.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/agent/runnable/ReportingThread.java Fri Jun 23 12:03:04 2006
@@ -0,0 +1,59 @@
+/*
+* Copyright 2006 The Apache Software Foundation
+*
+* 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.lokahi.core.agent.runnable;
+
+import org.apache.log4j.Logger;
+import org.apache.lokahi.core.agent.dao.AgentJob;
+import org.apache.lokahi.core.api.state.State;
+
+import java.util.Collection;
+
+/**
+ * @author Stephen Toback
+ * @version $id$
+ */
+public class ReportingThread implements Runnable {
+ static final Logger logger = Logger.getLogger(JobScheduler.class);
+
+ private static volatile boolean run = false;
+
+ public static boolean shouldRun() {
+ return run;
+ }
+
+ public static void setRun(boolean run) {
+ ReportingThread.run = run;
+ }
+
+ public void run() {
+ while (shouldRun()) {
+ Collection<AgentJob> jobs = AgentJob.getJobs(State.COMPLETE);
+ jobs.addAll(AgentJob.getJobs(State.FAILED));
+ for (AgentJob j : jobs) {
+ //check to see if the job has any childern in the queue and update accordingly
+ //report status back to the console.
+ //
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Exception: " + e.getMessage());
+ }
+ }
+ }
+ }
+}