264. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 2/4/2019 11:34:04 AM Eastern Standard 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.

264.1 Files compared

# Location File Last Modified
1 MHPRO_v1.x.zip\mhpro-resources-master@a26412b610c.zip\ws\src\main\java\gov\va\mobile\vamf\mhpro\datalayer\impl QuartzSemaphoreRepositoryImpl.java Tue Nov 14 19:31:17 2017 UTC
2 MHPRO_v1.x.zip\mhpro-resources-master@a26412b610c.zip\ws\src\main\java\gov\va\mobile\vamf\mhpro\datalayer\impl QuartzSemaphoreRepositoryImpl.java Mon Feb 4 15:13:47 2019 UTC

264.2 Comparison summary

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

264.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

264.4 Active regular expressions

No regular expressions were active.

264.5 Comparison detail

  1   package go v.va.mobil e.vamf.mhp ro.datalay er.impl;
  2  
  3   import sta tic org.sp ringframew ork.data.m ongodb.cor e.query.Cr iteria.whe re;
  4  
  5   import jav a.sql.Time stamp;
  6  
  7   import org .springfra mework.bea ns.factory .annotatio n.Autowire d;
  8   import org .springfra mework.dao .Duplicate KeyExcepti on;
  9   import org .springfra mework.dat a.mongodb. core.Mongo Template;
  10   import org .springfra mework.dat a.mongodb. core.query .Criteria;
  11   import org .springfra mework.dat a.mongodb. core.query .Query;
  12   import org .springfra mework.ste reotype.Re pository;
  13   import org .springfra mework.tra nsaction.a nnotation. Propagatio n;
  14   import org .springfra mework.tra nsaction.a nnotation. Transactio nal;
  15  
  16   import com .mongodb.W riteResult ;
  17  
  18   import gov .va.mobile .vamf.mhpr o.datalaye r.QuartzSe maphoreRep ositoryCus tom;
  19   import gov .va.mobile .vamf.mhpr o.domain.J obType;
  20   import gov .va.mobile .vamf.mhpr o.domain.Q uartzSemap hore;
  21   import gov .va.mobile .vamf.mhpr o.domain.Q uartzSemap horeLock;
  22  
  23   /**
  24    * 
  25    * @author   PII
  26    *
  27    */
  28   @Repositor y
  29   @Transacti onal(propa gation = P ropagation .REQUIRES_ NEW)
  30   public cla ss QuartzS emaphoreRe positoryIm pl impleme nts Quartz SemaphoreR epositoryC ustom {
  31  
  32           pr ivate stat ic final S tring SYST EM_USER =  "system";
  33  
  34           @A utowired
  35           pr ivate Mong oTemplate  mongoTempl ate;
  36  
  37           St ring pidAt HostName =  java.lang .managemen t.Manageme ntFactory. getRuntime MXBean().g etName();
  38           in t delayCon firmationM illis = 20 00;
  39  
  40           pu blic stati c interfac e PidGener ator {
  41                    Stri ng getPid( );
  42           }
  43  
  44           pu blic class  DefaultPi dGenerator  implement s PidGener ator {
  45                    publ ic String  getPid() {
  46                             return  pidAtHost Name;
  47                    }
  48           }
  49  
  50           @O verride
  51           pu blic Quart zSemaphore Lock tryLo ck(JobType  jobType,  int forceI fExceededS econds) {
  52                    retu rn tryLock Internal(j obType, fo rceIfExcee dedSeconds , new Defa ultPidGene rator());
  53           }
  54  
  55           Qu artzSemaph oreLock tr yLockInter nal(JobTyp e jobType,  int force IfExceeded Seconds, P idGenerato r generato r) {
  56                    Stri ng jobIden tifier = S tring.valu eOf(jobTyp e.getCode( ));
  57                    Stri ng pid = g enerator.g etPid();
  58  
  59                    Time stamp nowN oMillis =  getNowNoMi llis();
  60  
  61                    Quar tzSemaphor e qs = new  QuartzSem aphore();
  62                    qs.s et_id(jobI dentifier) ;
  63                    qs.s etPidAtHos tname(pid) ;
  64                    qs.s etJobIdent ifier(jobI dentifier) ;
  65                    qs.s etDocCreat edBy(SYSTE M_USER);
  66                    qs.s etDocCreat edDate(now NoMillis);
  67                    qs.s etDocLastM odifiedBy( SYSTEM_USE R);
  68                    qs.s etDocUpdat edDate(now NoMillis);
  69  
  70                    try  {
  71                             mongoT emplate.in sert(qs);
  72                             /*
  73                              * Thi s section  is ugly bu t a necess ary
  74                              * wor karound fo r Mongo no t operatin g atomical ly. In a m ultithread ed
  75                              * uni t test I f ound that  sporadical ly two dif ferent thr eads would
  76                              * be  able to in sert the s ame doc w/  this ID w ithout it  throwing a
  77                              * Dup licateKeyE xeption. T his query  performs a  last minu te check t o
  78                              * ens ure the it em exists  in the DB  that we ex pect. CPB
  79                              */
  80                             delay( delayConfi rmationMil lis);
  81                             Query  query = ne w Query(wh ere("_id") .is(jobIde ntifier));
  82                             Quartz Semaphore  test = mon goTemplate .findOne(q uery, Quar tzSemaphor e.class);
  83                             if (te st != null  && test.g etPidAtHos tname().eq uals(pid))
  84                                      return n ew QuartzS emaphoreLo ck(jobType , nowNoMil lis);
  85                    } ca tch (Dupli cateKeyExc eption e)  {
  86                    }
  87                    retu rn null;
  88           }
  89  
  90           pr ivate void  delay(lon g millis)  {
  91                    try  {
  92                             Thread .sleep(mil lis);
  93                    } ca tch (Inter ruptedExce ption e) {
  94                             e.prin tStackTrac e();
  95                    }
  96           }
  97  
  98           @O verride
  99           pu blic boole an unlock( QuartzSema phoreLock  lock) {
  100                    retu rn unlockI nternal(lo ck, new De faultPidGe nerator()) ;
  101           }
  102  
  103           bo olean unlo ckInternal (QuartzSem aphoreLock  lock, Pid Generator  generator)  {
  104                    if ( lock == nu ll)
  105                             return  false;
  106  
  107                    Stri ng jobIden tifier = S tring.valu eOf(lock.g etJobType( ).getCode( ));
  108  
  109                    Quer y query =  new Query( new Criter ia().andOp erator( //
  110                                      where("j obIdentifi er").is(jo bIdentifie r), //
  111                                      where("p idAtHostna me").is(ge nerator.ge tPid()), / /
  112                                      where("d ocUpdatedD ate").is(l ock.getMod ifiedDate( ))));
  113  
  114                    Writ eResult re sult = mon goTemplate .remove(qu ery, Quart zSemaphore .class);
  115                    retu rn result. getN() > 0 ;
  116           }
  117  
  118           pr ivate Time stamp getN owNoMillis () {
  119                    long  millis =  System.cur rentTimeMi llis();
  120                    Time stamp modi fiedDate =  new Times tamp(milli s - (milli s % 1000)) ;
  121                    retu rn modifie dDate;
  122           }
  123  
  124   }