252. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:43 PM Central 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.

252.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCacheImpl\main\test\java\gov\va\med\imaging\storage\cache\impl\memory TestStorageThresholdEviction.java Mon Dec 4 21:35:32 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCacheImpl\main\test\java\gov\va\med\imaging\storage\cache\impl\memory TestStorageThresholdEviction.java Mon Dec 4 22:01:45 2017 UTC

252.2 Comparison summary

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

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

252.4 Active regular expressions

No regular expressions were active.

252.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging.sto rage.cache .impl.memo ry;
  5  
  6   import gov .va.med.im aging.GUID ;
  7   import gov .va.med.im aging.stor age.cache. *;
  8   import gov .va.med.im aging.stor age.cache. exceptions .CacheExce ption;
  9   import gov .va.med.im aging.stor age.cache. impl.Cache ManagerImp l;
  10   import gov .va.med.im aging.stor age.cache. impl.evict ion.Storag eThreshold EvictionSt rategyMeme nto;
  11   import gov .va.med.im aging.stor age.cache. impl.memor y.MemoryCa che;
  12   import gov .va.med.se rver.Serve rLifecycle Event;
  13  
  14   import jav a.io.IOExc eption;
  15   import jav a.net.URI;
  16   import jav a.net.URIS yntaxExcep tion;
  17   import jav a.nio.Byte Buffer;
  18  
  19   import jun it.framewo rk.TestCas e;
  20  
  21   import org .apache.lo gging.log4 j.LogManag er;
  22   import org .apache.lo gging.log4 j.Logger;
  23  
  24   /**
  25    * @author         
BECKEC
  26    *
  27    * This te st creates  an in-mem ory cache  with a sin gle region  and an ev iction str ategy
  28    * that de letes grou ps when fr ee space i s too low.
  29    */
  30   public cla ss TestSto rageThresh oldEvictio
  31   extends Te stCase
  32   {
  33           pr ivate stat ic final i nt maxCach eInstanceC ount = 32;
  34           pr ivate stat ic final i nt instanc eDataLengt h = 4096;
  35           pr ivate stat ic final l ong maxCac heSize = i nstanceDat aLength *  maxCacheIn stanceCoun t;
  36           pr ivate stat ic final l ong minIns tanceCount Threshold  = 8;
  37           pr ivate stat ic final l ong target InstanceCo untThresho ld = 16;
  38           
  39           pr ivate Cach e cache =  null;
  40  
  41           pr ivate stat ic byte[]  sampleData  = null;
  42           pr ivate Logg er logger  = LogManag er.getLogg er(this.ge tClass());
  43  
  44           //  create so me list of  bytes we  can use fo r data
  45           //  the data  should be  repeatable  so tests  are consis tent
  46           st atic
  47           {
  48                    samp leData = n ew byte[in stanceData Length];
  49                    for( int index= 0; index<i nstanceDat aLength; + +index)
  50                             sample Data[index ] = (byte) (index % 2 56);
  51           }
  52           
  53           pr otected st atic byte[ ] getSampl eData()
  54           {
  55                    retu rn sampleD ata;
  56           }
  57  
  58  
  59           
  60           pr otected UR I getCache Uri() 
  61           th rows URISy ntaxExcept ion
  62           {
  63                    retu rn new URI (MemoryCac he.protoco l + "://"  + this.get Name() + " ?" + "maxS ize=" + ma xCacheSize  + "&maxIn stanceCoun t=" + maxC acheInstan ceCount);
  64           }
  65  
  66           /* *
  67            *  @return t he cache
  68            * /
  69           pu blic Cache  getCache( )
  70           {
  71                    retu rn this.ca che;
  72           }
  73  
  74           pr ivate void  setCache( Cache cach e)
  75           {
  76                    this .cache = c ache;
  77           }
  78  
  79           /*  (non-Java doc)
  80            *  @see juni t.framewor k.TestCase #setUp()
  81            * /
  82           pr otected vo id setUp()  
  83           th rows Excep tion
  84           {
  85                    Abst ractCacheT est.initia lizeLoggin g(this.get Name());
  86                    logg er.info("S tarting un it test '"  + this.ge tName() +  "' ======= ========== ========== ========== ========== ========") ;
  87                    
  88                    Cach eManagerIm pl cacheMa nager = Ca cheManager Impl.getSi ngleton();
  89                    setC ache( cach eManager.c reateCache (this.getN ame(), get CacheUri() , (String) null) );
  90                    
  91                    Stor ageThresho ldEviction StrategyMe mento evic tionStrate gyMemento  = new Stor ageThresho ldEviction StrategyMe mento();
  92                    
  93                    evic tionStrate gyMemento. setName("s torageThre sholdEvict ionStrateg y");
  94                    evic tionStrate gyMemento. setDelay(0 L);                     // scan  immediatel y
  95                    evic tionStrate gyMemento. setInterva l(1000L);               // scan  every seco nd
  96                    //ev ictionStra tegyMement o.setMaxUs edSpaceThr eshold(max UsedSpaceT hreshold);
  97                    evic tionStrate gyMemento. setMinFree SpaceThres hold(minIn stanceCoun tThreshold  * instanc eDataLengt h);
  98                    evic tionStrate gyMemento. setTargetF reeSpaceTh reshold(ta rgetInstan ceCountThr eshold * i nstanceDat aLength);
  99                    evic tionStrate gyMemento. setInitial ized(true) ;
  100                    cach eManager.c reateEvict ionStrateg y(getCache (), evicti onStrategy Memento);
  101  
  102                    cach eManager.c reateRegio n(getCache (), "regio n", new St ring[]{"st orageThres holdEvicti onStrategy "} );
  103                    
  104                    getC ache().set Initialize d(true);
  105                    getC ache().set Enabled(tr ue);
  106                    cach eManager.s erverLifec ycleEvent( new Server LifecycleE vent(Serve rLifecycle Event.Even tType.STAR T));
  107           }
  108  
  109           /*  (non-Java doc)
  110            *  @see juni t.framewor k.TestCase #tearDown( )
  111            * /
  112           pr otected vo id tearDow n() throws  Exception
  113           {
  114                    Cach eManagerIm pl cacheMa nager = Ca cheManager Impl.getSi ngleton();
  115                    
  116                    cach eManager.s erverLifec ycleEvent( new Server LifecycleE vent(Serve rLifecycle Event.Even tType.STOP ));
  117                    
  118                    supe r.tearDown ();
  119           }
  120  
  121           /* *
  122            *  Simply te st that th e cache re gions's fr eespace pr operty is  functional .
  123            *  @throws C acheExcept ion 
  124            *  @throws I OException  
  125            * /
  126           pu blic void  testCacheF reespace()  
  127           th rows Cache Exception,  IOExcepti on
  128           {
  129                    int  iterations  = 64;
  130                    Stri ng[] image Ids = new  String[ite rations];
  131                    
  132                    for( int index= 0; index <  iteration s; ++index )
  133                    {
  134                             imageI ds[index]  = (new GUI D()).toSho rtString() ;
  135                             create AndPopulat eInstance(  imageIds[ index] );
  136                             
  137                             System .out.print ln( "Avail able regio n free spa ce is " +  getCache() .getRegion ("region") .getFreeSp ace() + "  bytes." );
  138                             try{Th read.sleep (1000L);}c atch(Inter ruptedExce ption iX){ }                // g ive the ev iciton thr ead a chan ce to keep  up
  139                    }
  140                    
  141           }
  142  
  143           pr ivate void  createAnd PopulateIn stance(Str ing instan ceId) 
  144           th rows Cache Exception,  IOExcepti on
  145           {
  146                    Stri ng[] path  = new Stri ng[]{insta nceId};
  147                    Inst ance insta nce = getC ache().get OrCreateIn stance("re gion", pat h, instanc eId);
  148                    
  149                    Inst anceWritab leByteChan nel writeC hannel = i nstance.ge tWritableC hannel();
  150                    
  151                    java .nio.ByteB uffer src  = ByteBuff er.wrap( g etSampleDa ta() );
  152                    
  153                    writ eChannel.w rite(src);
  154  
  155                    writ eChannel.c lose();
  156           }
  157   }