272. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/11/2019 10:54:15 AM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

272.1 Files compared

# Location File Last Modified
1 HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\scheduling SchedulerConfigurator.java Wed May 29 15:26:24 2019 UTC
2 HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\scheduling SchedulerConfigurator.java Mon Jun 10 19:27:47 2019 UTC

272.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 786
Changed 1 2
Inserted 0 0
Removed 0 0

272.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

272.4 Active regular expressions

No regular expressions were active.

272.5 Comparison detail

  1   /********* ********** ********** ********** ********** ********** *********
  2    * Copyrig ht 2004 VH A. All rig hts reserv ed
  3    ********* ********** ********** ********** ********** ********** *********/
  4   // Package
  5   package go v.va.med.f w.scheduli ng;
  6  
  7   // Librari es class
  8   import org .apache.co mmons.lang .Validate;
  9   import org .quartz.Cr onSchedule Builder;
  10   import org .quartz.Cr onTrigger;
  11   import org .quartz.Jo bDetail;
  12   import org .quartz.Jo bPersisten ceExceptio n;
  13   import org .quartz.Sc heduler;
  14   import org .quartz.Sc hedulerExc eption;
  15   import org .quartz.Tr igger;
  16   import org .quartz.Tr igger.Trig gerState;
  17   import org .quartz.Tr iggerBuild er;
  18   import org .springfra mework.sch eduling.qu artz.CronT riggerBean ;
  19   import org .springfra mework.sch eduling.qu artz.JobDe tailAwareT rigger;
  20   import org .springfra mework.tra nsaction.P latformTra nsactionMa nager;
  21   import org .springfra mework.tra nsaction.T ransaction Definition ;
  22   import org .springfra mework.tra nsaction.T ransaction Exception;
  23   import org .springfra mework.tra nsaction.T ransaction Status;
  24   import org .springfra mework.tra nsaction.s upport.Def aultTransa ctionDefin ition;
  25  
  26   import gov .va.med.fw .batchproc ess.BatchP rocessServ ice;
  27   import gov .va.med.fw .model.bat chprocess. JobConfig;
  28   import gov .va.med.fw .service.A bstractCom ponent;
  29   import gov .va.med.fw .util.Stri ngUtils;
  30   import gov .va.med.fw .util.date .TimeZoneU tils;
  31  
  32   /**
  33    * A typic al usage o f this cla ss is to r egister tr iggers and  job detai ls defined
  34    * in ejb  modules an d and war  modules us ing one co mmon singl eton sched uler
  35    * defined  at the EA R level. F or instanc e, in ESR,  a common  scheduler  is defined
  36    * in a co mmon.jar a nd schedul er post pr ocessor be ans are de fined in U I and
  37    * Messagi ng to allo w UI and M essaging t o register  their own  triggers,  and job
  38    * details .
  39    * 
  40    * <p>
  41    * Note th at trigger s that are  currently  paused in  the JobSt ore will N OT be
  42    * overwri tten.
  43    * 
  44    * @author   DN S
  45    */
  46   public cla ss Schedul erConfigur ator exten ds Abstrac tComponent  {
  47  
  48           /* *
  49            *  An instan ce of a si ngleton sc heduler
  50            * /
  51           pr ivate Sche duler sche duler = nu ll;
  52  
  53           /* *
  54            *  A list of  triggers  to add to  a schedule r
  55            * /
  56           pr ivate Trig ger[] trig gers = nul l;
  57  
  58           /* *
  59            *  A list of  job detai ls to add  to a sched uler
  60            * /
  61           pr ivate JobD etail[] jo bDetails =  null;
  62  
  63           /* *
  64            *  A flag to  overwrite  existing  jobs in th e schedule r An insta nce of
  65            *  overwrite ExistingJo bs
  66            * /
  67           pr ivate bool ean overwr iteExistin gJobs = tr ue;
  68  
  69           /* *
  70            *  A name of  a transac tion for r egistering  job trigg ers
  71            *  in the af terPropert iesSet met hod
  72            * /
  73           pr ivate Stri ng transac tionName =  "schedule TriggersAn dJobs";
  74           
  75           /* *
  76            *  A transac tion attri bute to be  used for  registerin g job trig gers
  77            *  in the af terPropert iesSet met hod
  78            * /
  79           pr ivate int  transactio nAttribute  = Transac tionDefini tion.PROPA GATION_REQ UIRED;
  80           
  81           /* *
  82            *  A transac tion time  out in sec onds to be  used for  registerin g job trig gers
  83            *  in the af terPropert iesSet met hod.  A de fault valu e is 600 s econds.
  84            * /
  85           pr ivate int  transactio nTimeout =  600;
  86                    
  87           /* *
  88            *  Similar p aradigm fo r Spring's  Scheduler FactoryBea n. All ope rations to
  89            *  modify da tabase tri ggers/jobs  need to b e wrapped  in a Trans action so
  90            *  cluster r ace condit ions do no t occur.
  91            *  
  92            *  #see org. springfram ework.sche duling.qua rtz.Schedu lerFactory Bean#
  93            *  registerJ obsAndTrig gers
  94            * /
  95           pr ivate Plat formTransa ctionManag er transac tionManage r;
  96           
  97           /* *
  98            *  A service  process b atch jobs 
  99            * /
  100           pr ivate Batc hProcessSe rvice batc hProcessSe rvice;
  101  
  102           /* *
  103            *  A default  construct or
  104            * /
  105           pu blic Sched ulerConfig urator() {
  106                    supe r();
  107           }
  108  
  109           /* *
  110            *  Sets a fl ag to over write exis ting jobs  in the sch eduler
  111            *  
  112            *  @return R eturns the  overwrite ExistingJo bs.
  113            * /
  114           pu blic boole an isOverw riteExisti ngJobs() {
  115                    retu rn overwri teExisting Jobs;
  116           }
  117  
  118           /* *
  119            *  Returns a  flag indi cating whe ther overw riting job s is desir ed
  120            *  
  121            *  @param ov erwriteExi stingJobs  The overwr iteExistin gJobs to s et.
  122            * /
  123           pu blic void  setOverwri teExisting Jobs(boole an overwri teExisting Jobs) {
  124                    this .overwrite ExistingJo bs = overw riteExisti ngJobs;
  125           }
  126  
  127           /* *
  128            *  An instan ce of a si ngleton sc heduler
  129            *  
  130            *  @param sc heduler Th e singleto n schedule r to set.
  131            * /
  132           pu blic void  setSchedul er(Schedul er schedul er) {
  133                    this .scheduler  = schedul er;
  134           }
  135  
  136           /* *
  137            *  A list of  triggers  to registe r to a sch eduler at  start-up
  138            *  
  139            *  @param tr iggers The  list of t riggers to  set.
  140            * /
  141           pu blic void  setTrigger s(Trigger[ ] triggers ) {
  142                    this .triggers  = triggers ;
  143           }
  144  
  145           /* *
  146            *  A list of  job detai ls to regi ster to a  scheduler  at start-u p
  147            *  
  148            *  @param jo bDetails T he list of  job detai ls to set
  149            * /
  150           pu blic void  setJobDeta ils(JobDet ail[] jobD etails) {
  151                    this .jobDetail s = jobDet ails;
  152           }
  153  
  154           /* *
  155            *  Sets a tr ansaction  attribute  used for r egistering  scheduled  jobs
  156            *  in the af terPropert iesSet met hod
  157            *  
  158            *  @param tr ansactionA ttribute a  transacti on attribu te to be s et
  159            * /
  160           pu blic void  setTransac tionAttrib ute(int tr ansactionA ttribute)  {
  161                    this .transacti onAttribut e = transa ctionAttri bute;
  162           }
  163  
  164           /* *
  165            *  Sets a na me of a tr ansaction  used for r egistering  scheduled  jobs
  166            *  in the af terPropert iesSet met hod
  167            *  
  168            *  @param tr ansactionN ame a tran saction na me to be s et
  169            * /
  170           pu blic void  setTransac tionName(S tring tran sactionNam e) {
  171                    this .transacti onName = t ransaction Name;
  172           }
  173           
  174           /* *
  175            *  Sets a tr ansaction  time-out u sed for re gistering  scheduled  jobs
  176            *  in the af terPropert iesSet met hod
  177            *  
  178            *  @param tr ansactionA ttribute a  transacti on attribu te to be s et
  179            * /
  180           pu blic void  setTransac tionTimeou t(int tran sactionTim eout) {
  181                    this .transacti onTimeout  = transact ionTimeout ;
  182           }
  183           
  184           /* *
  185            *  Registers  a list of  triggers  and job de tails to a  scheduler  at start- up
  186            *  
  187            *  @see org. springfram ework.bean s.factory. Initializi ngBean#aft erProperti esSet()
  188            * /
  189           pu blic void  afterPrope rtiesSet()  throws Ex ception {
  190                    supe r.afterPro pertiesSet ();
  191                    Vali date.notNu ll(this.sc heduler, " A schedule r is requi red");
  192  
  193                    Tran sactionSta tus transa ctionStatu s = null;
  194                    if ( this.trans actionMana ger != nul l) {
  195                             Defaul tTransacti onDefiniti on dtf = n ew Default Transactio nDefinitio n();
  196                             dtf.se tName(this .transacti onName);
  197                             dtf.se tTimeout(t his.transa ctionTimeo ut);
  198                             dtf.se tPropagati onBehavior (this.tran sactionAtt ribute);
  199                             transa ctionStatu s = this.t ransaction Manager.ge tTransacti on(dtf);
  200                    }
  201                    try  {
  202                             // Reg ister a li st of trig gers to a  scheduler
  203                             if (tr iggers !=  null && tr iggers.len gth > 0) {
  204                                      schedule Triggers(t riggers);
  205                             }
  206  
  207                             // Reg ister a li st of job  details to  a schedul er
  208                             if (jo bDetails ! = null &&  jobDetails .length >  0) {
  209                                      schedule JobDetails (jobDetail s);
  210                             }
  211                    } ca tch (Throw able ex) {
  212                             if (tr ansactionS tatus != n ull) {
  213                                      try {
  214                                               this.trans actionMana ger.rollba ck(transac tionStatus );
  215                                      } catch  (Transacti onExceptio n tex) {
  216                                               logger.err or("Job re gistration  exception  overridde n by rollb ack except ion", ex);
  217                                               throw tex;
  218                                      }
  219                             }
  220                             if (ex  instanceo f Schedule rException ) {
  221                                      throw (S chedulerEx ception) e x;
  222                             }
  223                             if (ex  instanceo f Exceptio n) {
  224                                      throw ne w Schedule rException ("Registra tion of jo bs and tri ggers fail ed: "
  225                                                       +  ex.getMess age(), (Ex ception) e x);
  226                             }
  227                             throw  new Schedu lerExcepti on("Regist ration of  jobs and t riggers fa iled: "
  228                                               + ex.getMe ssage());
  229                    }
  230                    if ( transactio nStatus !=  null) {
  231                             this.t ransaction Manager.co mmit(trans actionStat us);
  232                    }
  233           }
  234  
  235           /* *
  236            *  Schedule  all regist ered trigg ers to a s cheduler
  237            *  
  238            *  @param tr iggers
  239            *              A list o f triggers  to schedu le
  240            * /
  241           pr otected vo id schedul eTriggers( Trigger[]  triggers)  throws Sch edulerExce ption {
  242                    Trig ger trigge r = null;
  243                    JobD etail jobD etail = nu ll;
  244                    JobC onfig jobC onfig = nu ll;
  245  
  246                    // L oop throug h a list o f triggers  to regist er
  247                    for  (int i = 0 ; i < trig gers.lengt h; i++) {
  248                             trigge r = trigge rs[i];
  249  
  250                             // Che ck if the  Trigger is  aware of  an associa ted JobDet ail.
  251                             jobDet ail = trig ger instan ceof JobDe tailAwareT rigger ? ( (JobDetail AwareTrigg er) trigge r)
  252                                               .getJobDet ail()
  253                                               : null;
  254                                              
  255                             //upda te all tri ggers with  the updat ed cron ex pression f rom the da tabase if  provided
  256                             try {
  257                                      if (trig ger instan ceof CronT riggerBean  && (jobDe tail != nu ll)) {
  258                                               CronTrigge rBean cron Trigger =  (CronTrigg erBean)tri gger;
  259                                               jobConfig  = batchPro cessServic e.getJobCo nfig(jobDe tail.getKe y().getNam e(), jobDe tail.getKe y().getGro up());
  260                                               logger.deb ug("Trigge r "+ jobDe tail.getKe y().getNam e()+" set  for conExp :  "+ cron Trigger.ge tCronExpre ssion() );
  261                                               if (jobCon fig != nul l) {
  262                                                       St ring jobSc hedule = j obConfig.g etJobSched ule();                                                     
  263                                                       if  (StringUt ils.isNotE mpty(jobSc hedule) &&  !jobSched ule.equals (cronTrigg er.getCron Expression ())){
  264                                                                
  265                                                                Cron Trigger cr onTrigger2  = Trigger Builder
  266                                                                                  .newTrig ger()
  267                                                                                  .withSch edule(Cron ScheduleBu ilder.cron Schedule(j obConfig.g etJobSched ule()).inT imeZone(Ti meZoneUtil s.getTimeZ one()))
  268                                                                                  .build() ;
  269                                                                
  270                                                                sche duler.resc heduleJob( cronTrigge r2.getKey( ), cronTri gger2);
  271                                                                
  272                                                       }
  273                                               }
  274                                      }
  275                             }catch  (Exceptio n e) {                             
  276                                      logger.e rror(e);
  277                             }
  278  
  279                             // Che ck if a tr igger exis ts
  280                             Trigge r existing Trigger =  this.sched uler.getTr igger(trig ger.getKey ());
  281                             Trigge rState exi stingTrigg erStatus =  this.sche duler.getT riggerStat e(trigger. getKey());
  282                             if (ex istingTrig ger == nul l) {
  283                                      // no tr igger in J obStore... ...add Tri gger and J obDetail ( if
  284                                      // prese nt)
  285  
  286                                      if (jobD etail != n ull) {
  287                                               this.addJo bDetailToS cheduler(j obDetail);
  288                                      }
  289  
  290                                      try {
  291                                               this.sched uler.sched uleJob(tri gger);
  292                                      } catch  (JobPersis tenceExcep tion e) {
  293                                               if (logger .isDebugEn abled()) {
  294                                                       lo gger
  295                                                                         .debug (
  296                                                                                           "Unexpecte dly found  existing j ob, assuma bly due to  cluster r ace condit ion",
  297                                                                                           e);
  298                                               }
  299                                               if (this.o verwriteEx istingJobs  && !(trig ger instan ceof Immut ableInitTr igger)) {
  300                                                       th is.schedul er.resched uleJob(tri gger.getKe y(), trigg er);
  301                                               }
  302                                      }
  303                             } else  {
  304                                      // yes t rigger in  JobStore.. ...conditi onally upd ate Trigge r and
  305                                      // JobDe tail (if p resent)
  306  
  307                                      // note:  don't ove rwrite tri ggers that  are curre ntly pause d
  308                                      if (this .overwrite ExistingJo bs && !(tr igger inst anceof Imm utableInit Trigger)
  309                                                       &&  existingT riggerStat us != Trig gerState.P AUSED ) {
  310                                               if (jobDet ail != nul l) {
  311                                                       th is.addJobD etailToSch eduler(job Detail);
  312                                               }
  313                                               // update  trigger in  database
  314                                               this.sched uler.resch eduleJob(t rigger.get Key(), tri gger);
  315                                      }
  316                             }
  317                    }
  318           }
  319  
  320           /* *
  321            *  Schedule  all regist ered job d etails to  a schedule r
  322            *  
  323            *  @param tr iggers
  324            *              A list o f triggers  to schedu le
  325            * /
  326           pr otected vo id schedul eJobDetail s(JobDetai l[] jobDet ails) thro ws Schedul erExceptio n {
  327                    for  (int i = 0 ; i < trig gers.lengt h; i++) {
  328                             addJob DetailToSc heduler(jo bDetails[i ]);
  329                    }
  330           }
  331  
  332           /* *
  333            *  Add a job  to a sche duler. Ove rwrite a j ob if need ed
  334            *  
  335            *  @param jo b
  336            *              A job to  add to a  scheduler
  337            *  @throws S chedulerEx ception
  338            *               Thrown  in failed  to add a j ob
  339            * /
  340           pr ivate void  addJobDet ailToSched uler(JobDe tail job)  throws Sch edulerExce ption {
  341  
  342                    // F ound an ex isting job
  343                    if ( this.sched uler.getJo bDetail(jo b.getKey() ) != null)  {
  344                             if (th is.overwri teExisting Jobs && !( job instan ceof Clust erAwareJob DetailBean )) {
  345                                      this.sch eduler.add Job(job, t his.overwr iteExistin gJobs);
  346                             }
  347                    } el se {
  348                             try {
  349                                      // To ad d a job wi thout a tr igger, a j ob must be  durable t o
  350                                      // prese rve the ex isting job . Otherwis e, a job m ust be
  351                                      // overw ritten
  352                                      boolean  overwrite  = !job.isD urable() ?  true : jo b.isDurabl e();
  353                                      this.sch eduler.add Job(job, o verwrite);
  354                             } catc h (Schedul erExceptio n e) {
  355                                      if (logg er.isDebug Enabled())  {
  356                                               logger
  357                                                                .deb ug(
  358                                                                                  "Unexpec tedly foun d existing  job, assu mably due  to cluster  race cond ition",
  359                                                                                  e);
  360                                      }
  361                                      // This  means that  a race co ndition mi ght
  362                                      // have  happened i n a cluste r environm ent
  363                                      if (this .overwrite ExistingJo bs && !(jo b instance of Cluster AwareJobDe tailBean))  {
  364                                               // Don't c are whethe r a job is  durable o r not, ove rwrite it
  365                                               // anyway
  366                                               this.sched uler.addJo b(job, tru e);
  367                                      }
  368                             }
  369                    }
  370           }
  371  
  372           /* *
  373            *  @return R eturns the  transacti onManager.
  374            * /
  375           pu blic Platf ormTransac tionManage r getTrans actionMana ger() {
  376                    retu rn transac tionManage r;
  377           }
  378  
  379           /* *
  380            *  @param tr ansactionM anager
  381            *              The tran sactionMan ager to se t.
  382            * /
  383           pu blic void  setTransac tionManage r(Platform Transactio nManager t ransaction Manager) {
  384                    this .transacti onManager  = transact ionManager ;
  385           }
  386  
  387           pu blic Batch ProcessSer vice getBa tchProcess Service()  {
  388                    retu rn batchPr ocessServi ce;
  389           }
  390  
  391           pu blic void  setBatchPr ocessServi ce(BatchPr ocessServi ce batchPr ocessServi ce) {
  392                    this .batchProc essService  = batchPr ocessServi ce;
  393           }
  394   }