<div dir="ltr"><div><div>Hi Radim<br><br></div>Actually, it&#39;s me that wrote the denormalization code :)<br><br></div>It was meant as a stop-gap measure before we upgraded the HotRod protocol to support the segment-based consistent hash, but the denormalization worked well enough (or so we thought) that we didn&#39;t get to changing the protocol yet. <br>

<br>That&#39;s not a big change in itself, but we also wanted to make the consistent hash per-cache on the client (it&#39;s now per-cache manager), and that&#39;s a bit more complicated to do. And it&#39;s not like it would have been a good idea to change this before starting the C++ client, the client would still have to support the current style of consistent hash.<br>

<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 10, 2013 at 8:17 PM, Radim Vansa <span dir="ltr">&lt;<a href="mailto:rvansa@redhat.com" target="_blank">rvansa@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

Hi Galder,<br>
<br>
as I am trying to debug some problem in C++ client, I was looking into<br>
the server code. And I am not sure whether I understand the code<br>
correctly, but it seems to me that the server denormalizes the<br>
consistent hash for each client anew (after each topology change or<br>
client joining). Is this true? Looking into trace logs, I can see stuff<br>
like<br>
<br>
18:15:17,339 TRACE [org.infinispan.server.hotrod.Encoders$Encoder12$]<br>
(HotRodServerWorker-12) Writing hash id 639767 for <a href="http://192.168.11.101:11222" target="_blank">192.168.11.101:11222</a><br>
<br>
 From denormalizeSegmentHashIds() method I see that this means that we<br>
have executed the hash function 639768 times just to notify one client.<br>
Is my understanding correct?<br></blockquote><div><br></div><div>Yes, this happens every time a client joins and/or every time the cache topology changes. <br><br>We could easily cache the result of denormalizeSegmentHashIds, as it only depends on the number of segments. It&#39;s just that I wasn&#39;t expecting it to take so many iterations.<br>

<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Also, there is nothing like the concept of primary owner, is this right?<br></blockquote><div><br></div><div>The client CH doesn&#39;t have a concept of backup owners. But for each (hash id, server) pair that gets sent to the client, it means all the hash codes between the previous hash id and this hash id have this server as the primary owner. The server in the next (hash id, server) pair is the first backup, and so on.<br>

</div><div><br></div><div>For each segment, the server generates numOwners (hash id, server) pairs. That means, for most of the hash codes in the segment, the list of owners on the client will be the same as the list of owners on the server. But for 0.0002 (leewayFraction) of the hash codes, the client primary owner will be indeed one of the server backup owners.<br>

<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I thought that every first request in HotRod will go to primary owner,<br>
so that the PUT does not have to do the first hop and is executed<br>
directly on the primary. But it seems to me that it goes to any of the<br>
owners (practically random one, as you are only looking for the numOwner<br>
ids in leeway = on the beginning of the range - then, 99.98% or more<br>
requests should go to the server with last position in the leeway). This<br>
looks pretty suboptimal for writes, isn&#39;t it?<br></blockquote><div><br></div><div></div><div>I&#39;m not sure what you mean here, but I&#39;m pretty sure the request goes to the correct server because we have a test for it: ConsistentHashV1IntegrationTest<br>

<br></div><div>Cheers<br></div><div>Dan<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Cheers<br>
<br>
Radim<br>
<br>
PS: for every line of code you write in Scala, God kills a kitten<br>
<span class=""><font color="#888888"><br>
--<br>
Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt;<br>
JBoss DataGrid QA<br>
<br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</font></span></blockquote></div><br></div></div>