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

251.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\eviction TestLimitedSpaceStorageThresholdEviction.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\eviction TestLimitedSpaceStorageThresholdEviction.java Mon Dec 4 22:01:44 2017 UTC

251.2 Comparison summary

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

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

251.4 Active regular expressions

No regular expressions were active.

251.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging.sto rage.cache .impl.evic tion;
  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 rategy;
  11   import gov .va.med.im aging.stor age.cache. impl.evict ion.Storag eThreshold EvictionSt rategyMeme nto;
  12   import gov .va.med.im aging.stor age.cache. impl.files ystem.File SystemCach e;
  13   import gov .va.med.im aging.stor age.cache. impl.memor y.MemoryCa che;
  14   import gov .va.med.se rver.Serve rLifecycle Event;
  15  
  16   import jav a.io.IOExc eption;
  17   import jav a.net.URI;
  18   import jav a.net.URIS yntaxExcep tion;
  19   import jav a.nio.Byte Buffer;
  20  
  21   import jun it.framewo rk.TestCas e;
  22  
  23   import org .apache.lo gging.log4 j.LogManag er;
  24   import org .apache.lo gging.log4 j.Logger;
  25  
  26   /**
  27    * @author         
BECKEC
  28    *
  29    * This te st creates  an in-mem ory cache  with a sin gle region  and an ev iction str ategy
  30    * that de letes grou ps when fr ee space i s too low.
  31    */
  32   public cla ss TestLim itedSpaceS torageThre sholdEvict ion 
  33   extends Te stCase
  34   {
  35           pr ivate stat ic final l ong KILO =  1024;
  36           pr ivate stat ic final l ong MEGA =  KILO * KI LO;
  37           pr ivate stat ic final l ong GIGA =  MEGA * KI LO;
  38           pr ivate stat ic final l ong TERA =  GIGA * KI LO;
  39           
  40           pr ivate stat ic final S tring REGI ON_NAME =  "very-smal l";
  41           pr ivate stat ic final S tring EVIC TION_STRAT EGY_NAME =  "20K-limi t";
  42  
  43           pr ivate stat ic final i nt instanc eDataLengt h = 1024;
  44           
  45           pr ivate Cach e cache =  null;
  46  
  47           pr ivate stat ic byte[]  sampleData  = null;
  48           pr ivate Logg er logger  = LogManag er.getLogg er(this.ge tClass());
  49  
  50           //  create so me list of  bytes we  can use fo r data
  51           //  the data  should be  repeatable  so tests  are consis tent
  52           st atic
  53           {
  54                    samp leData = n ew byte[in stanceData Length];
  55                    for( int index= 0; index<i nstanceDat aLength; + +index)
  56                             sample Data[index ] = (byte) (index % 2 56);
  57           }
  58           
  59           pr otected st atic byte[ ] getSampl eData()
  60           {
  61                    retu rn sampleD ata;
  62           }
  63           
  64           pr otected UR I getCache Uri() 
  65           th rows URISy ntaxExcept ion
  66           {
  67                    retu rn new URI ( FileSyst emCache.pr otocol + " ://" + "vi xtests/" +  this.getN ame() );
  68           }
  69  
  70           /* *
  71            *  @return t he cache
  72            * /
  73           pu blic Cache  getCache( )
  74           {
  75                    retu rn this.ca che;
  76           }
  77  
  78           pr ivate void  setCache( Cache cach e)
  79           {
  80                    this .cache = c ache;
  81           }
  82  
  83           /*  (non-Java doc)
  84            *  @see juni t.framewor k.TestCase #setUp()
  85            * /
  86           pr otected vo id setUp()  
  87           th rows Excep tion
  88           {
  89                    Abst ractCacheT est.initia lizeLoggin g(this.get Name());
  90                    logg er.info("S tarting un it test '"  + this.ge tName() +  "' ======= ========== ========== ========== ========== ========") ;
  91                    
  92                    Cach eManagerIm pl cacheMa nager = Ca cheManager Impl.getSi ngleton();
  93                    Cach e cache =  cacheManag er.createC ache(this. getName(),  getCacheU ri(), (Str ing)null);
  94  
  95                    Evic tionStrate gy evictio nStrategy  = StorageT hresholdEv ictionStra tegy.creat e(
  96                                      EVICTION _STRATEGY_ NAME, true , cache.ge tEvictionT imer(), 
  97                                      KILO, 5  * KILO, 20  * KILO, 
  98                                      1000L, 5 000L);
  99                    cach e.addEvict ionStrateg y(eviction Strategy);
  100                    Regi on region  = cache.cr eateRegion (REGION_NA ME, new St ring[]{EVI CTION_STRA TEGY_NAME} );
  101                    cach e.addRegio n(region);
  102                    
  103                    setC ache( cach e );
  104                    
  105                    getC ache().set Initialize d(true);
  106                    getC ache().set Enabled(tr ue);
  107                    cach eManager.s erverLifec ycleEvent( new Server LifecycleE vent(Serve rLifecycle Event.Even tType.STAR T));
  108           }
  109  
  110           /*  (non-Java doc)
  111            *  @see juni t.framewor k.TestCase #tearDown( )
  112            * /
  113           pr otected vo id tearDow n() throws  Exception
  114           {
  115                    Cach eManagerIm pl cacheMa nager = Ca cheManager Impl.getSi ngleton();
  116                    
  117                    cach eManager.s erverLifec ycleEvent( new Server LifecycleE vent(Serve rLifecycle Event.Even tType.STOP ));
  118                    
  119                    supe r.tearDown ();
  120           }
  121  
  122           /* *
  123            *  Simply te st that th e cache re gions's fr eespace pr operty is  functional .
  124            *  @throws C acheExcept ion 
  125            *  @throws I OException  
  126            * /
  127           pu blic void  testCacheF reespace()  
  128           th rows Cache Exception,  IOExcepti on
  129           {
  130                    int  iterations  = 64;
  131                    Stri ng[] image Ids = new  String[ite rations];
  132                    
  133                    for( int index= 0; index <  iteration s; ++index )
  134                    {
  135                             imageI ds[index]  = (new GUI D()).toSho rtString() ;
  136                             create AndPopulat eInstance(  imageIds[ index] );
  137                             
  138                             System .out.print ln( "Wrote  instance  [" + image Ids[index]  + "]." );
  139                             try{Th read.sleep (1000L);}c atch(Inter ruptedExce ption iX){ }                // g ive the ev iction thr ead a chan ce to keep  up
  140                    }
  141                    
  142           }
  143  
  144           /* *
  145            *  Seems odd  but there  was a pro blem if th e eviction  strategy  had nothin g to do
  146            *  so this t est just m akes it ru n a couple  of times  with nothi ng to do.
  147            *  
  148            *  @throws C acheExcept ion
  149            *  @throws I OException
  150            * /
  151           pu blic void  testCacheF reespaceNo Activity()  
  152           th rows Cache Exception,  IOExcepti on
  153           {
  154                    int  iterations  = 64;
  155                    
  156                    for( int index= 0; index <  iteration s; ++index )
  157                    {
  158                             System .out.print ln( "Did n othing, av ailable re gion free  space is "  + getCach e().getReg ion(REGION _NAME).get FreeSpace( ) + " byte s." );
  159                             try{Th read.sleep (1000L);}c atch(Inter ruptedExce ption iX){ }                // g ive the ev iction thr ead a chan ce to keep  up
  160                    }
  161                    
  162           }
  163           
  164           pr ivate void  createAnd PopulateIn stance(Str ing instan ceId) 
  165           th rows Cache Exception,  IOExcepti on
  166           {
  167                    Stri ng[] path  = new Stri ng[]{insta nceId};
  168                    Inst ance insta nce = getC ache().get OrCreateIn stance(REG ION_NAME,  path, inst anceId);
  169                    
  170                    Inst anceWritab leByteChan nel writeC hannel = i nstance.ge tWritableC hannel();
  171                    
  172                    java .nio.ByteB uffer src  = ByteBuff er.wrap( g etSampleDa ta() );
  173                    
  174                    writ eChannel.w rite(src);
  175  
  176                    writ eChannel.c lose();
  177           }
  178   }