Maybe we should add a check to see if FileObject is of type HttpFileObject, since I don&#39;t think that should ever have a different URL than what&#39;s passed in.<div>&nbsp;<span class="Apple-style-span" style="font-family: &#39;times new roman&#39;; font-size: 16px; ">&nbsp;</span><br>
</div><div><br><div class="gmail_quote">On Thu, Feb 19, 2009 at 7:04 PM, Sherman Wood <span dir="ltr">&lt;<a href="mailto:swood@jaspersoft.com">swood@jaspersoft.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">









<div lang="EN-US" link="blue" vlink="purple">

<div>

<p><span style="font-size:11.0pt;color:#1F497D">I was not able to recreate the cache problem with the usual file
system access or my JasperServer repository VFS implementation.</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<p>file.getName().getURI().equals(url) could be false for no
good reason. I played with the test suite and got:</p>

<p>&nbsp;</p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp; [java] Re-resolving file: returned VFS url
was: file:///C:/Users/swood/Documents/pf/sgwood_perforce.eigenbase.org_1666_1/open/mondrian/demo/FoodMart.xml,
not given url: C:/Users/swood/Documents/pf/sgwood_perforce.eigenbase.org_1666_1/open/mondrian/demo/FoodMart.xml</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">Doing this all the time will be overhead, but doesn't
break things. </span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">Sherman</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">

<p><b><span style="font-size:10.0pt">From:</span></b><span style="font-size:10.0pt">
<a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a> [mailto:<a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>] <b>On Behalf
Of </b>Matt Campbell<br>
<b>Sent:</b> Thursday, February 19, 2009 6:33 AM<div><div></div><div class="Wj3C7c"><br>
<b>To:</b> Mondrian developer mailing list<br>
<b>Subject:</b> Re: [Mondrian] RolapSchema #122</div></div></span></p>

</div><div><div></div><div class="Wj3C7c">

<p>&nbsp;</p>

<p style="margin-bottom:12.0pt">I took silence for assent and
have checked in 12382, which clears the VFS cache for the requested file when
this inconsistency is encountered. &nbsp;I also did some minor cleanup to
eliminate some of the duplicate code. &nbsp;Let me know if that change looks
reasonable to you.</p>

<div>

<p>On Wed, Feb 18, 2009 at 10:14 AM, Matt Campbell &lt;<a href="mailto:mkambol@gmail.com" target="_blank">mkambol@gmail.com</a>&gt; wrote:</p>

<p>It does certainly seem to be a vfs bug. &nbsp;As a
workaround, I added the following block right after the .resolveFile().
&nbsp;This validates that the url passed in matches the url of the file
retrieved, and if not clears the file from the cache and reloads.</p>

<div>

<p>&nbsp;</p>

</div>

<div>

<div>

<p>&nbsp;if ( !file.getName().getURI().equals(url)) {</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;fsManager.getFilesCache().removeFile(file.getFileSystem(), &nbsp;file.getName());</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;file =
fsManager.resolveFile(userDir, url);</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>Any objection to me checking in this change? &nbsp;If we
find a better workaround to the vfs bug we can always drop this check.</p>

</div>

<div>

<div>

<div>

<p>&nbsp;</p>

</div>

<p>&nbsp;</p>

<div>

<p>On Tue, Feb 17, 2009 at 6:20 PM, Sherman Wood &lt;<a href="mailto:swood@jaspersoft.com" target="_blank">swood@jaspersoft.com</a>&gt;
wrote:</p>

<div>

<div>

<p><span style="font-size:11.0pt;color:#1F497D">I was just going to refactor </span>RolapSchema.load()
to use Util.readVirtualFile() because of that identical code.</p>

<p>&nbsp;</p>

<p><span style="font-size:11.0pt;color:#1F497D">The default configuration of
Apache VFS we are using should be getting new content each time a URI is
&quot;resolved&quot; (<a href="http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/CacheStrategy.html#ON_RESOLVE" target="_blank">http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/CacheStrategy.html#ON_RESOLVE</a>
), which happens each time .readVirtualFile is called.</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">I&#39;ll do some further tests,
taking into account Will&#39;s comments about possible VFS HTTP bugs.</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">Sherman</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">

<p><b><span style="font-size:10.0pt">From:</span></b><span style="font-size:10.0pt"> <a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>
[mailto:<a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>]
<b>On Behalf Of </b>Matt Campbell<br>
<b>Sent:</b> Wednesday, February 18, 2009 6:14 AM</span></p>

<div>

<p><span style="font-size:10.0pt"><br>
<b>To:</b> Mondrian developer mailing list</span></p>

</div>

<p><b><span style="font-size:10.0pt">Subject:</span></b><span style="font-size:10.0pt"> Re: [Mondrian] RolapSchema #122</span></p>

</div>

<div>

<div>

<p>&nbsp;</p>

<p style="margin-bottom:12.0pt">I just noticed that RolapSchema.load() uses
identical code to Util.readVirtualFile(). &nbsp;It seems likely that it would
have the same problem with cached files.</p>

<div>

<p>On Tue, Feb 17, 2009 at 12:18 PM, Matt Campbell &lt;<a href="mailto:mkambol@gmail.com" target="_blank">mkambol@gmail.com</a>&gt;
wrote:</p>

<p>It looks like the parameters in the URL are ignored on the second call to
readVirtualFile(). &nbsp;The unit test below shows the issue. &nbsp;The URI of
the second file returned by .readVirtualFile ends up being identical to uri1.</p>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>Could you revert your change until this is fixed?</p>

</div>

<div>

<div>

<p>&nbsp;</p>

</div>

<div>

<div>

<p>&nbsp;public void testReadVirtualFile() {</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try {</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String uri1 = &quot;<a href="http://localhost:8088/?URI1" target="_blank">http://localhost:8088/?URI1</a>&quot;;</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String uri2 = &quot;<a href="http://localhost:8088/?URI2" target="_blank">http://localhost:8088/?URI2</a>&quot;;</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FileObject file1 =
Util.readVirtualFile(uri1);</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FileObject file2 = Util.readVirtualFile(uri2);</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;assertEquals(file1.getName().getURI(), uri1);</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;assertEquals(file2.getName().getURI(), uri2);</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch(Exception e) {</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fail(&quot;Threw an
exception while reading virtual file&quot;);</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp;}</p>

</div>

<p>&nbsp;</p>

<div>

<div>

<div>

<p>On Mon, Feb 16, 2009 at 4:36 PM, Sherman Wood &lt;<a href="mailto:swood@jaspersoft.com" target="_blank">swood@jaspersoft.com</a>&gt;
wrote:</p>

</div>

</div>

<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">

<div>

<div>

<div>

<div>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">Yep – that looks weird
and bad. I&#39;ll look into it too.</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">Sherman</span></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></p>

<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">

<p><b><span style="font-size:10.0pt">From:</span></b><span style="font-size:10.0pt"> <a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>
[mailto:<a href="mailto:mondrian-bounces@pentaho.org" target="_blank">mondrian-bounces@pentaho.org</a>]
<b>On Behalf Of </b>Matt Campbell<br>
<b>Sent:</b> Tuesday, February 17, 2009 4:01 AM<br>
<b>To:</b> Mondrian developer mailing list<br>
<b>Subject:</b> [Mondrian] RolapSchema #122</span></p>

</div>

<div>

<div>

<p>&nbsp;</p>

<div>

<p>Sherman,</p>

</div>

<p>It looks like a bug was introduced in the code which retrieves schemas from
the Pool. &nbsp;In Pool.get() there is code which first loads the schema from a
given URL, then computes its checksum. &nbsp;I&#39;ve noticed that the new
Util.readVirtualFile() method will sometimes return the content of the
*previous* schema loaded. &nbsp;</p>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>In the current code there is actually an extra read of the catalog--see the
bolded section below. &nbsp;It&#39;s leftover from the previous approach for
loading the schema. &nbsp;This should probably be cleaned up, but it helped me
find the issue. &nbsp;When I&#39;ve traced through this code I&#39;ve seen that the
catalogStr returned by the old code (Util.readURL) is sometimes different from
the schema returned by Util.readVirtualFile.</p>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>I&#39;m going to try to come up with a clean reproducible test case tomorrow,
but I thought I&#39;d pass on what I&#39;ve seen in case you see something obviously
wrong.</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try {</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;if (catalogStr == null) {</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; <b>&nbsp;catalogStr = Util.readURL(catalogUrl);</b></p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;// Use VFS to get the content</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;FileObject file = Util.readVirtualFile(catalogUrl);</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;StringBuilder buf = new StringBuilder(1000);</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;FileContent fileContent = file.getContent();</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;InputStream in = fileContent.getInputStream();</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;int n;</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;while ((n = in.read()) != -1) {</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;buf.append((char) n);</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;}</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>&nbsp;
&nbsp;catalogStr = buf.toString();</b></p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;md5Bytes = encodeMD5(catalogStr);</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch
(Exception ex) {</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;// Note, can not throw an Exception from this method</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;// but just to show that all is not well in Mudville</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;// we print stack trace (for now - better to change</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//
method signature and throw).</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;ex.printStackTrace();</p>

</div>

<div>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>-Matt</p>

</div>

</div>

</div>

</div>

</div>

</div>

</div>

<p>&nbsp;</p>

</div>

</div>

<p style="margin-bottom:12.0pt">_______________________________________________<br>
Mondrian mailing list<br>
<a href="mailto:Mondrian@pentaho.org" target="_blank">Mondrian@pentaho.org</a><br>
<a href="http://lists.pentaho.org/mailman/listinfo/mondrian" target="_blank">http://lists.pentaho.org/mailman/listinfo/mondrian</a></p>

</blockquote>

</div>

<p>&nbsp;</p>

</div>

</div>

</div>

<p>&nbsp;</p>

</div>

</div>

</div>

</div>

<p style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
Mondrian mailing list<br>
<a href="mailto:Mondrian@pentaho.org" target="_blank">Mondrian@pentaho.org</a><br>
<a href="http://lists.pentaho.org/mailman/listinfo/mondrian" target="_blank">http://lists.pentaho.org/mailman/listinfo/mondrian</a></p>

</div>

<p>&nbsp;</p>

</div>

</div>

</div>

</div>

<p>&nbsp;</p>

</div></div></div>

</div>


<br>_______________________________________________<br>
Mondrian mailing list<br>
<a href="mailto:Mondrian@pentaho.org">Mondrian@pentaho.org</a><br>
<a href="http://lists.pentaho.org/mailman/listinfo/mondrian" target="_blank">http://lists.pentaho.org/mailman/listinfo/mondrian</a><br>
<br></blockquote></div><br></div>