Blog Update -


The blog will be updated at least once a week. Don't hesitate in asking for samples or suggesting paths that you think others will find useful.

Tuesday, February 14, 2012

Monitor Running Jobs

The following method enables you to query your Intelligent Server and see the ongoing report executions. You must keep in mind that a report will go through different states while the date provided points to the job's creation date. This means that to calculate the running time you would have to track the job status change and then save that time.

private void getReportsJobs() {
      WebObjectsFactory lObjectFactory = mServerSession
                  .getFactory();
      // The JobSource object enables you to monitor running Jobs
      JobSource lJobSource
             = (JobSource) lObjectFactory.getMonitorSource(
                      EnumWebMonitorType.WebMonitorTypeJob);

      lJobSource.setLevel(EnumDSSXMLLevelFlags.DssXmlBrowsingLevel);
      JobResults lCurrentJobs;
      try {
            lCurrentJobs = lJobSource.getJobs();
            int lJobsCount = lCurrentJobs.getCount();
            if (lJobsCount > 0) {
                  System.out.println("Number of Jobs: "
                              + lJobsCount);
                  for (int lIndex = 0; lIndex < lJobsCount; lIndex++) {
                        System.out.println("Checking Job #"
                                    + (lIndex + 1));
                        Job lSingleJob = lCurrentJobs.get(lIndex);
                        int lJobIDint = lSingleJob.getJobID();
                        int lJobStatusInt = lSingleJob.getJobStatus();
                        String lOwner = lSingleJob.getUserName();
                        String lDescription = lSingleJob
                                    .getDescription();
                        String lProject = lSingleJob.getProjectName();

                        int lJobExecutingConst = EnumDSSXMLJobStatus.DssXmlJobStatusExecuting;
                        if (lJobStatusInt == lJobExecutingConst) {
                              // Check the Status.
                        }
                        String lJobDescription = "ID: "
                                    + lJobIDint + ", Status: "
                                    + lJobStatusInt + ", Owner: "
                                    + lOwner + ", Description: "
                                    + lDescription + ", Project: "
                                    + lProject;
                        System.out.println(lJobDescription);
                  }
            } else {
                  System.out.println("No Jobs found");
            }
      } catch (WebObjectsAdminException lException) {
            lException.printStackTrace();
      }
}

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete