Re: [jgroups-users] problem with custom address

Questions/problems related to using JGroups <[email protected]> Fri, 1 Jun 2018 11:47:55 -0400
Newsgroups gmane.comp.java.javagroups.general
Message-ID <mailman.23872.1527869862.27734.javagroups-users@lists.sourceforge.net>
On Fri, Jun 1, 2018 at 9:54 AM, Questions/problems related to using JGroups
<[email protected]> wrote:

> The problem is that you cannot override equals(), take a look at my sample
> program below:
>

Ok, I've pulled that. Thanks. Still not working, but I have more info. When
I start each node, viewAccepted is called at startup, but never is again. I
added a loop that outputs jc.getView().getMembers() every few seconds. On
each node, I see that the members are *replaced* with whoever joined last.
The viewAccepted method is never called, and each node ends up with a view
containing 1 address, the address of the last node to start.

On first node, with others started several seconds apart (duplicate
addresses removed):

6/1/18 11:44:18 AM com.enterprisedb.efm.nodes.EfmNode lambda$doStartup$0
WARNING: [hostone-40171(Fri Jun 01 11:43:50 EDT 2018)]
6/1/18 11:44:33 AM com.enterprisedb.efm.nodes.EfmNode lambda$doStartup$0
WARNING: [localhost-9003(Fri Jun 01 11:43:50 EDT 2018)]
6/1/18 11:44:53 AM com.enterprisedb.efm.nodes.EfmNode lambda$doStartup$0
WARNING: [localhost-64497(Fri Jun 01 11:43:50 EDT 2018)]
6/1/18 11:45:08 AM com.enterprisedb.efm.nodes.EfmNode lambda$doStartup$0
WARNING: [localhost-48894(Fri Jun 01 11:43:50 EDT 2018)]

One difference from my code to yours in that we use a message dispatcher.
When we moved from 3.x to 4.x we had to change to dispatcher to handle
everything (I can find that thread if needed). So am doing this, where
'this' in code extends ReceiverAdapter and implements RequestHandler:

        jChannel = env.createJChannel(this);
        jChannel.addAddressGenerator(TestAddress::new);
        dispatcher = new MessageDispatcher(jChannel, this);
        dispatcher.setMembershipListener(this);
        dispatcher.setStateListener(this);
        jChannel.connect(env.getClusterName(), null, 10 * 1000);
        final JChannel jc = jChannel;
        Thread t = new Thread(() -> {
            while (true) {
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {}
                LOGGER.log(Level.WARNING,
jc.getView().getMembers().toString());
            }
        });
        t.setDaemon(true);
        t.start();

If I comment out " jChannel.addAddressGenerator(TestAddress::new);"
everything is fine, but otherwise I'm seeing the issue of viewAccepted()
not called and the view being improperly replaced. Any thoughts on that?

Also, the extra text in toString is always specific to the node outputting
it, not to the node that the Address represents. Current code:

public class TestAddress extends UUID {
    static {
        ClassConfigurator.add((short) 5309, TestAddress.class);
    }
    String ipOrHost = new Date().toString(); // simple way to test info
getting from node to node
    @Override
    public String toString() {
        return super.toString() + "(" + ipOrHost + ")";
    }
    @Override
    public Supplier<? extends TestAddress> create() {
        return TestAddress::new;
    }
    @Override
    public void writeTo(DataOutput out) throws Exception {
        super.writeTo(out);
        out.writeUTF(ipOrHost);
    }
    @Override
    public void readFrom(DataInput in) throws Exception {
        super.readFrom(in);
        ipOrHost = in.readUTF();
    }
}

Tried without the writeTo/readFrom and have same issue with the view.

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