750. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/18/2018 2:02:16 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.

750.1 Files compared

# Location File Last Modified
1 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\CacheImplJCIFS\main\src\java\gov\va\med\imaging\storage\cache\impl\jcifs JcifsByteChannelFactory.java Thu Oct 11 13:30:16 2018 UTC
2 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\CacheImplJCIFS\main\src\java\gov\va\med\imaging\storage\cache\impl\jcifs JcifsByteChannelFactory.java Wed Oct 17 18:44:47 2018 UTC

750.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 1392
Changed 2 4
Inserted 0 0
Removed 0 0

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

750.4 Active regular expressions

No regular expressions were active.

750.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging.sto rage.cache .impl.jcif s;
  5  
  6  
  7   import jav a.io.IOExc eption;
  8   import jav a.text.Dat eFormat;
  9   import jav a.text.Sim pleDateFor mat;
  10   import jav a.util.Arr ayList;
  11   import jav a.util.Col lections;
  12   import jav a.util.Con currentMod ificationE xception;
  13   import jav a.util.Has hMap;
  14   import jav a.util.Lis t;
  15   import jav a.util.Map ;
  16  
  17   import jav ax.managem ent.Attrib ute;
  18   import jav ax.managem ent.Attrib uteList;
  19   import jav ax.managem ent.Attrib uteNotFoun dException ;
  20   import jav ax.managem ent.Dynami cMBean;
  21   import jav ax.managem ent.Invali dAttribute ValueExcep tion;
  22   import jav ax.managem ent.MBeanE xception;
  23   import jav ax.managem ent.MBeanI nfo;
  24   import jav ax.managem ent.MBeanN otificatio nInfo;
  25   import jav ax.managem ent.Reflec tionExcept ion;
  26   import jav ax.managem ent.openmb ean.OpenMB eanAttribu teInfo;
  27   import jav ax.managem ent.openmb ean.OpenMB eanAttribu teInfoSupp ort;
  28   import jav ax.managem ent.openmb ean.OpenMB eanConstru ctorInfo;
  29   import jav ax.managem ent.openmb ean.OpenMB eanInfoSup port;
  30   import jav ax.managem ent.openmb ean.OpenMB eanOperati onInfo;
  31   import jav ax.managem ent.openmb ean.Simple Type;
  32  
  33   import org .apache.lo gging.log4 j.LogManag er;
  34   import org .apache.lo gging.log4 j.Logger;
  35  
  36   import gov .va.med.im aging.Stac kTraceAnal yzer;
  37   import gov .va.med.im aging.stor age.cache. CacheLifec ycleEvent;
  38   import gov .va.med.im aging.stor age.cache. CacheLifec ycleListen er;
  39   import gov .va.med.im aging.stor age.cache. InstanceBy teChannelF actory;
  40   import gov .va.med.im aging.stor age.cache. InstanceBy teChannelL istener;
  41   import gov .va.med.im aging.stor age.cache. InstanceRe adableByte Channel;
  42   import gov .va.med.im aging.stor age.cache. InstanceWr itableByte Channel;
  43   import gov .va.med.im aging.stor age.cache. exceptions .CacheExce ption;
  44   import gov .va.med.im aging.stor age.cache. exceptions .CacheStat eException ;
  45   import gov .va.med.im aging.stor age.cache. exceptions .Persisten ceIOExcept ion;
  46   import gov .va.med.im aging.stor age.cache. memento.By teChannelF actoryMeme nto;
  47   import jci fs.smb.Smb File;
  48  
  49   /**
  50    * @author   PI I
  51    *
  52    * A facto ry class t hat provid es some ma nagement o f instance  file chan nels.
  53    * 
  54    */
  55   public cla ss JcifsBy teChannelF actory 
  56   implements  InstanceB yteChannel Factory<Sm bFile>, Dy namicMBean , CacheLif ecycleList ener
  57   {
  58           pu blic stati c final lo ng default MaxChannel OpenDurati on = 30000 0L;        // long de fault fore  remote ju keboxes
  59           pu blic stati c final lo ng default SweepTime  = 10000L;
  60           pu blic stati c final bo olean defa ultTraceCh annelInsta ntiation =  true;
  61           
  62           pr ivate Date Format df  = new Simp leDateForm at("ddMMMy yyy hh:mm: ss");
  63           
  64           pr ivate long  maxChanne lOpenDurat ion = defa ultMaxChan nelOpenDur ation;
  65           pr ivate long  sweepTime  = default SweepTime;
  66           pr ivate bool ean traceC hannelInst antiation  = defaultT raceChanne lInstantia tion;
  67           
  68           Lo gger log =  LogManage r.getLogge r(this.get Class());
  69           pr ivate Chan nelCleanup Thread cle anupThread ;
  70           
  71           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ======
  72           //  Factory M ethods
  73           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ======
  74           pu blic stati c JcifsByt eChannelFa ctory crea te()
  75           {
  76                    retu rn new Jci fsByteChan nelFactory (defaultMa xChannelOp enDuration , defaultS weepTime);
  77           }
  78           
  79           pu blic stati c JcifsByt eChannelFa ctory crea te(ByteCha nnelFactor yMemento m emento)
  80           {
  81                    retu rn new Jci fsByteChan nelFactory (memento);
  82           }
  83           
  84           /* *
  85            *  
  86            *  @param me mento
  87            * /
  88           pr ivate Jcif sByteChann elFactory( ByteChanne lFactoryMe mento meme nto)
  89           {
  90                    this (
  91                             mement o == null  ? defaultM axChannelO penDuratio n : mement o.getMaxCh annelOpenD uration(),  
  92                             mement o == null  ? defaultS weepTime :  memento.g etSweepTim e() 
  93                    );
  94           }
  95           
  96           /* *
  97            *  
  98            *  @param ma xChannelOp enDuration  - the max imum time  a channel  is allowed  to be ope n
  99            *  @param sw eepTime -  the delay  in the bac kground th read that  looks for  open chann els
  100            * /
  101           pr ivate Jcif sByteChann elFactory( Long maxCh annelOpenD uration, L ong sweepT ime)
  102           {
  103                    this .maxChanne lOpenDurat ion = maxC hannelOpen Duration.l ongValue() ;
  104                    this .sweepTime  = sweepTi me;
  105           }
  106  
  107           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =========
  108           //  InstanceB yteChannel Factory Im plementati on
  109           //  Behaviora l Modifica tion Metho ds
  110           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =========
  111           
  112           /*  (non-Java doc)
  113            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Insta nceByteCha nnelFactor yImplMBean #getMaxCha nnelOpenDu ration()
  114            * /
  115           pu blic long  getMaxChan nelOpenDur ation()
  116           {
  117                    retu rn maxChan nelOpenDur ation;
  118           }
  119           pu blic void  setMaxChan nelOpenDur ation(long  maxChanne lOpenDurat ion)
  120           {
  121                    if(m axChannelO penDuratio n > 0L)
  122                             this.m axChannelO penDuratio n = maxCha nnelOpenDu ration;
  123           }
  124  
  125           /*  (non-Java doc)
  126            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Insta nceByteCha nnelFactor yImplMBean #getSweepT ime()
  127            * /
  128           pu blic long  getSweepTi me()
  129           {
  130                    retu rn sweepTi me;
  131           }
  132           pu blic void  setSweepTi me(long sw eepTime)
  133           {
  134                    if(s weepTime >  0L)
  135                             this.s weepTime =  sweepTime ;
  136           }
  137           
  138           /*  (non-Java doc)
  139            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Insta nceByteCha nnelFactor yImplMBean #getCurren tlyOpenRea dableByteC hannels()
  140            * /
  141           pu blic int g etCurrentl yOpenReada bleByteCha nnels()
  142           {
  143                    retu rn openRea dChannels. size();
  144           }
  145  
  146           /*  (non-Java doc)
  147            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Insta nceByteCha nnelFactor yImplMBean #getCurren tlyOpenWri tableByteC hannels()
  148            * /
  149           pu blic int g etCurrentl yOpenWrita bleByteCha nnels()
  150           {
  151                    retu rn openWri teChannels .size();
  152           }
  153  
  154           /* *
  155            *  If traceC hannelInst antiation  is set the n the fact ory will r ecord
  156            *  the stack  trace whe n a channe l is insta ntiated an d report t he stack
  157            *  trace whe n the chan nel is clo sed due to  a timeout
  158            *  
  159            *  @return
  160            * /
  161           pu blic boole an isTrace ChannelIns tantiation ()
  162           {
  163                    retu rn this.tr aceChannel Instantiat ion;
  164           }
  165  
  166           pu blic void  setTraceCh annelInsta ntiation(b oolean tra ceChannelI nstantiati on)
  167           {
  168                    this .traceChan nelInstant iation = t raceChanne lInstantia tion;
  169           }
  170  
  171           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =========
  172           //  InstanceB yteChannel Factory Im plementati on
  173           //  Business  Methods
  174           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =========
  175           /*  (non-Java doc)
  176            *  @see gov. va.med.ima ging.stora ge.cache.f ilesystem. InstanceBy teChannelF actory#get InstanceRe adableByte Channel(ja va.io.File )
  177            * /
  178           pu blic Insta nceReadabl eByteChann el getInst anceReadab leByteChan nel(SmbFil e instance File, Inst anceByteCh annelListe ner timeou tListener)
  179           th rows Persi stenceIOEx ception, C acheExcept ion
  180           {
  181                    try
  182                    {
  183                             Instan ceReadable ByteChanne lImpl read able = new  InstanceR eadableByt eChannelIm pl(this, i nstanceFil e);
  184                             if(tim eoutListen er != null )
  185                                      this.put ReadableCh annel(read able, time outListene r);
  186                                      
  187                             return  readable;
  188                    } 
  189                    catc h (IOExcep tion ioX)
  190                    {
  191                             throw  new Persis tenceIOExc eption(ioX );
  192                    }
  193           }
  194           
  195           /*  (non-Java doc)
  196            *  @see gov. va.med.ima ging.stora ge.cache.f ilesystem. InstanceBy teChannelF actory#get InstanceWr itableByte Channel(ja va.io.File )
  197            * /
  198           pu blic Insta nceWritabl eByteChann el getInst anceWritab leByteChan nel(SmbFil e instance File, Inst anceByteCh annelListe ner timeou tListener)  
  199           th rows Persi stenceIOEx ception, C acheExcept ion
  200           {
  201                    try
  202                    {
  203                             Instan ceWritable ByteChanne lImpl writ able = new  InstanceW ritableByt eChannelIm pl(this, i nstanceFil e );
  204  
  205                             if(tim eoutListen er != null )
  206                                      putWrita bleChannel (writable,  timeoutLi stener);
  207                             
  208                             return  writable;
  209                    } 
  210                    catc h (IOExcep tion ioX)
  211                    {
  212                             throw  new Persis tenceIOExc eption(ioX );
  213                    }
  214           }
  215           
  216           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ======
  217           //  Open Read /Write Cha nnels list  managemen t.
  218           //  All acces s to these  maps shou ld go thro ugh the ca lls provid ed below s o that cor rect
  219           //  synchroni zation may  be provid ed.
  220           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ======
  221           pr ivate Map< InstanceWr itableByte ChannelImp l, Instanc eByteChann elListener > openWrit eChannels 
  222                    Coll ections.sy nchronized Map( new H ashMap<Ins tanceWrita bleByteCha nnelImpl,  InstanceBy teChannelL istener>()  );
  223           pr ivate Map< InstanceRe adableByte ChannelImp l, Instanc eByteChann elListener > openRead Channels =  
  224                    Coll ections.sy nchronized Map( new H ashMap<Ins tanceReada bleByteCha nnelImpl,  InstanceBy teChannelL istener>()  );
  225           
  226           pr ivate void  putWritab leChannel( InstanceWr itableByte ChannelImp l writable , Instance ByteChanne lListener  listener)
  227           {
  228                    open WriteChann els.put(wr itable, li stener);
  229           }
  230  
  231           pr ivate void  putReadab leChannel( InstanceRe adableByte ChannelImp l readable , Instance ByteChanne lListener  listener)
  232           {
  233                    open ReadChanne ls.put(rea dable, lis tener);
  234           }
  235           
  236           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =========
  237           //  InstanceB yteChannel Factory Im plementati on
  238           //  Statistic s Gatherin g Methods
  239           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =========
  240           /* *
  241            *  Look thro ugh our in ternal lis t of open  writable c hannels an d return a
  242            *  reference  to the by te channel  that is o pen on the  given fil e,
  243            *  or return  null if n ot open.
  244            *  
  245            *  @param in stanceFile
  246            *  @return
  247            * /
  248           In stanceWrit ableByteCh annelImpl  getOpenWri tableByteC hannel(Smb File insta nceFile)
  249           {
  250                    if(i nstanceFil e == null)
  251                             return  null;
  252                    
  253                    sync hronized(o penWriteCh annels)
  254                    {
  255                             for(In stanceWrit ableByteCh annelImpl  channel: o penWriteCh annels.key Set() )
  256                             {
  257                                      SmbFile  channelFil e = channe l.getFile( );
  258                                      
  259                                      if(insta nceFile.eq uals(chann elFile))
  260                                               return cha nnel;
  261                             }
  262                    }
  263                    
  264                    retu rn null;
  265           }
  266           
  267           /* *
  268            *  Look thro ugh our in ternal lis t of open  readable c hannels an d return a
  269            *  reference  to the by te channel  that is o pen on the  given fil e,
  270            *  or return  null if n ot open.
  271            *  
  272            *  @param in stanceFile
  273            *  @return
  274            * /
  275           In stanceRead ableByteCh annelImpl  getOpenRea dableByteC hannel(Smb File insta nceFile)
  276           {
  277                    if(i nstanceFil e == null)
  278                             return  null;
  279                    
  280                    sync hronized(o penReadCha nnels)
  281                    {
  282                             for(In stanceRead ableByteCh annelImpl  channel: o penReadCha nnels.keyS et() )
  283                             {
  284                                      SmbFile  channelFil e = channe l.getFile( );
  285                                      
  286                                      if(insta nceFile.eq uals(chann elFile))
  287                                               return cha nnel;
  288                             }
  289                    }
  290                    
  291                    retu rn null;
  292           }
  293           
  294           /* *
  295            *  This is N OT an idem potent met hod, it RE MOVES the  writable m ap entry.
  296            *  
  297            *  @param wr itable
  298            * /
  299           pr ivate void  notifyTim eoutWritab leChannelL isteners(I nstanceWri tableByteC hannelImpl  writable)
  300           {
  301                    writ ableByteCh annelClose d(writable , true);
  302           }
  303           
  304           /* *
  305            *  This is N OT an idem potent met hod, it RE MOVES the  readable m ap entry.
  306            *  
  307            *  @param re adable
  308            * /
  309           pr ivate void  notifyTim eoutReadab leChannelL isteners(I nstanceRea dableByteC hannelImpl  readable)
  310           {
  311                    read ableByteCh annelClose d(readable , true);
  312           }
  313           
  314           
  315           /* *
  316            *  Any shoul d call thi s to remov e the writ able byte  channel,
  317            *  else the  listeners  will get t imeout sig nals. 
  318            *  
  319            *  @param wr itable
  320            * /
  321           vo id writabl eByteChann elClosed(I nstanceWri tableByteC hannelImpl  writable,  boolean e rrorClose)
  322           {
  323                    Inst anceByteCh annelListe ner listen er = openW riteChanne ls.get(wri table);
  324                    open WriteChann els.remove (writable) ;
  325                    
  326                    if(l istener !=  null)
  327                    {
  328                             if(err orClose)
  329                                      listener .writeChan nelIdleTim eout(writa ble);
  330                             else
  331                                      listener .writeChan nelClose(w ritable);
  332                    }
  333           }
  334           /* *
  335            *  A 'normal ' close sh ould call  this to re move the r eadable by te channel ,
  336            *  else the  listeners  will get t imeout sig nals. 
  337            *  
  338            *  @param re adable
  339            * /
  340           vo id readabl eByteChann elClosed(I nstanceRea dableByteC hannelImpl  readable,  boolean e rrorClose)
  341           {
  342                    Inst anceByteCh annelListe ner listen er = openR eadChannel s.get(read able);
  343                    open ReadChanne ls.remove( readable);
  344                    
  345                    if(l istener !=  null)
  346                    {
  347                             if(err orClose)
  348                                      listener .readChann elIdleTime out(readab le);
  349                             else
  350                                      listener .readChann elClose(re adable);
  351                    }
  352           }
  353           
  354           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =
  355           //  State per sistence i mplementat ion
  356           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =
  357           /* *
  358            *  Create a  Serializab le represe ntation of  our state  that may  be
  359            *  used late r to recre ate our st ate.
  360            *  
  361            *  @return
  362            * /
  363           pu blic ByteC hannelFact oryMemento  createMem ento()
  364           {
  365                    Byte ChannelFac toryMement o memento  = new Byte ChannelFac toryMement o();
  366                    
  367                    meme nto.setMax ChannelOpe nDuration( getMaxChan nelOpenDur ation());
  368                    meme nto.setSwe epTime(get SweepTime( ));
  369                    
  370                    retu rn memento ;
  371           }
  372  
  373           pu blic void  restoreMem ento(ByteC hannelFact oryMemento  memento)
  374           {
  375                    setM axChannelO penDuratio n( memento .getMaxCha nnelOpenDu ration() ) ;
  376                    setS weepTime(  memento.ge tSweepTime () );
  377           }
  378  
  379           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ======
  380           //  CacheLife cycleListe ner 
  381           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ======
  382           pu blic void  cacheLifec ycleEvent( CacheLifec ycleEvent  event) thr ows CacheS tateExcept ion
  383           {
  384                    if(e vent == Ca cheLifecyc leEvent.ST ART)
  385                    {
  386                             if(thi s.sweepTim e > 0L &&  this.maxCh annelOpenD uration >  0L)
  387                             {
  388                                      cleanupT hread = ne w ChannelC leanupThre ad(this.sw eepTime, t his.maxCha nnelOpenDu ration);
  389                                      cleanupT hread.star t();
  390                             }
  391                    }
  392                    else  if (event  == CacheL ifecycleEv ent.STOP)
  393                    {
  394                             if(cle anupThread  != null)
  395                                      cleanupT hread.kill ();
  396                    }
  397           }
  398  
  399           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ======
  400           //  JMX (mana gement) re lated meth ods (Dynam icMBean im plementati on)
  401           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ======
  402           
  403           /* *
  404            *  @see java x.manageme nt.Dynamic MBean#getM BeanInfo()
  405            * /
  406           pr ivate MBea nInfo open MBeanInfo;
  407           pu blic synch ronized MB eanInfo ge tMBeanInfo ()
  408           {
  409                    if(o penMBeanIn fo == null )
  410                    {
  411                             openMB eanInfo =  new OpenMB eanInfoSup port(
  412                                               getClass() .getName() ,
  413                         "Byte chan nel factor y for file  system ba sed cache  implementa tions.",
  414                         new OpenMB eanAttribu teInfo[] 
  415                         {
  416                                                       ne w OpenMBea nAttribute InfoSuppor t("maxChan nelOpenDur ation", "M aximum tim e in milli seconds be tween chan nel usage" , SimpleTy pe.LONG, t rue, true,  false),
  417                                                       ne w OpenMBea nAttribute InfoSuppor t("sweepTi me", "Time  to delay  between sw eeping ope n channels ", SimpleT ype.LONG,  true, true , false),
  418                                                       ne w OpenMBea nAttribute InfoSuppor t("traceCh annelInsta ntiation",  "Trace th e code tha t opened c hannels",  SimpleType .BOOLEAN,  true, true , true),
  419                                                       ne w OpenMBea nAttribute InfoSuppor t("openRea dableByteC hannels",  "Number of  read chan nels curre ntly open" , SimpleTy pe.INTEGER , true, fa lse, false ),
  420                                                       ne w OpenMBea nAttribute InfoSuppor t("openWri tableByteC hannels",  "Number of  write cha nnels curr ently open ", SimpleT ype.INTEGE R, true, f alse, fals e)
  421                         },
  422                         new OpenMB eanConstru ctorInfo[] {},
  423                         new OpenMB eanOperati onInfo[]{} ,
  424                         new MBeanN otificatio nInfo[]{}
  425                             );
  426                    }
  427                    
  428                    retu rn openMBe anInfo;
  429           }
  430  
  431           /* *
  432            *  @see java x.manageme nt.Dynamic MBean#getA ttribute(j ava.lang.S tring)
  433            * /
  434           pu blic Objec t getAttri bute(Strin g attribut e) 
  435           th rows Attri buteNotFou ndExceptio n, MBeanEx ception, R eflectionE xception
  436           {
  437                    if(  "maxChanne lOpenDurat ion".equal s(attribut e) )
  438                             return  new Long( getMaxChan nelOpenDur ation());
  439                    else  if( "swee pTime".equ als(attrib ute) )
  440                             return  new Long( getSweepTi me());
  441                    else  if( "trac eChannelIn stantiatio n".equals( attribute)  )
  442                             return  new Boole an(isTrace ChannelIns tantiation ());
  443                    else  if( "open ReadableBy teChannels ".equals(a ttribute)  )
  444                             return  new Integ er(getCurr entlyOpenR eadableByt eChannels( ));
  445                    else  if( "open WritableBy teChannels ".equals(a ttribute)  )
  446                             return  new Integ er(getCurr entlyOpenW ritableByt eChannels( ));
  447                    else
  448                             throw  new Attrib uteNotFoun dException ("Attribut e '" + att ribute + " ' not foun d");
  449           }
  450  
  451           /* *
  452            *  @see java x.manageme nt.Dynamic MBean#getA ttributes( java.lang. String[])
  453            * /
  454           pu blic Attri buteList g etAttribut es(String[ ] attribut es)
  455           {
  456                    Attr ibuteList  list = new  Attribute List();
  457                    for( String att ribute:att ributes)
  458                             try
  459                             {
  460                                      list.add ( new Attr ibute(attr ibute, get Attribute( attribute) ) );
  461                             } 
  462                             catch  (Attribute NotFoundEx ception x)
  463                             {
  464                                      x.printS tackTrace( );
  465                             } 
  466                             catch  (MBeanExce ption x)
  467                             {
  468                                      x.printS tackTrace( );
  469                             } 
  470                             catch  (Reflectio nException  x)
  471                             {
  472                                      x.printS tackTrace( );
  473                             }
  474                    retu rn list;
  475           }
  476  
  477           /* *
  478            *  @see java x.manageme nt.Dynamic MBean#setA ttribute(j avax.manag ement.Attr ibute)
  479            * /
  480           pu blic void  setAttribu te(Attribu te attribu te) 
  481           th rows Attri buteNotFou ndExceptio n, Invalid AttributeV alueExcept ion, MBean Exception,  Reflectio nException
  482           {
  483                    try
  484                    {
  485                             if( "m axChannelO penDuratio n".equals( attribute. getName())  )
  486                                      setMaxCh annelOpenD uration( ( Long)attri bute.getVa lue() );
  487                             else i f( "sweepT ime".equal s(attribut e.getName( )) )
  488                                      setSweep Time( (Lon g)attribut e.getValue () );
  489                             else i f( "traceC hannelInst antiation" .equals(at tribute.ge tName()) )
  490                                      setTrace ChannelIns tantiation ( (Boolean )attribute .getValue( ) );
  491                             else
  492                                      throw ne w Attribut eNotFoundE xception(" Attribute  '" + attri bute + "'  not found. ");
  493                    } 
  494                    catc h (ClassCa stExceptio n x)
  495                    {
  496                             throw  new Invali dAttribute ValueExcep tion("Attr ibute '" +  attribute  + "' valu es was of  incorrect  type.");
  497                    }
  498           }
  499  
  500           /* *
  501            *  @see java x.manageme nt.Dynamic MBean#setA ttributes( javax.mana gement.Att ributeList )
  502            * /
  503           pu blic Attri buteList s etAttribut es(Attribu teList att ributes)
  504           {
  505                    for( int index= 0; index <  attribute s.size();  ++index)
  506                    {
  507                             Attrib ute attrib ute = (Att ribute)att ributes.ge t(index);
  508                             
  509                             try
  510                             {
  511                                      setAttri bute(attri bute);
  512                             } 
  513                             catch  (Attribute NotFoundEx ception x)
  514                             {
  515                                      x.printS tackTrace( );
  516                             } 
  517                             catch  (InvalidAt tributeVal ueExceptio n x)
  518                             {
  519                                      x.printS tackTrace( );
  520                             } 
  521                             catch  (MBeanExce ption x)
  522                             {
  523                                      x.printS tackTrace( );
  524                             } 
  525                             catch  (Reflectio nException  x)
  526                             {
  527                                      x.printS tackTrace( );
  528                             }
  529                    }
  530                    
  531                    retu rn attribu tes;
  532           }
  533           
  534           /* *
  535            *  @see java x.manageme nt.Dynamic MBean#invo ke(java.la ng.String,  java.lang .Object[],  java.lang .String[])
  536            * /
  537           pu blic Objec t invoke(S tring acti onName, Ob ject[] par ams, Strin g[] signat ure) 
  538           th rows MBean Exception,  Reflectio nException
  539           {
  540                    retu rn null;
  541           }
  542  
  543           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ======
  544           //  The threa d that mon itors and  cleans up  channels t hat have b een left h anging
  545           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ======
  546           /* *
  547            *  
  548              * @author  DN S      BECKEC
  549            *
  550            * /
  551           cl ass Channe lCleanupTh read 
  552           ex tends Thre ad
  553           {
  554                    priv ate long s weepInterv al;
  555                    priv ate long m axChannelO penDuratio n;
  556                    priv ate boolea n running  = true;
  557                    
  558                    Chan nelCleanup Thread(lon g sweepInt erval, lon g maxChann elOpenDura tion)
  559                    {
  560                             this.s weepInterv al = sweep Interval;
  561                             this.m axChannelO penDuratio n = maxCha nnelOpenDu ration;
  562                             
  563                             this.s etDaemon(t rue);
  564                    }
  565                    
  566                    publ ic void ki ll()
  567                    {
  568                             this.r unning = f alse;
  569                             this.i nterrupt() ;
  570                    }
  571  
  572                    @Ove rride
  573                    publ ic void ru n()
  574                    {
  575                             while( running)
  576                             {
  577                                      long min OpenTime =  System.cu rrentTimeM illis() -  maxChannel OpenDurati on;
  578                                      
  579                                      log.info ("Sweeping  write cha nnels open  before "  + df.forma t(minOpenT ime));
  580                                      try
  581                                      {
  582                                               List<Insta nceWritabl eByteChann elImpl> wr iteChannel KillList =  new Array List<Insta nceWritabl eByteChann elImpl>();
  583                                               try
  584                                               {
  585                                                       //  do the ki ll/close i n two loop s to avoid  concurren t modifica tion excep tions
  586                                                       fo r( Instanc eWritableB yteChannel Impl write Channel:op enWriteCha nnels.keyS et() )
  587                                                       {
  588                                                                if(  writeChann el.getLast AccessedTi me() < min OpenTime )
  589                                                                {
  590                                                                         log.wa rn("Writab le Byte Ch annel " +  writeChann el.toStrin g() + " ha s remained  open past  the maxim um allowab le, forcin g close!"  );
  591                                                                         writeC hannelKill List.add(w riteChanne l);
  592                                                                         
  593                                                                         if(isT raceChanne lInstantia tion())
  594                                                                         {
  595                                                                                  StackTra ceElement[ ] instanti atingStack Trace = wr iteChannel .getInstan tiatingSta ckTrace();
  596                                                                                  warnInst antiatingS tackTrace( instantiat ingStackTr ace);
  597                                                                         }
  598                                                                }
  599                                                       }
  600                                               }
  601                                               catch(Conc urrentModi ficationEx ception cm X)
  602                                               {
  603                                                       //  note that  if we get  a concurr ent modifi cation (i. e. another  thread is  opening o r closing  readable c hannels)
  604                                                       //  then log  it but don 't fail 'c ause we ca n always c lose the c hannel lat er
  605                                                       lo g.info("Co ncurrent m odificatio n exceptio n while it erating op en write c hannels, s ome overdu e channels  may not b e closed i mmediately .");
  606                                               }
  607                                              
  608                                               log.info(" Closing "  + writeCha nnelKillLi st.size()  + " write  channels d ue to inac tivity tim eout");
  609                                               for(Instan ceWritable ByteChanne lImpl dead Channel:wr iteChannel KillList)
  610                                               {
  611                                                       tr y
  612                                                       {
  613                                                                dead Channel.er ror();
  614                                                       } 
  615                                                       ca tch (IOExc eption e)
  616                                                       {
  617                                                                log. error(e);
  618                                                       }
  619                                                       no tifyTimeou tWritableC hannelList eners(dead Channel);
  620                                                       op enWriteCha nnels.remo ve(deadCha nnel);
  621                                               }
  622                                              
  623                                               log.info(" Sweeping r ead channe ls open be fore " + d f.format(m inOpenTime ));
  624                                               List<Insta nceReadabl eByteChann elImpl> re adChannelK illList =  new ArrayL ist<Instan ceReadable ByteChanne lImpl>();
  625                                              
  626                                               // do the  kill/close  in two lo ops to avo id concurr ent modifi cation exc eptions
  627                                               try
  628                                               {
  629                                                       fo r( Instanc eReadableB yteChannel Impl readC hannel:ope nReadChann els.keySet () )
  630                                                       {
  631                                                                if(  readChanne l.getLastA ccessedTim e() < minO penTime )
  632                                                                {
  633                                                                         log.wa rn("Readab le Byte Ch annel " +  readChanne l.toString () + " has  remained  open past  the maximu m allowabl e, notifyi ng listene rs" );
  634                                                                         readCh annelKillL ist.add(re adChannel) ;
  635                                                                         
  636                                                                         if(isT raceChanne lInstantia tion())
  637                                                                         {
  638                                                                                  StackTra ceElement[ ] instanti atingStack Trace = re adChannel. getInstant iatingStac kTrace();
  639                                                                                  warnInst antiatingS tackTrace( instantiat ingStackTr ace);
  640                                                                         }
  641                                                                }
  642                                                       }
  643                                               }
  644                                               catch(Conc urrentModi ficationEx ception cm X)
  645                                               {
  646                                                       //  note that  if we get  a concurr ent modifi cation (i. e. another  thread is  opening o r closing  readable c hannels)
  647                                                       //  then log  it but don 't fail 'c ause we ca n always c lose the c hannel lat er
  648                                                       lo g.info("Co ncurrent m odificatio n exceptio n while it erating op en read ch annels, so me overdue  channels  may not be  closed im mediately. ");
  649                                               }
  650                                              
  651                                               log.info(" Closing "  + readChan nelKillLis t.size() +  " read ch annels due  to inacti vity timeo ut");
  652                                               for(Instan ceReadable ByteChanne lImpl dead Channel:re adChannelK illList)
  653                                               {
  654                                                       tr y
  655                                                       {
  656                                                                dead Channel.cl ose();
  657                                                       } 
  658                                                       ca tch (IOExc eption e)
  659                                                       {
  660                                                                log. error(e);
  661                                                       }
  662                                                       no tifyTimeou tReadableC hannelList eners(dead Channel);
  663                                                       op enReadChan nels.remov e(deadChan nel);
  664                                               }
  665                                              
  666                                               sleep(swee pInterval) ;
  667                                      } 
  668                                      catch (I nterrupted Exception  e)
  669                                      {
  670                                               // if some one interr upts us th en run the  thread ou t, we're d one
  671                                               log.error( e);
  672                                               break;
  673                                      }
  674                             }
  675                    }
  676                    
  677                    /*
  678                     * L og warning  about who  is leavin g channels  open, if  the info i s availabl e, else
  679                     * j ujst log m essages th at a chann el was lef t open.
  680                     */
  681                    priv ate void w arnInstant iatingStac kTrace(Sta ckTraceEle ment[] ins tantiating StackTrace )
  682                    {
  683                             if(ins tantiating StackTrace  != null)
  684                             {
  685                                      StackTra ceAnalyzer  stAnalyze r = new St ackTraceAn alyzer(ins tantiating StackTrace );
  686                                      StackTra ceElement  element =  stAnalyzer .getFirstE lementNotI nPackageHi erarchy("g ov.va.med. imaging.st orage.cach e");
  687                                      if(eleme nt != null )
  688                                               log.warn(" Method '"  + element. getClassNa me() + "."  + element .getMethod Name() + " ' (or some thing it c alls) is o pening cha nnels that  are not b eing close d." + 
  689                                                                "Ent ire call s tack is:\n " + stAnal yzer.toStr ing());
  690                                      else
  691                                               log.warn(" Some metho d in this  stack trac e is openi ng channel s that are  not being  closed:\n " + stAnal yzer.toStr ing());
  692                             }
  693                             else
  694                                      log.warn ("Stack Tr ace analys is of chan nel instan tiating me thod is no t availabl e.  Turn T raceChanne lInstantia tion on to  find the  offending  code.");
  695                             
  696                    }
  697           }                 // end  ChannelCl eanup
  698   }