<div dir="ltr">On Thu, Mar 30, 2017 at 4:49 PM, Galder Zamarreño <span dir="ltr">&lt;<a href="mailto:galder@redhat.com" target="_blank">galder@redhat.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
--<br>
Galder Zamarreño<br>
Infinispan, Red Hat<br>
<br>
</span><span class="">&gt; On 30 Mar 2017, at 17:15, Gustavo Fernandes &lt;<a href="mailto:gustavo@infinispan.org">gustavo@infinispan.org</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Mar 30, 2017 at 1:51 PM, Galder Zamarreño &lt;<a href="mailto:galder@redhat.com">galder@redhat.com</a>&gt; wrote:<br>
&gt; Hi all,<br>
&gt;<br>
&gt; For a demo I&#39;m giving next week, I&#39;d like to show how to use distributed streams via a remote server task. All server tasks that we have in testsuite rely on primitives but in my case I wanted to use POJOs.<br>
&gt;<br>
&gt; To do that, I needed to get compatibility mode working in such way that those POJOs could be unmarshalled for the server task. Since in another demo I&#39;m showing Protostream based POJOs, I thought I&#39;d try to use that as mechanism to unmarshall POJOs server side.<br>
&gt;<br>
&gt; We have a test for such scenario [1], but the reality (running on a proper server) is anything that simple. Here&#39;s a list of things I&#39;ve found out while creating a WordCount example that relies on a POJO:<br>
&gt;<br>
&gt; 1. Out of the box, it&#39;s impossible to set compatibility marshaller to org.infinispan.query.remote.<wbr>CompatibilityProtoStreamMarsha<wbr>ller [1] because &quot;org.infinispan.main&quot; classloader can&#39;t access that class. I worked around that by tweaking the module.xml to have an optional dependency to &quot;org.infinispan.remote-query.<wbr>server&quot; module.<br>
&gt;<br>
&gt; 2. After doing that, I had to register the protofile and associated classes remotely in the server. Again, there&#39;s no out of the box mechanism for that, so I created a remote server task that would do that [3].<br>
&gt;<br>
&gt;<br>
&gt; AFAICT, you should be able to do that doing a PUT in the Protobuf_Metadata cache, which entails having auth enabled. This cache should be REPL_SYNC, so no need to run a server task.<br>
<br>
</span>Good point but not so sure it completely removes the need for the task. The task does two things:<br>
<br>
1. Call ProtobufMetadataManager.<wbr>registerProtofile, which as you say could be swapped with a cache.put on the metadata cache.<br>
<br>
2. Call ProtobufMetadataManager.<wbr>registerMarshaller. This goes deep into updating SerializationContextImpl, which seems independent of any replicated cache.<br></blockquote><div><br><br></div><div>AFAICT (again), there is an internal listener or interceptor that upon metadata cache change, will update the SerCtx on all nodes.<br><br></div><div>Gustavo<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
In fact, I had originally set up the task to execute in only in one node, but when I did that I found that marshallers were not registered in all nodes, so I had to execute the task in all nodes.<br>
<br>
I guess the task could be just limited to only executing 2.) in all nodes (and store the protofile contents by accessing the cache remotely), but I can&#39;t see how I can avoid the task altogether right now.<br>
<div class="HOEnZb"><div class="h5"><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; 3. Finally, with all that in place, I was able to complete the WordCount test [4] with a final caveat: the return of the word count, and words protofile registration, tasks return objects that are not marshalled by the compatibility marshaller, so I had to make sure that the remote cache manager used for those tasks uses the default marshaller.<br>
&gt;<br>
&gt; Clearly we need to improve on this, and we have plans to address these issues (with new upcoming transcoding capabilities), but I thought it&#39;d be worth mentioning the problems found in case anyone else encounters them before transcoding is in place.<br>
&gt;<br>
&gt; Cheers,<br>
&gt;<br>
&gt; [1] <a href="https://github.com/galderz/datagrid-patterns/blob/master/server-config/domain/domain.xml#L139" rel="noreferrer" target="_blank">https://github.com/galderz/<wbr>datagrid-patterns/blob/master/<wbr>server-config/domain/domain.<wbr>xml#L139</a><br>
&gt; [2] <a href="https://github.com/galderz/datagrid-patterns/blob/master/server-config/org.infinispan.main_module.xml#L18" rel="noreferrer" target="_blank">https://github.com/galderz/<wbr>datagrid-patterns/blob/master/<wbr>server-config/org.infinispan.<wbr>main_module.xml#L18</a><br>
&gt; [3] <a href="https://github.com/galderz/datagrid-patterns/blob/master/analytics-stream/tasks-server/src/main/java/test/WordsProtoTask.java" rel="noreferrer" target="_blank">https://github.com/galderz/<wbr>datagrid-patterns/blob/master/<wbr>analytics-stream/tasks-server/<wbr>src/main/java/test/<wbr>WordsProtoTask.java</a><br>
&gt; [4] <a href="https://github.com/galderz/datagrid-patterns/blob/master/analytics-stream/tasks-client/src/test/java/test/WordCountTest.java" rel="noreferrer" target="_blank">https://github.com/galderz/<wbr>datagrid-patterns/blob/master/<wbr>analytics-stream/tasks-client/<wbr>src/test/java/test/<wbr>WordCountTest.java</a><br>
&gt; --<br>
&gt; Galder Zamarreño<br>
&gt; Infinispan, Red Hat<br>
&gt;<br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a><br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a><br>
<br>
<br>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a></div></div></blockquote></div><br></div></div>