perfsonar-dev - perfsonar: r5302 - branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler
Subject: perfsonar development work
List archive
perfsonar: r5302 - branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5302 - branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler
- Date: Thu, 8 Oct 2009 10:15:11 -0400
Author: trzaszcz
Date: 2009-10-08 10:15:11 -0400 (Thu, 08 Oct 2009)
New Revision: 5302
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulerTask.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleScheduler.java
Log:
changed value of startupDelay of Scheduler, Scheduler action - threading
improved
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulerTask.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulerTask.java
2009-10-08 14:11:39 UTC (rev 5301)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulerTask.java
2009-10-08 14:15:11 UTC (rev 5302)
@@ -23,12 +23,14 @@
private long timestamp = 0; // last timestamp when action was
performed; 0 - never
private SchedulerAction action;
+
+ private Thread thread;
// --------------------------------------------------- Constructor
- public SchedulerTask(long interval, SchedulerAction action) {
+ public SchedulerTask(long interval, final SchedulerAction action) {
//check whether interval isn't lower than minimal
if (interval<MIN_INTERVAL) {
@@ -40,10 +42,20 @@
}
this.action = action;
this.timestamp = 0;
-
+
+ thread=getThread();
}
+
+ private Thread getThread(){
+ return new Thread() {
+ @Override
+ public void run() {
+// super.run();
+ action.runAction();
+ }
+ };
+ }
-
/**
* This constructor is used, when some action should be run in the future
*
@@ -52,12 +64,12 @@
* @param startTimestamp when should we start running action
*/
public SchedulerTask(
- long interval, SchedulerAction action, long startTimestamp) {
+ long interval, final SchedulerAction action, long startTimestamp) {
this(interval, action); //interval in seconds
timestamp = startTimestamp - (interval*1000);
-
+
}
@@ -82,13 +94,14 @@
//TODO: to be changed - should be thread pool?
//run action in thread
- new Thread() {
- @Override
- public void run() {
- super.run();
- action.runAction();
- }
- }.start();
+
+ if(thread.isAlive()){
+ // do nothing
+ logger.debug("last action is already running");
+ }else{
+ thread=getThread();
+ thread.start();
+ }
//if action is being performed return true
return true;
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleScheduler.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleScheduler.java
2009-10-08 14:11:39 UTC (rev 5301)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleScheduler.java
2009-10-08 14:15:11 UTC (rev 5302)
@@ -38,7 +38,7 @@
/**
* Scheduler will start after this time (in seconds)
*/
- protected int startDelayTime = 10; //sec
+ protected int startDelayTime = 40; //sec
protected static final Logger logger =
Logger.getLogger(SimpleScheduler.class.getName());
- perfsonar: r5302 - branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler, svnlog, 10/08/2009
Archive powered by MHonArc 2.6.16.