SchedulerMonitorEvent.java
上传用户:qing5858
上传日期:2015-10-27
资源大小:6056k
文件大小:2k
源码类别:

搜索引擎

开发平台:

Java

  1. package net.javacoding.jspider.api.event.monitor;
  2. /**
  3.  * $Id: SchedulerMonitorEvent.java,v 1.4 2003/04/03 15:57:14 vanrogu Exp $
  4.  */
  5. public class SchedulerMonitorEvent extends MonitorEvent {
  6.     protected int jobCount;
  7.     protected int spiderJobsCount;
  8.     protected int thinkerJobsCount;
  9.     protected int jobsDone;
  10.     protected int spiderJobsDone;
  11.     protected int thinkerJobsDone;
  12.     protected int blockedCount;
  13.     protected int assignedCount;
  14.     public SchedulerMonitorEvent ( int jobCount, int spiderJobsCount, int thinkerJobsCount, int jobsDone, int spiderJobsDone, int thinkerJobsDone, int blockedCount, int assignedCount ) {
  15.         this.jobCount= jobCount;
  16.         this.spiderJobsCount= spiderJobsCount;
  17.         this.thinkerJobsCount= thinkerJobsCount;
  18.         this.jobsDone = jobsDone;
  19.         this.spiderJobsDone = spiderJobsDone;
  20.         this.thinkerJobsDone = thinkerJobsDone;
  21.         this.blockedCount = blockedCount;
  22.         this.assignedCount = assignedCount;
  23.     }
  24.     public String toString ( ) {
  25.         int pctDone = 0;
  26.         if ( getJobCount() != 0 ) {
  27.             pctDone = ((getJobsDone()*100)/getJobCount());
  28.         }
  29.         int spidersPctDone = 0;
  30.         if ( getSpiderJobsCount() != 0) {
  31.             spidersPctDone = ((getSpiderJobsDone()*100)/getSpiderJobsCount());
  32.         }
  33.         int thinkersPctDone = 0;
  34.         if ( getThinkerJobsCount() != 0) {
  35.             thinkersPctDone = ((getThinkerJobsDone()*100)/getThinkerJobsCount());
  36.         }
  37.         return "Job monitor: " + pctDone + "% (" + getJobsDone() + "/" + getJobCount() + ")  [S:" + spidersPctDone + "% (" + getSpiderJobsDone() + "/" + getSpiderJobsCount() + ") | T:" + thinkersPctDone + "% (" + getThinkerJobsDone() + "/" + getThinkerJobsCount() + ")] [blocked:" + blockedCount + "] [assigned:" + assignedCount + "]";
  38.     }
  39.     public String getComment() {
  40.         return toString ( );
  41.     }
  42.     public int getJobCount() {
  43.         return jobCount;
  44.     }
  45.     public int getSpiderJobsCount() {
  46.         return spiderJobsCount;
  47.     }
  48.     public int getThinkerJobsCount() {
  49.         return thinkerJobsCount;
  50.     }
  51.     public int getJobsDone() {
  52.         return jobsDone;
  53.     }
  54.     public int getSpiderJobsDone() {
  55.         return spiderJobsDone;
  56.     }
  57.     public int getThinkerJobsDone() {
  58.         return thinkerJobsDone;
  59.     }
  60.     public int getBlockedCount ( ) {
  61.         return blockedCount;
  62.     }
  63.     public int getAssignedCount ( ){
  64.         return assignedCount;
  65.     }
  66. }