149. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/10/2017 1:01:46 PM Central Daylight 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.

149.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IV-ehmp_cif\TomcatAdapter\main\src\java\gov\va\med\server\tomcat TomcatTransacactionMonitorValve.java Thu Jun 29 17:22:52 2017 UTC
2 C:\AraxisMergeCompare\Pri_re\IV-ehmp_cif\TomcatAdapter\main\src\java\gov\va\med\server\tomcat TomcatTransacactionMonitorValve.java Thu Jul 6 15:05:18 2017 UTC

149.2 Comparison summary

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

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

149.4 Active regular expressions

No regular expressions were active.

149.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.s erver.tomc at;
  5  
  6   import jav a.io.IOExc eption;
  7   import jav a.util.Arr ayList;
  8   import jav a.util.Col lections;
  9   import jav a.util.Lis t;
  10   import jav ax.servlet .ServletEx ception;
  11   import org .apache.ca talina.Val ve;
  12   import org .apache.ca talina.con nector.Req uest;
  13   import org .apache.ca talina.con nector.Res ponse;
  14   import org .apache.ca talina.val ves.ValveB ase;
  15  
  16   /**
  17    * Configu re this so mething li ke:
  18    *  <Valve  className ="gov.va.m ed.server. tomcat.Tom catTransac actionMoni torValve"  transactio nWarningTi me="10000" />
  19    * NOTE: t he parent  container  must have  its backgr oundProces sorDelay a ttribute s et to some thing reas onable
  20    * (e.g. < Engine def aultHost=" 660. URL         " name="Ca talina" ba ckgroundPr ocessorDel ay="5"> )
  21    * If the  background ProcessorD elay is si gnificantl y more tha n the tran sactionWar ningTime t hen the wa rnings wil l
  22    * be very  late.  It  is sugges ted that t he backgro undProcess orDelay be  less than  the trans actionWarn ingTime.
  23    * 
  24    * @author  vhaiswbec kec
  25    *
  26    */
  27   public cla ss TomcatT ransacacti onMonitorV alve
  28   extends Va lveBase
  29   implements  Valve
  30   {
  31           pr ivate fina l List<Act iveTransac tion> acti veTransact ions = 
  32                    Coll ections.sy nchronized List( new  ArrayList< ActiveTran saction>()  );
  33           pr ivate long  transacti onWarningT ime = 1000 0;             // def ault to 10  seconds
  34           
  35           pu blic long  getTransac tionWarnin gTime()
  36           {
  37                    retu rn this.tr ansactionW arningTime ;
  38           }
  39  
  40           pu blic void  setTransac tionWarnin gTime(long  transacti onWarningT ime)
  41           {
  42                    this .transacti onWarningT ime = tran sactionWar ningTime;
  43           }
  44  
  45           /* *
  46            *  Run a per iodic task  in the pa rent Conta iner backg round proc essing thr ead.
  47            *  
  48            *  @see org. apache.cat alina.Valv e#backgrou ndProcess( )
  49            * /
  50           @O verride
  51           pu blic void  background Process()
  52           {
  53                    long  now = Sys tem.curren tTimeMilli s();
  54                    // M ake a copy  so that w e don't ha ve to keep  the mutex  on the
  55                    // a ctive copy  while we  iterate an d do our t hings.
  56                    List <ActiveTra nsaction>  transactio ns = new A rrayList<A ctiveTrans action>(th is.activeT ransaction s);
  57                    
  58                    if(g etTransact ionWarning Time() > 0 )
  59                             for(Ac tiveTransa ction tran saction :  transactio ns)
  60                             {
  61                                      if(now -  transacti on.getStar tTime() >  getTransac tionWarnin gTime())
  62                                               issueWarni ng(transac tion, now) ;
  63                             }
  64           }
  65  
  66           /* *
  67            *  @param tr ansaction
  68            * /
  69           pr ivate void  issueWarn ing(Active Transactio n transact ion, long  now)
  70           {
  71                    Stri ngBuilder  sb = new S tringBuild er();
  72                    
  73                    sb.a ppend("A t ransaction  has excee ded the co nfigured m aximum dur ation.\n") ;
  74                    sb.a ppend("Tra nsaction h as run for  " );
  75                    sb.a ppend(now  - transact ion.getSta rtTime());
  76                    sb.a ppend(" mi lliseconds .\n");
  77                    
  78                    Thre ad thread  = transact ion.getWor ker();
  79                    sb.a ppend("Thr ead ["); 
  80                    sb.a ppend( thr ead.getNam e() );
  81                    sb.a ppend( ']'  );
  82                    sb.a ppend( thr ead.getSta te().toStr ing() );
  83                    sb.a ppend( '\n ' );
  84                    for(  StackTrac eElement s te : threa d.getStack Trace() )
  85                    {
  86                             sb.app end(ste.ge tClassName ());
  87                             sb.app end('.');
  88                             sb.app end(ste.ge tMethodNam e());
  89                             sb.app end(' ');
  90                             sb.app end(ste.ge tFileName( ));
  91                             sb.app end( '[');
  92                             sb.app end(ste.ge tLineNumbe r());
  93                             sb.app end(']');
  94                    }
  95                    
  96                    Syst em.err.pri ntln(sb.to String());
  97           }
  98  
  99           /* *
  100            *  @see org. apache.cat alina.Valv e#getInfo( )
  101            * /
  102           // @Override
  103           pu blic Strin g getInfo( )
  104           {
  105                    retu rn "Transa ction moni toring val ve, watche s for long  running t ransaction s.";
  106           }
  107  
  108           /* *
  109            *  @see org. apache.cat alina.Valv e#invoke(o rg.apache. catalina.c onnector.R equest, or g.apache.c atalina.co nnector.Re sponse)
  110            * /
  111           @O verride
  112           pu blic void  invoke(Req uest reque st, Respon se respons e) 
  113           th rows IOExc eption, Se rvletExcep tion
  114           {
  115                    long  startTime  = System. currentTim eMillis();
  116                    Thre ad thread  = Thread.c urrentThre ad();
  117                    Acti veTransact ion active Transactio n = new Ac tiveTransa ction(star tTime, thr ead);
  118                    acti veTransact ions.add(  activeTran saction );
  119                    
  120                    getN ext().invo ke(request , response );
  121                    
  122                    acti veTransact ions.remov e( activeT ransaction  );
  123           }
  124           
  125           cl ass Active Transactio n
  126           {
  127                    priv ate final  long start Time;
  128                    priv ate final  Thread wor ker;
  129                    
  130                    /**
  131                     * @ param star tTime
  132                     * @ param work er
  133                     */
  134                    publ ic ActiveT ransaction (long star tTime, Thr ead worker )
  135                    {
  136                             super( );
  137                             this.s tartTime =  startTime ;
  138                             this.w orker = wo rker;
  139                    }
  140  
  141                    publ ic long ge tStartTime ()
  142                    {
  143                             return  this.star tTime;
  144                    }
  145  
  146                    publ ic Thread  getWorker( )
  147                    {
  148                             return  this.work er;
  149                    }
  150           }
  151   }