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