Produced by Araxis Merge on 12/13/2018 10:35:32 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\util | StopWatchLogger.java | Fri Dec 7 17:36:24 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\util | StopWatchLogger.java | Wed Dec 12 22:26:42 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 392 |
| 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 | * Copyrii ght 2006 V HA. All ri ghts reser ved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | ||
| 5 | package go v.va.med.f w.util; | |
| 6 | ||
| 7 | import jav a.net.Inet Address; | |
| 8 | import jav a.net.Unkn ownHostExc eption; | |
| 9 | ||
| 10 | import org .apache.co mmons.lang .StringEsc apeUtils; | |
| 11 | import org .apache.co mmons.logg ing.Log; | |
| 12 | import org .apache.co mmons.logg ing.LogFac tory; | |
| 13 | import org .springfra mework.uti l.StopWatc h; | |
| 14 | ||
| 15 | import gov .va.med.cc ht.util.ES APIValidat ionType; | |
| 16 | import gov .va.med.cc ht.util.ES APIValidat or; | |
| 17 | ||
| 18 | ||
| 19 | /** | |
| 20 | * Allows for config uring a se parate log ger for th e StopWatc h than for its | |
| 21 | * client/ measured c lass. | |
| 22 | * | |
| 23 | * <p> | |
| 24 | * Preferr ed usage i s AOP appr oach via P erformance MonitorInt erceptor | |
| 25 | * </p> | |
| 26 | * | |
| 27 | * Created Oct 13, 2 006 12:11: 16 PM | |
| 28 | * | |
| 29 | * DNS | |
| 30 | */ | |
| 31 | public cla ss StopWat chLogger e xtends Sto pWatch { | |
| 32 | pr otected fi nal Log lo gger = Log Factory.ge tLog(getCl ass()); | |
| 33 | pu blic stati c final St ring ENV_C ONTEXT_SYS _PROPERTY = "server. Name"; | |
| 34 | ||
| 35 | pu blic stati c final in t SLOW_THR ESHOLD_MIL LIS = 3000 ; | |
| 36 | pu blic stati c final in t FAIL_THR ESHOLD_MIL LIS = 1000 0; | |
| 37 | pu blic int s lowThresho ldMillis = SLOW_THRE SHOLD_MILL IS; | |
| 38 | pu blic int f ailThresho ldMillis = FAIL_THRE SHOLD_MILL IS; | |
| 39 | ||
| 40 | pu blic stati c final St ring SLOW_ THRESHOLD_ EXCEEDED_L OG_FLAG = "[SLOW] "; | |
| 41 | pu blic stati c final St ring FAIL_ THRESHOLD_ EXCEEDED_L OG_FLAG = "[FAIL] "; | |
| 42 | pu blic Strin g slowThre sholdExcee dedLogFlag = SLOW_TH RESHOLD_EX CEEDED_LOG _FLAG; | |
| 43 | pu blic Strin g failThre sholdExcee dedLogFlag = FAIL_TH RESHOLD_EX CEEDED_LOG _FLAG; | |
| 44 | ||
| 45 | pu blic boole an logBelo wDurationT hreshold = true; | |
| 46 | ||
| 47 | pr ivate Stri ng id; | |
| 48 | ||
| 49 | pu blic StopW atchLogger () { | |
| 50 | this (StringUti ls.EMPTY); | |
| 51 | } | |
| 52 | ||
| 53 | pu blic StopW atchLogger (String id ) { | |
| 54 | supe r(id); | |
| 55 | this .id = id; | |
| 56 | this .setKeepTa skList(fal se); | |
| 57 | } | |
| 58 | ||
| 59 | pu blic void start() { | |
| 60 | star t(this.id) ; | |
| 61 | } | |
| 62 | ||
| 63 | pu blic void stopAndLog () { | |
| 64 | stop (); | |
| 65 | log( ); | |
| 66 | } | |
| 67 | ||
| 68 | pu blic void stopAndLog (String re turnDataSu mmary) { | |
| 69 | stop (); | |
| 70 | log( returnData Summary); | |
| 71 | } | |
| 72 | ||
| 73 | pu blic void stopAndLog (String re turnDataSu mmary, Log targetLog ger) { | |
| 74 | stop (); | |
| 75 | log( returnData Summary, t argetLogge r); | |
| 76 | } | |
| 77 | ||
| 78 | pu blic void log() { | |
| 79 | log( null); | |
| 80 | } | |
| 81 | ||
| 82 | pu blic void log(String returnDat aSummary) { | |
| 83 | log( returnData Summary, t his.logger ); | |
| 84 | } | |
| 85 | ||
| 86 | pu blic void log(String returnDat aSummary, Log target Logger) { | |
| 87 | if ( targetLogg er.isTrace Enabled()) { | |
| 88 | String shortSumm ary = this .shortSumm ary(); | |
| 89 | if (sh ortSummary == null) | |
| 90 | { | |
| 91 | return; | |
| 92 | } | |
| 93 | ||
| 94 | String Builder lo gStringBui lder = new StringBui lder(); | |
| 95 | logStr ingBuilder .append(ge tEnvContex t()); | |
| 96 | logStr ingBuilder .append(sh ortSummary ); | |
| 97 | logStr ingBuilder .append(" - "); | |
| 98 | if (St ringUtils. isNotBlank (returnDat aSummary)) | |
| 99 | { | |
| 100 | logStrin gBuilder.a ppend(retu rnDataSumm ary); | |
| 101 | } | |
| 102 | ||
| 103 | String logString = StringE scapeUtils .escapeHtm l(logStrin gBuilder.t oString()) ; | |
| 104 | ||
| 105 | //Fix Fortify I ssues | |
| 106 | ESAPIV alidator.v alidateStr ingInput(l ogString, ESAPIValid ationType. LogString_ WhiteList) ; | |
| 107 | target Logger.tra ce(logStri ng); | |
| 108 | ||
| 109 | } | |
| 110 | } | |
| 111 | ||
| 112 | /* | |
| 113 | * (non-Java doc) | |
| 114 | * | |
| 115 | * @see org. springfram ework.util .StopWatch #shortSumm ary() | |
| 116 | * / | |
| 117 | @O verride | |
| 118 | pu blic Strin g shortSum mary() { | |
| 119 | long duration = getTotal TimeMillis (); | |
| 120 | if ( duration > = failThre sholdMilli s) { | |
| 121 | return failThres holdExceed edLogFlag + super.sh ortSummary (); | |
| 122 | } el se if (dur ation >= s lowThresho ldMillis) { | |
| 123 | return slowThres holdExceed edLogFlag + super.sh ortSummary (); | |
| 124 | } el se { | |
| 125 | if (lo gBelowDura tionThresh old) { | |
| 126 | return " [OK] " + s uper.short Summary(); | |
| 127 | } | |
| 128 | } | |
| 129 | ||
| 130 | retu rn null; | |
| 131 | } | |
| 132 | ||
| 133 | pr otected St ring getEn vContext() { | |
| 134 | Stri ng envCont ext = Syst em.getProp erty(ENV_C ONTEXT_SYS _PROPERTY) ; | |
| 135 | if ( envContext == null) { | |
| 136 | try { | |
| 137 | envConte xt = InetA ddress.get LocalHost( ).getHostN ame(); | |
| 138 | } catc h (Unknown HostExcept ion e) { | |
| 139 | // oh we ll, we tri ed | |
| 140 | envConte xt = "Unkn own"; | |
| 141 | } | |
| 142 | } | |
| 143 | retu rn "[" + e nvContext + "] "; | |
| 144 | } | |
| 145 | ||
| 146 | pu blic void reset() { | |
| 147 | if ( this.isRun ning()) | |
| 148 | stop() ; | |
| 149 | } | |
| 150 | ||
| 151 | /* * | |
| 152 | * @return t he logBelo wDurationT hreshold | |
| 153 | * / | |
| 154 | pu blic boole an isLogBe lowDuratio nThreshold () { | |
| 155 | retu rn logBelo wDurationT hreshold; | |
| 156 | } | |
| 157 | ||
| 158 | /* * | |
| 159 | * @param lo gBelowDura tionThresh old | |
| 160 | * the logB elowDurati onThreshol d to set | |
| 161 | * / | |
| 162 | pu blic void setLogBelo wDurationT hreshold(b oolean log BelowDurat ionThresho ld) { | |
| 163 | this .logBelowD urationThr eshold = l ogBelowDur ationThres hold; | |
| 164 | } | |
| 165 | ||
| 166 | pu blic int g etSlowThre sholdMilli s() { | |
| 167 | retu rn slowThr esholdMill is; | |
| 168 | } | |
| 169 | ||
| 170 | pu blic void setSlowThr esholdMill is(int slo wThreshold Millis) { | |
| 171 | this .slowThres holdMillis = slowThr esholdMill is; | |
| 172 | } | |
| 173 | ||
| 174 | pu blic int g etFailThre sholdMilli s() { | |
| 175 | retu rn failThr esholdMill is; | |
| 176 | } | |
| 177 | ||
| 178 | pu blic void setFailThr esholdMill is(int fai lThreshold Millis) { | |
| 179 | this .failThres holdMillis = failThr esholdMill is; | |
| 180 | } | |
| 181 | ||
| 182 | pu blic Strin g getSlowT hresholdEx ceededLogF lag() { | |
| 183 | retu rn slowThr esholdExce ededLogFla g; | |
| 184 | } | |
| 185 | ||
| 186 | pu blic void setSlowThr esholdExce ededLogFla g(String s lowThresho ldExceeded LogFlag) { | |
| 187 | this .slowThres holdExceed edLogFlag = slowThre sholdExcee dedLogFlag .trim() + " "; | |
| 188 | } | |
| 189 | ||
| 190 | pu blic Strin g getFailT hresholdEx ceededLogF lag() { | |
| 191 | retu rn failThr esholdExce ededLogFla g; | |
| 192 | } | |
| 193 | ||
| 194 | pu blic void setFailThr esholdExce ededLogFla g(String f ailThresho ldExceeded LogFlag) { | |
| 195 | this .failThres holdExceed edLogFlag = failThre sholdExcee dedLogFlag .trim() + " "; | |
| 196 | } | |
| 197 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.