124. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:38 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.

124.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreValueObjects\main\src\java\gov\va\med\imaging\exchange\storage DataSourceByteBufferPoolManager.java Mon Dec 4 21:35:00 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreValueObjects\main\src\java\gov\va\med\imaging\exchange\storage DataSourceByteBufferPoolManager.java Mon Dec 4 21:58:58 2017 UTC

124.2 Comparison summary

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

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

124.4 Active regular expressions

No regular expressions were active.

124.5 Comparison detail

  1   /**
  2    * 
  3     Package:  MAG - Vis tA Imaging
  4     WARNING:  Per VHA D irective 2 004-038, t his routin e should n ot be modi fied.
  5     Date Cre ated: Oct  1, 2008
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:          
WERFEJ
  8     Descript ion: 
  9  
  10           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  11           ;;  Property  of the US  Government .
  12           ;;  No permis sion to co py or redi stribute t his softwa re is give n.
  13           ;;  Use of un released v ersions of  this soft ware requi res the us er
  14           ;;   to execu te a writt en test ag reement wi th the Vis tA Imaging
  15           ;;   Developm ent Office  of the De partment o f Veterans  Affairs,
  16           ;;   telephon e (301) 73 4-0100.
  17           ;;
  18           ;;  The Food  and Drug A dministrat ion classi fies this  software a s
  19           ;;  a Class I I medical  device.  A s such, it  may not b e changed
  20           ;;  in any wa y.  Modifi cations to  this soft ware may r esult in a n
  21           ;;  adulterat ed medical  device un der 21CFR8 20, the us e of which
  22           ;;  is consid ered to be  a violati on of US F ederal Sta tutes.
  23           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  24  
  25    */
  26   package go v.va.med.i maging.exc hange.stor age;
  27  
  28   import gov .va.med.im aging.Imag ingMBean;
  29   import gov .va.med.im aging.Size dInputStre am;
  30   import gov .va.med.im aging.exch ange.stora ge.ByteBuf ferPool;
  31   import gov .va.med.im aging.exch ange.stora ge.KnownSi zeByteBuff er;
  32  
  33   import jav a.io.ByteA rrayInputS tream;
  34   import jav a.io.ByteA rrayOutput Stream;
  35   import jav a.io.IOExc eption;
  36   import jav a.io.Input Stream;
  37   import jav a.lang.man agement.Ma nagementFa ctory;
  38   import jav a.nio.Byte Buffer;
  39   import jav a.util.Has htable;
  40   import jav a.util.Lis t;
  41   import jav a.util.Set ;
  42   import jav a.util.Tre eSet;
  43  
  44   import jav ax.managem ent.MBeanS erver;
  45   import jav ax.managem ent.Object Name;
  46  
  47   import org .apache.lo gging.log4 j.LogManag er;
  48   import org .apache.lo gging.log4 j.Logger;
  49  
  50   /**
  51    * Manager  of the by te buffer  list, find s the corr ect buffer  list to u se.
  52    * 
  53    * @author         
WERFEJ
  54    * @deprec ated Buffe r pool no  longer use d, use Dat aSourceByt eBufferPoo lFactory i nstead
  55    *
  56    */
  57   @Deprecate d
  58   public cla ss DataSou rceByteBuf ferPoolMan ager 
  59   implements  DataSourc eByteBuffe rPoolManag erMBean
  60   {
  61  
  62           pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(Data SourceByte BufferPool Manager.cl ass);
  63           
  64           pr ivate Set< ByteBuffer Pool> buff ers = null ;
  65           pr ivate int  overloaded BufferRequ estsCount  = 0;
  66           pr ivate int  highestOve rloadedBuf ferRequest Size = 0;
  67           
  68           pu blic DataS ourceByteB ufferPoolM anager()
  69           {
  70                    //cr eateBuffer Lists();
  71                    // c hange to l oad buffer s from fil e
  72           }
  73           
  74           pr ivate stat ic DataSou rceByteBuf ferPoolMan ager manag er = null;
  75           
  76           pu blic synch ronized st atic DataS ourceByteB ufferPoolM anager get ByteBuffer PoolManage r()
  77           {
  78                    if(m anager ==  null)
  79                    {
  80                             manage r = new Da taSourceBy teBufferPo olManager( );
  81                             manage r.initiali zeBufferPo olManager( );
  82                             regist erResource MBeans();
  83                    }
  84                    retu rn manager ;
  85           }
  86           
  87           /* *
  88            *  Initializ e the buff er pools,  either fro m the conf iguration  file or us ing defaul t lists
  89            * /
  90           pr ivate void  initializ eBufferPoo lManager()
  91           {
  92                    mana ger.create BufferList s();
  93           }
  94           
  95           pr ivate List <BufferCon figuration > getBuffe rConfigura tions()
  96           {
  97                    retu rn ByteBuf ferPoolCon figuration .getByteBu fferPoolCo nfiguratio n().getBuf fers();
  98           }
  99           
  100           pr ivate void  createBuf ferLists()
  101           {
  102                    logg er.info("C reating bu ffers in b uffer pool  list");
  103                    buff ers = new  TreeSet<By teBufferPo ol>();
  104                    
  105                    for( BufferConf iguration  configurat ion : getB ufferConfi gurations( ))
  106                    {
  107                             buffer s.add(Byte BufferPool .createByt eBufferLis t(configur ation.getB ufferListN ame(), 
  108                                      configur ation.getM axBufferSi ze(), conf iguration. getOptimal BufferCoun t(),
  109                                      configur ation.getI nitialBuff ers()));
  110                    }
  111           }
  112           
  113           pr ivate Set< ByteBuffer Pool> getB uffers()
  114           {
  115                    retu rn buffers ;
  116           }
  117           
  118           /* *
  119            *  Read the  input stre am into a  buffer. Th is functio n gets a b uffer to u se based o n the know n size
  120            *  of the in put data
  121            *  
  122            *  @param id entifier
  123            *  @param in putStream
  124            *  @param si ze
  125            *  @return
  126            *  @throws I OException
  127            * /
  128           pu blic Known SizeByteBu ffer readI ntoBuffer( String ide ntifier, I nputStream  inputStre am, 
  129                    int  size)
  130           th rows IOExc eption
  131           {
  132                    if(s ize > 0)
  133                    {
  134                             logger .info("Rea ding file  [" + ident ifier + "]  into buff er of size  [" + size  + "]");
  135                             ByteBu ffer store Buffer = g etBuffer(s ize);
  136                             
  137                             byte[]  byteBuffe r = new by te[1024];
  138                             int le n;
  139                             int by tesRead =  0;
  140                    whil e ((len =  inputStrea m.read(byt eBuffer))  > 0) 
  141                    {
  142                             storeB uffer.put( byteBuffer , 0, len);
  143                             bytesR ead += len ;
  144                    }
  145                    logg er.info("D one readin g file ["  + identifi er + "] in to buffer,  read [" +  bytesRead  + "] byte s");
  146                    retu rn new Kno wnSizeByte Buffer(ide ntifier, s toreBuffer , bytesRea d);
  147                    }
  148                    else
  149                    {
  150                             return  readIntoB uffer(iden tifier, in putStream) ;
  151                    }
  152           }
  153           
  154           /* *
  155            *  Read the  input stre am into a  buffer. Th is functio n reads th e data int o a tempor ary buffer
  156            *  before pu tting it i nto a buff er pool bu ffer becau se the siz e of the d ata is unk nown.
  157            *  
  158            *  @param id entifier
  159            *  @param in putStream
  160            *  @return
  161            *  @throws I OException  occurs if  there is  an error r eading the  image int o the buff er
  162            * /
  163           pu blic Known SizeByteBu ffer readI ntoBuffer( String ide ntifier, I nputStream  inputStre am)
  164           th rows IOExc eption
  165           {
  166                    logg er.info("R eading fil e [" + ide ntifier +  "] into bu ffer of un known size ");
  167                    Byte ArrayOutpu tStream bu ffer = new  ByteArray OutputStre am();
  168                    byte [] byteBuf fer = new  byte[1024] ;
  169                    int  len;
  170                    int  bytesRead  = 0;
  171           wh ile ((len  = inputStr eam.read(b yteBuffer) ) > 0) {
  172                    byte sRead += l en;
  173                    buff er.write(b yteBuffer,  0, len);
  174           }
  175           By teBuffer s toreBuffer  = getBuff er(bytesRe ad);
  176           st oreBuffer. put(buffer .toByteArr ay());
  177           lo gger.info( "Done read ing file [ " + identi fier + "]  into buffe r, read ["  + bytesRe ad + "] by tes");
  178           re turn new K nownSizeBy teBuffer(i dentifier,  storeBuff er, bytesR ead);
  179           }
  180           
  181           /* *
  182            *  Opens an  SizedInput Stream to  the buffer
  183            *  
  184            *  @param bu ffer
  185            *  @return
  186            * /
  187           pu blic Sized InputStrea m openStre amToBuffer (KnownSize ByteBuffer  buffer)
  188           {
  189                    logg er.info("O pening siz ed input s tream to b uffer [" +  buffer.ge tIdentifie r() + "]") ;
  190                    Byte ArrayInput Stream inS tream = ne w ByteArra yInputStre am(buffer. getBuffer( ).array(),  0, buffer .getKnownS ize());
  191           Si zedInputSt ream sized Stream = n ew SizedIn putStream( inStream,  buffer.get KnownSize( ));
  192           re turn sized Stream;
  193           }
  194           
  195           /* *
  196            *  Gets a bu ffer to us e based on  the size  of the dat a being st ored. It w ill get th e buffer f rom one 
  197            *  of the po ols select ing the sm allest buf fer that m eets the s ize.  If n o pool can  meet the  size 
  198            *  requireme nt, then a  new buffe r of the e xact reque sted size  is created .
  199            *  
  200            *  @param mi nSize
  201            *  @return
  202            * /
  203           pr ivate Byte Buffer get Buffer(int  minSize)
  204           {
  205                    logg er.info("R etrieving  buffer fro m cache of  minimum s ize [" + m inSize + " ]");
  206                    Byte BufferPool  bufferLis t = getBuf ferToUse(m inSize);
  207                    if(b ufferList  == null)
  208                    {
  209                             logger .error("Cr eating buf fer of siz e [" + min Size + "],  not assoc iated with  a buffer  list, new  buffer lis t of minim um size mi ght be nee ded");
  210                             overlo adedBuffer RequestsCo unt++;
  211                             if(min Size > hig hestOverlo adedBuffer RequestSiz e)
  212                                      highestO verloadedB ufferReque stSize = m inSize;
  213                             return  ByteBuffe r.allocate (minSize);  
  214                    }
  215                    
  216                    sync hronized ( bufferList
  217                    {
  218                             if(buf ferList.ge tBufferLis tSize() >  0)
  219                             {
  220                                      logger.i nfo("Retre iving exis ting buffe r from buf fer list p ool '" + b ufferList  + "'");
  221                                      return b ufferList. removeBuff erFromList (minSize);
  222                             }
  223                             else
  224                             {
  225                                      return b ufferList. createNewB uffer(minS ize);
  226                             }
  227                    }
  228           }
  229           
  230           /* *
  231            *  Determine  what buff er to use  based on t he size of  the reque st. If no  buffer mee ts the min imum
  232            *  size requ est, null  is returne d.
  233            *  
  234            *  @param mi nimumSize
  235            *  @return
  236            * /
  237           pr ivate Byte BufferPool  getBuffer ToUse(int  minimumSiz e)
  238           {                 
  239                    for( ByteBuffer Pool buffy  : getBuff ers())
  240                    {
  241                             if(min imumSize <  buffy.get MaxBufferS izeInBytes ())
  242                             {
  243                                      return b uffy;
  244                             }
  245                    }
  246                    retu rn null;
  247           }
  248           
  249           /* *
  250            *  Determine  the buffe r pool lis t to relea se the buf fer to. Th is is base d on the s ize of the  buffer.
  251            *  If there  is no pool  for the s pecified s ize, then  null is re turned
  252            *  
  253            *  @param bu fferSize
  254            *  @return
  255            * /
  256           pr ivate Byte BufferPool  getBuffer ListToRele aseTo(int  bufferSize )
  257           {
  258                    for( ByteBuffer Pool buffy  : getBuff ers())
  259                    {
  260                             if(buf ferSize ==  buffy.get MaxBufferS izeInBytes ())
  261                             {
  262                                      return b uffy;
  263                             }
  264                    }
  265                    retu rn null;
  266                    /*
  267                    if(b ufferSize  == buffer1 00k.getMax BufferSize InBytes())
  268                    {
  269                             return  buffer100 k;
  270                    }
  271                    else  if(buffer Size ==  b uffer1024k .getMaxBuf ferSizeInB ytes())
  272                    {
  273                             return  buffer102 4k;
  274                    }
  275                    else  if(buffer Size ==  b uffer5120k .getMaxBuf ferSizeInB ytes())
  276                    {
  277                             return  buffer512 0k;
  278                    }
  279                    else  if(buffer Size ==  b uffer10240 k.getMaxBu fferSizeIn Bytes())
  280                    {
  281                             return  buffer102 40k;
  282                    }
  283                    else
  284                    {
  285                             return  null;
  286                    }
  287                    */
  288           }
  289  
  290           /* *
  291            *  Release t he buffer  back into  the correc t pool (if  there is  one).
  292            *  @param bu ffer
  293            * /
  294           pu blic void  releaseBuf fer(ByteBu ffer buffe r)
  295           {
  296                    logg er.info("r eleasing b uffer back  into cach e");
  297                    Byte BufferPool  bufferToR eleaseTo =  getBuffer ListToRele aseTo(buff er.capacit y());
  298                    // i f the buff er has a s ize too bi g for any  in the poo l, don't w ant to put  it in the  pool beca use
  299                    // i t will hav e a random  size and  will make  finding it  more diff icult
  300                    if(b ufferToRel easeTo !=  null)
  301                    {
  302                             logger .info("Put ting buffe r into buf fer pool ' " + buffer ToReleaseT o + "'");
  303                             buffer .clear();
  304                             synchr onized (bu fferToRele aseTo) 
  305                             {
  306                                      bufferTo ReleaseTo. returnBuff erToList(b uffer);
  307                             }
  308                             
  309                    }
  310           }
  311  
  312           /*  (non-Java doc)
  313            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#g etBufferPo olCount()
  314            * /
  315           @O verride
  316           pu blic int g etBufferPo olCount() 
  317           {
  318                    retu rn buffers .size();
  319           }
  320           
  321           
  322           
  323           /*  (non-Java doc)
  324            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#g etOverload edBufferSi zeRequests ()
  325            * /
  326           @O verride
  327           pu blic int g etOverload edBufferSi zeRequests () 
  328           {
  329                    retu rn overloa dedBufferR equestsCou nt;
  330           }
  331  
  332           /*  (non-Java doc)
  333            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#g etHighestO verloadedB ufferSizeR equest()
  334            * /
  335           @O verride
  336           pu blic int g etHighestO verloadedB ufferSizeR equest() 
  337           {
  338                    retu rn highest Overloaded BufferRequ estSize;
  339           }
  340  
  341           /*  (non-Java doc)
  342            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#g etBufferNa mes()
  343            * /
  344           @O verride
  345           pu blic Strin g getBuffe rNames() 
  346           {
  347                    Stri ngBuilder  sb = new S tringBuild er();
  348                    Stri ng prefix  = "";
  349                    for( ByteBuffer Pool pool  : buffers)
  350                    {
  351                             sb.app end(prefix );
  352                             sb.app end(pool.g etName());
  353                             prefix = ",";
  354                    }
  355                    retu rn sb.toSt ring();
  356           }
  357  
  358           pr ivate stat ic ObjectN ame buffer PoolManage rMBeanName  = null;
  359           /* *
  360            *  This meth od should  only be ca lled once,  else MBea n exceptio ns will oc cur.
  361            * /
  362           pr ivate sync hronized s tatic void  registerR esourceMBe ans()
  363       {
  364                    MBea nServer mB eanServer  = Manageme ntFactory. getPlatfor mMBeanServ er();
  365                    
  366                    if(b ufferPoolM anagerMBea nName == n ull)
  367                    {
  368                             DataSo urceByteBu fferPoolMa nager buff erManager  = getByteB ufferPoolM anager();
  369                             if(buf ferManager  instanceo f DataSour ceByteBuff erPoolMana gerMBean)
  370                             {
  371                                      try
  372                         {
  373                                               // VistaIm aging.ViX: type=Cache ,name=Imag ingExchang eCache
  374                                               Hashtable< String, St ring> mBea nPropertie s = new Ha shtable<St ring, Stri ng>();
  375                                               mBeanPrope rties.put(  "type", " ByteBuffer PoolManage r" );
  376                                               //mBeanPro perties.pu t( "name",  "Manager- " + Intege r.toHexStr ing(buffer Manager.ha shCode())  );
  377                                               mBeanPrope rties.put(  "name", " Manager");
  378                                 bu fferPoolMa nagerMBean Name = new  ObjectNam e(ImagingM Bean.VIX_M BEAN_DOMAI N_NAME, mB eanPropert ies);
  379                                 mB eanServer. registerMB ean(buffer Manager, b ufferPoolM anagerMBea nName);
  380                                 
  381                                 fo r(ByteBuff erPool buf fer : buff erManager. getBuffers ())
  382                                 {
  383                                      mBeanPro perties =  new Hashta ble<String , String>( );
  384                                                       mB eanPropert ies.put( " type", "By teBufferPo olManager"  );
  385                                                       mB eanPropert ies.put( " name", buf fer.getNam e() );
  386                                          buff erPoolMana gerMBeanNa me = new O bjectName( ImagingMBe an.VIX_MBE AN_DOMAIN_ NAME, mBea nPropertie s);
  387                                          mBea nServer.re gisterMBea n(buffer,  bufferPool ManagerMBe anName);
  388                                 }
  389                        
  390                                      catch (E xception e ){ LogMana ger.getLog ger(DataSo urceByteBu fferPoolMa nager.clas s).error(e .toString( )); }
  391                             }
  392                    }
  393       }
  394  
  395           /*  (non-Java doc)
  396            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#g etTotalCre ateNewBuff erCount()
  397            * /
  398           @O verride
  399           pu blic int g etTotalCre ateNewBuff erCount() 
  400           {
  401                    int  count = 0;
  402                    for( ByteBuffer Pool buffe rPool : ge tBuffers() )
  403                    {
  404                             count  += bufferP ool.getCre ateNewBuff erCount();
  405                    } 
  406                    retu rn count;
  407           }
  408  
  409           /*  (non-Java doc)
  410            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#g etTotalReq uestBuffer Count()
  411            * /
  412           @O verride
  413           pu blic int g etTotalReq uestBuffer Count() 
  414           {
  415                    int  count = 0;
  416                    for( ByteBuffer Pool buffe rPool : ge tBuffers() )
  417                    {
  418                             count  += bufferP ool.getReq uestBuffer Count();
  419                    } 
  420                    retu rn count;
  421           }
  422  
  423           /*  (non-Java doc)
  424            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#g etTotalRet urnBufferC ount()
  425            * /
  426           @O verride
  427           pu blic int g etTotalRet urnBufferC ount() 
  428           {
  429                    int  count = 0;
  430                    for( ByteBuffer Pool buffe rPool : ge tBuffers() )
  431                    {
  432                             count  += bufferP ool.getRet urnBufferC ount();
  433                    } 
  434                    retu rn count;
  435           }
  436  
  437           /*  (non-Java doc)
  438            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#g etTotalBuf ferSizeUse ()
  439            * /
  440           @O verride
  441           pu blic long  getTotalBu fferSizeUs e() 
  442           {
  443                    int  count = 0;
  444                    for( ByteBuffer Pool buffe rPool : ge tBuffers() )
  445                    {
  446                             count  += bufferP ool.getBuf ferSizeUse ();
  447                    } 
  448                    retu rn count;
  449           }
  450  
  451           /*  (non-Java doc)
  452            *  @see gov. va.med.ima ging.excha nge.storag e.DataSour ceByteBuff erPoolMana gerMBean#r esetCounte rs()
  453            * /
  454           @O verride
  455           pu blic void  resetCount ers() 
  456           {
  457                    for( ByteBuffer Pool buffe rPool : ge tBuffers() )
  458                    {
  459                             buffer Pool.reset Counters() ;
  460                    } 
  461           }        
  462   }