Re: [jgroups-users] Eclipselink cache coordination with JGroups in Docker in AWS

Questions/problems related to using JGroups <[email protected]> Sat, 7 Jan 2017 14:24:44 +0100
Newsgroups gmane.comp.java.javagroups.general
Message-ID <[email protected]>

On 06/01/17 18:06, Questions/problems related to using JGroups wrote:
> Hi, I'm a JGroups newbie so I'm not sure if what I'm trying to do is
> possible or not. What I want to do is to set up eclipselink cache
> coordination using jgroups. Thing is that my application runs in a
> Docker container in amazon Elastic Beanstalk with autoscaling set up.


What addresses are shown when you attach to the container and do an 
ifconfig? And which address does JGroups bind to?

You can use bind_addr in the TCP transport to pick the right address; 
this obviously needs to be an address that's reachable by all cluster 
members. You could use a symbolic or regexp with bind_addr, as shown in 
[1], e.g.

<TCP
    bind_addr="match-interface:eth2,192.168.1.*"
     ...
/>

This will try to bind to any of the addresses associated with eth2 
first, and when not successful, fall back to any address starting with 
192.168.1. You could also list multiple addresses here.


> So far I've found out that IP-mulicasting isn't supported by elastic
> beanstalk so what I'm thinking is if it would be possible to use jgroups
> in TCP mode?

Yes, absolutely; most clouds don't allow IP multicasting so TCP (or 
TCP_NIO2) is usually used in cloud environments by JGroups.

> One thing I'm not sure how I would solve is that I don't
> know how to get the IP-adresses for my instances since elastic beanstalk
> scales up and down automatically based on load.

Use a match-xxx regexp for bind_addr. Note that if you control startup 
of the JGroups cluster, you could also inject the address into JGroups, 
as follows:

JChannel ch=new JChannel(...);
InetAddress bind_address=....; // find out, e.g. via curl in AWS
ch.getProtcolStack.getTransport.setBindAddress(bind_address);
ch.connect(cluster_name); // bind_addr needs to be set before connect()

> Ideally I would like the newly launched instances to automatically join
> the cluster once they've been spawned.
  The above instructions should make this work. Note that there are 
discovery protocols specially designed for AWS, e.g. S3_PING, AWS_PING, 
S3_NATIVE_PING, or for Google Cloud, e.g. KUBE_PING or GOOGLE_PING. 
Check the manual for details.

[1] http://www.jgroups.org/manual4/index.html#Transport


-- 
Bela Ban, JGroups lead (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