Re: [jgroups-users] v3->v4 move, problem with castMessage
Questions/problems related to using JGroups <[email protected]> Thu, 2 Nov 2017 17:48:15 +0100
| Newsgroups | gmane.comp.java.javagroups.general |
|---|---|
| Message-ID | <mailman.23229.1509641315.14213.javagroups-users@lists.sourceforge.net> |
On 02/11/17 17:44, Questions/problems related to using JGroups wrote:
>
> Am having various problems with our v3->v4 change. Trying to
> focus on them one at a time, I wanted to ask about the
> castMessage change. We were doing this before to send a message
> out to every node, collect responses, etc:
>
> RspList<MyOb> rspList = md.castMessage(null,
> new Message(null, myString), ro);
>
> ...where myString is actually a constant starting with "n" and
> MyOb is a Serializable object with some primitive data in it and
> one Address object (*).
>
>
> I don't see a myObj instance getting passed to the call?
>
>
> Where would that go? I don't see it in the v3 or v4 APIs. With jgroups
> v3, we've been using that for years now and it always returns what I'd
> expect. When I iterate over "for (Rsp<MyOb> rsp : rspList.values())"
> rsp.getValue() always returns a MyOb.
>
> I changed the castMessage contents to use Util.objectToByteBuffer
> instead of string (our handle() method could get a couple different
> things instead of strings), used the proper byte array length, and that
> all works fine. Thanks for the information. So far each rsp.value is a
> MyOb, so it's working.
>
> Which leads me to the last question (for this thread anyway):
>
>
> (*) Related: am getting a lot of FindBugs warnings now because
> we have a couple Serializable objects we pass around that
> include Address objects, and that isn't marked Externalizable
> any more. Any advice there would also be appreciated.
>
>
> I removed Serializable / Externalizable from Address, so they cannot
> be serialized with Java serialization (which is a bad idea anyway!).
> Use Util.writeAddress()/readAddress() instead
>
>
> Am not following yet. In the MyOj case above, the object used to be
> something like (simplified):
>
> public class MyOb implements Serializable {
> private static final long serialVersionUID = // stuff
> private final String this;
> private final String that;
> private final boolean a;
> private final boolean b;
> private final Address addr;
>
> // code
> }
>
> Now I've marked 'addr' transient and set it when I iterate over the
> RspList. That's working ok I think. But we have other cases, like the
> object used to store shared cluster state, that's more like this:
>
> public class MyOb2 implements Serializable {
> private static final long serialVersionUID = // stuff
> private String[] something;
> private Address[] addresses1;
> private Address[] addresses2;
>
> // code
> }
>
> In v3.X that could all be sent over the wire because everything was
> Serializable. Is there a suggested way to handle this in v4.X to reuse
> jgroups util code as much as possible?
Yes, make it implement Streamable instead of Serializable
> Thanks,
> Bobby
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> javagroups-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/javagroups-users
>
--
Bela Ban | http://www.jgroups.org
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
javagroups-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javagroups-users