https://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&feed=atom&action=historyCompressionAndRMI - Revision history2024-03-28T23:20:34ZRevision history for this page on the wikiMediaWiki 1.27.7https://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5879&oldid=prevTredmond at 22:18, May 6, 20092009-05-06T22:18:17Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:18, May 6, 2009</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''This page is no longer valid.  It turns out that the ideas on the page [http://javatechniques.com/blog/compressing-data-sent-over-a-socket Good Compression] work fine and that is the technique that we are using now.'''</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''This page is no longer valid.  It turns out that the ideas on the page [http://javatechniques.com/blog/compressing-data-sent-over-a-socket Good Compression] work fine and that is the technique that we are using now.'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>'''The implementation below almost works but there are intermittent problems <del class="diffchange diffchange-inline">with the implementation below</del>.  It occasionally hangs - looks like even though the writer has written and flushed a zipentry the reader cannot read it.  The key is not to use any of the streams (ZipInputStream, GZIPInputStream, etc) but to write one yourself so as to take complete control of when data is flushed or not.'''</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>'''The implementation below almost works but there are intermittent problems.  It occasionally hangs - looks like even though the writer has written and flushed a zipentry the reader cannot read it.  The key is not to use any of the streams (ZipInputStream, GZIPInputStream, etc) but to write one yourself so as to take complete control of when data is flushed or not.'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5878&oldid=prevTredmond at 22:16, May 6, 20092009-05-06T22:16:33Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:16, May 6, 2009</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''This page is no longer valid.  It turns out that the ideas on the page [http://javatechniques.com/blog/compressing-data-sent-over-a-socket Good Compression] work fine and that is the technique that we are using now.'''</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''This page is no longer valid.  It turns out that the ideas on the page [http://javatechniques.com/blog/compressing-data-sent-over-a-socket Good Compression] work fine and that is the technique that we are using now.'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>'''<del class="diffchange diffchange-inline">Compression is tricky - I thought we are done </del>but <del class="diffchange diffchange-inline">we </del>are <del class="diffchange diffchange-inline">still having </del>intermittent problems with the implementation below.  It occasionally hangs - looks like even though the writer has written and flushed a zipentry the reader cannot read it.  <del class="diffchange diffchange-inline">I will update </del>or <del class="diffchange diffchange-inline">delete this page when I know more</del>.'''</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>'''<ins class="diffchange diffchange-inline">The implementation below almost works </ins>but <ins class="diffchange diffchange-inline">there </ins>are intermittent problems with the implementation below.  It occasionally hangs - looks like even though the writer has written and flushed a zipentry the reader cannot read it.  <ins class="diffchange diffchange-inline">The key is not to use any of the streams (ZipInputStream, GZIPInputStream, etc) but to write one yourself so as to take complete control of when data is flushed </ins>or <ins class="diffchange diffchange-inline">not</ins>.'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5877&oldid=prevTredmond at 22:14, May 6, 20092009-05-06T22:14:23Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:14, May 6, 2009</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">'''This page is no longer valid.  It turns out that the ideas on the page [http://javatechniques.com/blog/compressing-data-sent-over-a-socket Good Compression] work fine and that is the technique that we are using now.'''</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''Compression is tricky - I thought we are done but we are still having intermittent problems with the implementation below.  It occasionally hangs - looks like even though the writer has written and flushed a zipentry the reader cannot read it.  I will update or delete this page when I know more.'''</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''Compression is tricky - I thought we are done but we are still having intermittent problems with the implementation below.  It occasionally hangs - looks like even though the writer has written and flushed a zipentry the reader cannot read it.  I will update or delete this page when I know more.'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5282&oldid=prevTredmond at 14:38, December 10, 20082008-12-10T14:38:34Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 14:38, December 10, 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>'''Compression is tricky - I thought we are done but we are still having intermittent problems with the implementation below.  It occasionally hangs - looks like even though the writer has written and flushed the reader cannot <del class="diffchange diffchange-inline">see the result</del>.  I will update or delete this page when I know more.'''</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>'''Compression is tricky - I thought we are done but we are still having intermittent problems with the implementation below.  It occasionally hangs - looks like even though the writer has written and flushed <ins class="diffchange diffchange-inline">a zipentry </ins>the reader cannot <ins class="diffchange diffchange-inline">read it</ins>.  I will update or delete this page when I know more.'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5281&oldid=prevTredmond at 14:37, December 10, 20082008-12-10T14:37:46Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 14:37, December 10, 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">'''Compression is tricky - I thought we are done but we are still having intermittent problems with the implementation below.  It occasionally hangs - looks like even though the writer has written and flushed the reader cannot see the result.  I will update or delete this page when I know more.'''</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5211&oldid=prevTredmond at 22:11, December 4, 20082008-12-04T22:11:43Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:11, December 4, 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l2" >Line 2:</td>
<td colspan="2" class="diff-lineno">Line 2:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this solution and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown. One is not supposed to finish a GZIPOutputStream and then continue writing.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this solution and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown. One is not supposed to finish a GZIPOutputStream and then continue writing.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"># RMI uses a BufferedOutputStream that limits the data on the wire to 8192 bytes at a time.  It is argued [http://forums.sun.com/thread.jspa?threadID=5167582 here] that this makes compression hardly worth while.  But- I did this purely by accident - the compressing output stream below is also buffered and as part of a socket sits closer to the wire than RMI's buffered output stream.  This means that in terms of buffer size my buffered output stream wins - it sets the real buffer size.  And I know from measurements that I am getting almost a 10 to 1 compression ratio.  I have not yet done sufficient experiments to determine what the optimal buffer size would be.  I am currently using 64K buffers.</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>So what I needed was a way to tell the compressing stream that I had a unit that could be compressed in its entirety without interfering with future writes.  My solution was to make a compressing output stream based on a  buffered version of a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipOutputStream.html ZipOutputStream].  My idea was to buffer up data to be sent and only send data over the wire  when either the buffer is  full or flush is called explicitly:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>So what I needed was a way to tell the compressing stream that I had a unit that could be compressed in its entirety without interfering with future writes.  My solution was to make a compressing output stream based on a  buffered version of a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipOutputStream.html ZipOutputStream].  My idea was to buffer up data to be sent and only send data over the wire  when either the buffer is  full or flush is called explicitly:</div></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5154&oldid=prevTredmond at 06:37, December 2, 20082008-12-02T06:37:20Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 06:37, December 2, 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this <del class="diffchange diffchange-inline">soltion </del>and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown. One is not supposed to finish a GZIPOutputStream and then continue writing.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this <ins class="diffchange diffchange-inline">solution </ins>and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown. One is not supposed to finish a GZIPOutputStream and then continue writing.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># RMI uses a BufferedOutputStream that limits the data on the wire to 8192 bytes at a time.  It is argued [http://forums.sun.com/thread.jspa?threadID=5167582 here] that this makes compression hardly worth while.  But- I did this purely by accident - the compressing output stream below is also buffered and as part of a socket sits closer to the wire than RMI's buffered output stream.  This means that in terms of buffer size my buffered output stream wins - it sets the real buffer size.  And I know from measurements that I am getting almost a 10 to 1 compression ratio.  I have not yet done sufficient experiments to determine what the optimal buffer size would be.  I am currently using 64K buffers.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># RMI uses a BufferedOutputStream that limits the data on the wire to 8192 bytes at a time.  It is argued [http://forums.sun.com/thread.jspa?threadID=5167582 here] that this makes compression hardly worth while.  But- I did this purely by accident - the compressing output stream below is also buffered and as part of a socket sits closer to the wire than RMI's buffered output stream.  This means that in terms of buffer size my buffered output stream wins - it sets the real buffer size.  And I know from measurements that I am getting almost a 10 to 1 compression ratio.  I have not yet done sufficient experiments to determine what the optimal buffer size would be.  I am currently using 64K buffers.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5153&oldid=prevTredmond at 06:28, December 2, 20082008-12-02T06:28:42Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 06:28, December 2, 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l2" >Line 2:</td>
<td colspan="2" class="diff-lineno">Line 2:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this soltion and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown. One is not supposed to finish a GZIPOutputStream and then continue writing.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this soltion and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown. One is not supposed to finish a GZIPOutputStream and then continue writing.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"># RMI uses a BufferedOutputStream that limits the data on the wire to 8192 bytes at a time.  It is argued [http://forums.sun.com/thread.jspa?threadID=5167582 here] that this makes compression hardly worth while.  But- I did this purely by accident - the compressing output stream below is also buffered and as part of a socket sits closer to the wire than RMI's buffered output stream.  This means that in terms of buffer size my buffered output stream wins - it sets the real buffer size.  And I know from measurements that I am getting almost a 10 to 1 compression ratio.  I have not yet done sufficient experiments to determine what the optimal buffer size would be.  I am currently using 64K buffers.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>So what I needed was a way to tell the compressing stream that I had a unit that could be compressed in its entirety without interfering with future writes.  My solution was to make a compressing output stream based on a  buffered version of a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipOutputStream.html ZipOutputStream].  My idea was to buffer up data to be sent and only send data over the wire  when either the buffer is  full or flush is called explicitly:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>So what I needed was a way to tell the compressing stream that I had a unit that could be compressed in its entirety without interfering with future writes.  My solution was to make a compressing output stream based on a  buffered version of a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipOutputStream.html ZipOutputStream].  My idea was to buffer up data to be sent and only send data over the wire  when either the buffer is  full or flush is called explicitly:</div></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5120&oldid=prevTredmond at 01:16, November 28, 20082008-11-28T01:16:53Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 01:16, November 28, 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a <del class="diffchange diffchange-inline">[</del>[http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server then all the data flushed will appear  on the client.  Instead in this case the client is still waiting for some  the data.  The server does not further help the client here because the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this soltion and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown. One is not supposed to finish a GZIPOutputStream and then continue writing.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this soltion and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown. One is not supposed to finish a GZIPOutputStream and then continue writing.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l58" >Line 58:</td>
<td colspan="2" class="diff-lineno">Line 58:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></code></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></code></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Once the <del class="diffchange diffchange-inline">idea </del> for the output stream is devised, <del class="diffchange diffchange-inline">writing </del>the input stream is pretty easy.  The key idea is to read zip entries and then go to the next zip entry whenever the current zipentry runs  out of data:</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Once the <ins class="diffchange diffchange-inline">strategy </ins> for the output stream is devised, <ins class="diffchange diffchange-inline">developing </ins>the input stream is pretty easy.  The key idea is to read zip entries and then go to the next zip entry whenever the current zipentry runs  out of data:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><code><pre></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><code><pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>     @Override</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>     @Override</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l131" >Line 131:</td>
<td colspan="2" class="diff-lineno">Line 131:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>However my first prototype did not have this check.  What would happen in that case is that the client would occasionally hang because these really small compressed zipentries did not appear  to get flushed over the wire.  This hang took a while to appear - much of the initialization of my client would complete before hanging.  At this point I gave up but decided to add the small data is stored logic in case I ever came back to the problem.  To my surprise this one change made everything work and is now the implementation that I am using.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>However my first prototype did not have this check.  What would happen in that case is that the client would occasionally hang because these really small compressed zipentries did not appear  to get flushed over the wire.  This hang took a while to appear - much of the initialization of my client would complete before hanging.  At this point I gave up but decided to add the small data is stored logic in case I ever came back to the problem.  To my surprise this one change made everything work and is now the implementation that I am using.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>The full implementation can be found [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket here].  In particular the [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket/CompressingInputStream.java CompressingInputStream.java] and [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket/CompressingOutputStream.java CompressingOutputStream.java] are the key to the implementation.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>The full implementation can be found [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket here].  In particular the [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket/CompressingInputStream.java CompressingInputStream.java] and [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket/CompressingOutputStream.java CompressingOutputStream.java] are the key to the implementation<ins class="diffchange diffchange-inline">.  This implementation would certainly need to be adapted for another application but I suspect that this ought to be relatively easy</ins>.</div></td></tr>
</table>Tredmondhttps://protegewiki.stanford.edu/index.php?title=CompressionAndRMI&diff=5119&oldid=prevTredmond at 01:12, November 28, 20082008-11-28T01:12:58Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 01:12, November 28, 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected.  There are several other pages that describe  [http://java.sun.com/javase/6/docs/technotes/guides/rmi/socketfactory/index.html how to create and use an rmisocket factory].  The tricky part is to develop the compressing input and output streams that can be used by  a socket with rmi.  The main difficulties are</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server <del class="diffchange diffchange-inline">that </del>all the data flushed will appear  on the client.  Instead in this case the client is still waiting for <del class="diffchange diffchange-inline">the rest of </del>the data.  The server does not further help the client here <del class="diffchange diffchange-inline">beccuase </del>the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div># the client hangs when trying to communicate with the server. This is what happens  if you simply try to use a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPInputStream]  and a [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/GZIPInputStream.html GZIPOutputStream].  The flush operation on the GZIPOutputStream is not sufficient to have the desired effect on the client.  RMI expects that when  it flushes the output stream on the server <ins class="diffchange diffchange-inline">then </ins>all the data flushed will appear  on the client.  Instead in this case the client is still waiting for <ins class="diffchange diffchange-inline">some  </ins>the data.  The server does not further help the client here <ins class="diffchange diffchange-inline">because </ins>the server is waiting for the next request from the client.  I believe that  the issue is that the GZIPOutputStream is in the middle of a compress operation and is not ready to flush everything down the wire.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this soltion and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi <del class="diffchange diffchange-inline">later </del>writes to this same stream <del class="diffchange diffchange-inline">again </del>after the flush, an exception is thrown <del class="diffchange diffchange-inline">because one </del>is not supposed to finish a GZIPOutputStream and then continue writing.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div># A common solution to the above is to modify the GZIPOutputStream so that on a flush() operation it invokes finish().  There are web pages and books that suggest  this soltion and perhaps it works in many contexts.  This approach is indeed useful for flushing out all the data.  Unfortunately what I found is that when rmi writes to this same stream after the flush, an exception is thrown<ins class="diffchange diffchange-inline">. One </ins>is not supposed to finish a GZIPOutputStream and then continue writing.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>So what I needed was a way to tell the compressing stream that I had a unit that could be compressed in its entirety without interfering with future writes.  My solution was to make a compressing output stream based on a  buffered version of a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipOutputStream.html ZipOutputStream].  My idea was to buffer up data to be sent and only send data over the wire  when either the buffer is  full or flush is called explicitly:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>So what I needed was a way to tell the compressing stream that I had a unit that could be compressed in its entirety without interfering with future writes.  My solution was to make a compressing output stream based on a  buffered version of a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipOutputStream.html ZipOutputStream].  My idea was to buffer up data to be sent and only send data over the wire  when either the buffer is  full or flush is called explicitly:</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l127" >Line 127:</td>
<td colspan="2" class="diff-lineno">Line 127:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>             }</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>             }</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></code></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></code></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>I think that this is a good idea in any case because I suspect that if the data is too small then compression is not really worthwhile.  In fact for some of the very small buffers compression appeared to actually increase the size of the data sent over the wire.  When the code has <del class="diffchange diffchange-inline">this check for </del>small data <del class="diffchange diffchange-inline">buffers </del>the compression code works great and is in use now.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>I think that this is a good idea in any case because I suspect that if the data is too small then compression is not really worthwhile.  In fact for some of the very small buffers compression appeared to actually increase the size of the data sent over the wire.  When the code has small data <ins class="diffchange diffchange-inline">buffer check, </ins>the compression code works great and is in use now.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>However my first prototype did not have this check.  What would happen in that case is that the client would occasionally hang because these really small compressed zipentries did not appear  to get flushed over the wire.  This hang took a while to appear - much of the initialization of my client would complete before hanging.  At this point I gave up but decided to add the small data is stored logic in case I ever came back to the problem.  To my surprise this one change made everything work and is now the implementation that I am using.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>However my first prototype did not have this check.  What would happen in that case is that the client would occasionally hang because these really small compressed zipentries did not appear  to get flushed over the wire.  This hang took a while to appear - much of the initialization of my client would complete before hanging.  At this point I gave up but decided to add the small data is stored logic in case I ever came back to the problem.  To my surprise this one change made everything work and is now the implementation that I am using.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The full implementation can be found [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket here].  In particular the [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket/CompressingInputStream.java CompressingInputStream.java] and [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket/CompressingOutputStream.java CompressingOutputStream.java] are the key to the implementation.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The full implementation can be found [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket here].  In particular the [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket/CompressingInputStream.java CompressingInputStream.java] and [http://smi-protege.stanford.edu/repos/protege/protege-core/trunk/src/edu/stanford/smi/protege/server/socket/CompressingOutputStream.java CompressingOutputStream.java] are the key to the implementation.</div></td></tr>
</table>Tredmond