By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,658 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,658 IT Pros & Developers. It's quick & easy.

migration single processor to dual processor problem

P: n/a
Hello,

I have an application, that has been running on a single processor server
for more then a year without any problems. Now I'm migrating to a dual
processor server, and I'm experiencing problems with threading.

The application is actually a kind of job schedular. For all jobs, I can set
a recurring interval (daily,weekly, monthly etc) at which the specific job
should be started. We program each job, according to an interface. Examples
of jobs are: server monitoring, reporting, messaging etc.

The job itself maintains a status. When it's complete, it's status is set to
ready.

The job-schedular looks at certain times for two things: Should I start a
new job and Is there a job with status Ready which should be stopped.

the code for stopping a job is only a:
ji.InstanceThread.Abort();
ji.InstanceThread.Join(1000);
MJSJobList._jobList.Remove(ji);
What I now see, is that on the single processor server, this works, and the
job is removed from the list.
On the dual-processor server, however the job remains in the list with
status "Ready"..

Am I missing somethinge here ? The code worked perfectly on the other server
for a very long time.

Thanks in advance,
Michel Meex

Jun 12 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ok, here's some more code.

In the windows service, a timer executes the following method:
internal void MonitorJobs()
{
ArrayList al = this.RetrieveJobsState();
foreach(MJSJobState js in al)
{
//If job is ready
if (js.JobState == MJSJobStatic.JobState.Ready)
{
TempLogging(js.JobName,"Job found, status ready, should stop");
bool _found = false;
//stop and clear job
foreach (MJSJobInstance ji in MJSJobList._jobList)
{
if (ji.JobData.JobName == js.JobName)
{
_found = true;
this.JobStop(ji.JobData);
break; }
}
TempLogging(js.JobName,"Job found: " + _found.ToString());
}
}
}

the method JobStop contains the following:
public void JobStop(MJSJobData jobData)
{
if (jobData != null)
{
//if job is running
if (this.JobIsRunning(jobData) ==
MJSJobStatic.ThreeValueBool.True)
{
bool jobStopped = false;
//Find job instance in joblist
foreach (MJSJobInstance ji in MJSJobList._jobList)
{
if (jobData != null)
{
if (jobData.JobName == ji.JobData.JobName)
{
//Call job stop method (IJob interface),
((IJob) ji.InstanceObject).Stop();
//Clear object reference
ji.InstanceObject = null;
//Stop process / end thread
ji.InstanceThread.Abort();
ji.InstanceThread.Join(1000);

//debugging info
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = ji.JobData.JobName;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Information;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = "trying to stop.....debug info";
JobHistory.Add(_tempHistoryNew);
//end debugging info

//Remove job from JobList
MJSJobList._jobList.Remove(ji);
jobStopped = true;
break;
}
}
}

if (jobStopped)
{
//Log event
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = jobData.JobName;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Information;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = JOB_STOPPED;
JobHistory.Add(_tempHistoryNew);
}
else
{
//Log event
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = jobData.JobName;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Error;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = "Job could not be stopped.";
JobHistory.Add(_tempHistoryNew);
}
}
else
{
//Write something to the log
//Log event
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = jobData.JobName;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Error;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = "Job could not be stopped. The job is not
running.";
JobHistory.Add(_tempHistoryNew);
}
}
else
{
//Write something to the log if running state of job could not be
determined
//Log event
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = string.Empty;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Error;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = "Job could not be stopped. No job provided.";
JobHistory.Add(_tempHistoryNew);
}
}

I hope you can do something with this..
Regards,
Michel

Jun 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.