11. EPMO Open Source Coordination Office Redaction File Detail Report

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

11.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IV-ehmp_cif\CacheImplMemory\main\src\java\gov\va\med\imaging\storage\cache\impl\memory MemoryInstanceByteChannelFactory.java Thu Jun 29 17:22:25 2017 UTC
2 C:\AraxisMergeCompare\Pri_re\IV-ehmp_cif\CacheImplMemory\main\src\java\gov\va\med\imaging\storage\cache\impl\memory MemoryInstanceByteChannelFactory.java Fri Jul 7 16:36:29 2017 UTC

11.2 Comparison summary

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

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

11.4 Active regular expressions

No regular expressions were active.

11.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging.sto rage.cache .impl.memo ry;
  5  
  6   import gov .va.med.im aging.stor age.cache. InstanceBy teChannelF actory;
  7   import gov .va.med.im aging.stor age.cache. InstanceBy teChannelL istener;
  8   import gov .va.med.im aging.stor age.cache. InstanceRe adableByte Channel;
  9   import gov .va.med.im aging.stor age.cache. InstanceWr itableByte Channel;
  10   import gov .va.med.im aging.stor age.cache. TracableCo mponent;
  11   import gov .va.med.im aging.stor age.cache. exceptions .CacheExce ption;
  12   import gov .va.med.im aging.stor age.cache. exceptions .Persisten ceIOExcept ion;
  13   import gov .va.med.im aging.stor age.cache. impl.memor y.data.Mem oryInstanc eData;
  14   import gov .va.med.im aging.stor age.cache. impl.memor y.data.Mem oryInstanc eDataFacto ry;
  15   import gov .va.med.im aging.stor age.cache. memento.By teChannelF actoryMeme nto;
  16  
  17   import jav a.io.File;
  18   import jav a.io.IOExc eption;
  19   import jav a.nio.Byte Buffer;
  20   import jav a.util.Has hSet;
  21   import jav a.util.Set ;
  22   import jav a.util.zip .Checksum;
  23  
  24   /**
  25    * @author          R E DA C T E D
  26    *
  27    */
  28   public cla ss MemoryI nstanceByt eChannelFa ctory 
  29   implements  InstanceB yteChannel Factory<In teger>, In stanceByte ChannelLis tener
  30   {
  31           pu blic final  static in t maxInsta nceSize =  4096;
  32           pr ivate long  sweepTime  = 1000;
  33           pr ivate long  maxChanne lOpenDurat ion = 1000 0;
  34           pr ivate bool ean traceC hannelInst antiation;
  35           pr ivate int  currentlyO penReadabl eByteChann els = 0;
  36           pr ivate int  currentlyO penWritabl eByteChann els = 0;
  37           pr ivate Memo ryInstance DataFactor y instance Factory;
  38           
  39           pu blic Memor yInstanceB yteChannel Factory(Me moryInstan ceDataFact ory instan ceFactory)
  40           {
  41                    this .instanceF actory = i nstanceFac tory;
  42           }
  43           
  44           pu blic Memor yInstanceD ataFactory  getInstan ceFactory( )
  45           {
  46                    retu rn instanc eFactory;
  47           }
  48  
  49           pu blic int g etCurrentl yOpenReada bleByteCha nnels()
  50           {
  51                    retu rn current lyOpenRead ableByteCh annels;
  52           }
  53           
  54           pu blic int g etCurrentl yOpenWrita bleByteCha nnels()
  55           {
  56                    retu rn current lyOpenWrit ableByteCh annels;
  57           }
  58  
  59           /*  (non-Java doc)
  60            *  @see gov. va.med.ima ging.stora ge.cache.I nstanceByt eChannelFa ctory#getI nstanceRea dableByteC hannel(jav a.lang.Obj ect, gov.v a.med.imag ing.storag e.cache.In stanceByte ChannelLis tener)
  61            * /
  62           pu blic Insta nceReadabl eByteChann el getInst anceReadab leByteChan nel(Intege r instance Id, Instan ceByteChan nelListene r timeoutL istener)
  63           th rows Persi stenceIOEx ception, C acheExcept ion
  64           {
  65                    Memo ryInstance Data insta nce = getI nstanceFac tory().get (instanceI d);
  66                    if(i nstance !=  null)
  67                    {
  68                             Instan ceReadable ByteChanne l readable  = new Moc kInstanceR eadableByt eChannel(i nstance);
  69                             ++curr entlyOpenR eadableByt eChannels;
  70                             return  readable;
  71                    }
  72                    
  73                    retu rn null;
  74           }
  75  
  76           /*  (non-Java doc)
  77            *  @see gov. va.med.ima ging.stora ge.cache.I nstanceByt eChannelFa ctory#getI nstanceWri tableByteC hannel(jav a.lang.Obj ect, gov.v a.med.imag ing.storag e.cache.In stanceByte ChannelLis tener)
  78            * /
  79           pu blic Insta nceWritabl eByteChann el getInst anceWritab leByteChan nel(Intege r instance Id, Instan ceByteChan nelListene r timeoutL istener)
  80           th rows Persi stenceIOEx ception, C acheExcept ion
  81           {
  82                    Memo ryInstance Data insta nceData =  getInstanc eFactory() .getOrCrea te(instanc eId, maxIn stanceSize );
  83                    Inst anceWritab leByteChan nel writab le = new M ockInstanc eWritableB yteChannel (instanceD ata);
  84                    ++cu rrentlyOpe nReadableB yteChannel s;
  85                    retu rn writabl e;
  86           }
  87  
  88           /* *
  89            *  @param id
  90            * /
  91           pu blic void  remove(Int eger insta nceId)
  92           {
  93                    getI nstanceFac tory().ins tanceRemov ed(instanc eId);
  94           }
  95           
  96           /*  (non-Java doc)
  97            *  @see gov. va.med.ima ging.stora ge.cache.I nstanceByt eChannelFa ctory#getM axChannelO penDuratio n()
  98            * /
  99           pu blic long  getMaxChan nelOpenDur ation()
  100           {
  101                    retu rn maxChan nelOpenDur ation;
  102           }
  103  
  104           pu blic void  setMaxChan nelOpenDur ation(long  max)
  105           {
  106                    this .maxChanne lOpenDurat ion = max;
  107           }
  108  
  109           pu blic long  getSweepTi me()
  110           {
  111                    retu rn sweepTi me;
  112           }
  113  
  114           pu blic void  setSweepTi me(long sw eep)
  115           {
  116                    this .sweepTime  = sweep;
  117           }
  118           
  119           /*  (non-Java doc)
  120            *  @see gov. va.med.ima ging.stora ge.cache.I nstanceByt eChannelFa ctory#isTr aceChannel Instantiat ion()
  121            * /
  122           pu blic boole an isTrace ChannelIns tantiation ()
  123           {
  124                    retu rn traceCh annelInsta ntiation;
  125           }
  126  
  127           pu blic void  setTraceCh annelInsta ntiation(b oolean tra ceChannelI nstantiati on)
  128           {
  129                    this .traceChan nelInstant iation = t raceChanne lInstantia tion;
  130           }
  131  
  132           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== =======
  133           //  InstanceB yteChannel Listener
  134           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== =======
  135           pu blic void  readChanne lClose(Ins tanceReada bleByteCha nnel reada ble)
  136           {
  137                    --cu rrentlyOpe nReadableB yteChannel s;
  138           }
  139  
  140           pu blic void  readChanne lIdleTimeo ut(Instanc eReadableB yteChannel  readable)
  141           {
  142                    --cu rrentlyOpe nReadableB yteChannel s;
  143           }
  144  
  145           pu blic void  writeChann elClose(In stanceWrit ableByteCh annel writ able)
  146           {
  147                    --cu rrentlyOpe nWritableB yteChannel s;
  148           }
  149  
  150           pu blic void  writeChann elIdleTime out(Instan ceWritable ByteChanne l writable )
  151           {
  152                    --cu rrentlyOpe nWritableB yteChannel s;
  153           }
  154  
  155           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== =======
  156           //  State Ser ialization
  157           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== =======
  158           pu blic ByteC hannelFact oryMemento  createMem ento()
  159           {
  160                    retu rn null;
  161           }
  162  
  163           pu blic void  restoreMem ento(ByteC hannelFact oryMemento  memento)
  164           {
  165           }
  166           
  167           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== =======
  168           //  ByteChann el Realiza tions
  169           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== =======
  170           /* *
  171            *  
  172              * @author         R E DA C T E D
  173            *
  174            * /
  175           cl ass MockIn stanceRead ableByteCh annel
  176           im plements I nstanceRea dableByteC hannel, Tr acableComp onent
  177           {
  178                    priv ate Memory InstanceDa ta instanc eData;
  179                    priv ate StackT raceElemen t[] instan tiatingSta ckTrace =  null;
  180                    int  position =  0;
  181                    priv ate boolea n open = t rue;             // t he channel  is open w hen it is  created
  182                    
  183                    publ ic MockIns tanceReada bleByteCha nnel(Memor yInstanceD ata instan ceData)
  184                    {
  185                             this.i nstanceDat a = instan ceData;
  186                             
  187                             instan tiatingSta ckTrace =  Thread.cur rentThread ().getStac kTrace();
  188                    }
  189                    
  190                    @Ove rride
  191                    publ ic StackTr aceElement [] getInst antiatingS tackTrace( )
  192                    {
  193                             return  instantia tingStackT race;
  194                    }
  195                    
  196                    publ ic Checksu m getCheck sum()
  197                    {
  198                             return  null;
  199                    }
  200  
  201                    publ ic int rea d(ByteBuff er dst) 
  202                    thro ws IOExcep tion
  203                    {
  204                             if( !o pen )
  205                                      throw ne w IOExcept ion("Inval id state,  channel is  already c losed.");
  206                             
  207                             int by tesRead =  Math.min(i nstanceDat a.getLimit () - posit ion, dst.r emaining()  );
  208                             if(byt esRead > 0 )
  209                                      dst.put( instanceDa ta.read(po sition, by tesRead));
  210                             
  211                             positi on += byte sRead;
  212                             
  213                             return  bytesRead ;
  214                    }
  215  
  216                    publ ic void cl ose() 
  217                    thro ws IOExcep tion
  218                    {
  219                             open =  false;
  220                             notify Listeners( false);
  221                    }
  222  
  223                    publ ic void er ror() 
  224                    thro ws IOExcep tion
  225                    {
  226                             open =  false;
  227                             notify Listeners( true);
  228                    }
  229  
  230                    publ ic boolean  isOpen()
  231                    {
  232                             return  open;
  233                    }
  234                    
  235                    priv ate Set<In stanceByte ChannelLis tener> lis teners = n ew HashSet <InstanceB yteChannel Listener>( );
  236                    publ ic void ad dListener( InstanceBy teChannelL istener li stener)
  237                    {
  238                             listen ers.add(li stener);
  239                    }
  240                    publ ic void re moveListen er(Instanc eByteChann elListener  listener)
  241                    {
  242                             listen ers.remove (listener) ;
  243                    }
  244                    priv ate void n otifyListe ners(boole an errorCl ose)
  245                    {
  246                             for(In stanceByte ChannelLis tener list ener : lis teners)
  247                                      if( erro rClose )
  248                                               listener.r eadChannel IdleTimeou t(this);
  249                                      else
  250                                               listener.r eadChannel Close(this );
  251                    }
  252  
  253                    /* ( non-Javado c)
  254                     * @ see gov.va .med.imagi ng.storage .cache.Ins tanceReada bleByteCha nnel#getLa stAccessed Time()
  255                     */
  256                    @Ove rride
  257                    publ ic long ge tLastAcces sedTime()
  258                    {
  259                             return  System.cu rrentTimeM illis();
  260                    }
  261  
  262                    publ ic File ge tCacheFile ()
  263                    {
  264                             return  null;
  265                    }
  266           }
  267  
  268           /* *
  269            *  
  270              * @author         R E DA C T E D
  271            *
  272            * /
  273           cl ass MockIn stanceWrit ableByteCh annel
  274           im plements I nstanceWri tableByteC hannel, Tr acableComp onent
  275           {
  276                    priv ate Memory InstanceDa ta instanc eData;
  277                    int  position =  0;
  278                    priv ate boolea n open = t rue;             // t he channel  is open w hen it is  created
  279                    priv ate Checks um checksu m = new ja va.util.zi p.Adler32( );
  280                    priv ate StackT raceElemen t[] instan tiatingSta ckTrace =  null;
  281                    
  282                    publ ic MockIns tanceWrita bleByteCha nnel(Memor yInstanceD ata instan ceData)
  283                    {
  284                             this.i nstanceDat a = instan ceData;
  285                             
  286                             instan tiatingSta ckTrace =  Thread.cur rentThread ().getStac kTrace();
  287                    }
  288                    
  289                    @Ove rride
  290                    publ ic StackTr aceElement [] getInst antiatingS tackTrace( )
  291                    {
  292                             return  instantia tingStackT race;
  293                    }
  294                    
  295  
  296                    publ ic boolean  isOpen()
  297                    {
  298                             return  open;
  299                    }
  300                    
  301                    publ ic Checksu m getCheck sum()
  302                    {
  303                             return  checksum;
  304                    }
  305  
  306                    publ ic int wri te(ByteBuf fer src) 
  307                    thro ws IOExcep tion
  308                    {
  309                             if( !  isOpen() )
  310                                      throw ne w IOExcept ion("Inval id state,  channel is  already c losed.");
  311                             
  312                             // ass ure that w e do not o verwrite t he buffer
  313                             if( sr c.remainin g() > (ins tanceData. getCapacit y() - posi tion) )
  314                                      throw ne w IOExcept ion("Error  writing t o channel,  storage o verflow");
  315                             int by tesWritten  = Math.mi n(instance Data.getCa pacity() -  position,  src.remai ning() );
  316                             if(byt esWritten  > 0)
  317                             {
  318                                      byte[] t mp = new b yte[src.re maining()] ;
  319                                      src.get( tmp);
  320                                      checksum .update(tm p, 0, tmp. length);
  321                                      instance Data.write (position,  tmp);
  322                             }
  323                             
  324                             positi on += byte sWritten;
  325                             
  326                             return  bytesWrit ten;
  327                    }
  328  
  329                    publ ic void er ror() 
  330                    thro ws IOExcep tion
  331                    {
  332                             open =  false;
  333                             notify Listeners( true);
  334                    }
  335  
  336                    publ ic void cl ose() 
  337                    thro ws IOExcep tion
  338                    {
  339                             open =  false;
  340                             notify Listeners( false);
  341                    }
  342  
  343                    priv ate Set<In stanceByte ChannelLis tener> lis teners = n ew HashSet <InstanceB yteChannel Listener>( );
  344                    publ ic void ad dListener( InstanceBy teChannelL istener li stener)
  345                    {
  346                             listen ers.add(li stener);
  347                    }
  348                    publ ic void re moveListen er(Instanc eByteChann elListener  listener)
  349                    {
  350                             listen ers.remove (listener) ;
  351                    }
  352                    priv ate void n otifyListe ners(boole an errorCl ose)
  353                    {
  354                             for(In stanceByte ChannelLis tener list ener : lis teners)
  355                                      if( erro rClose )
  356                                               listener.w riteChanne lIdleTimeo ut(this);
  357                                      else
  358                                               listener.w riteChanne lClose(thi s);
  359                    }
  360                    /* ( non-Javado c)
  361                     * @ see gov.va .med.imagi ng.storage .cache.Ins tanceReada bleByteCha nnel#getLa stAccessed Time()
  362                     */
  363                    @Ove rride
  364                    publ ic long ge tLastAcces sedTime()
  365                    {
  366                             return  System.cu rrentTimeM illis();
  367                    }
  368           }
  369  
  370   }