Hi JB,


I quit using cellar-cloud because using a blob store (S3 in my case) left a lot 
of clutter to clean up and didn't look very efficient. I would regard that as a 
solution of last resort.



With AWS, tagging machines and scanning them with the describe-instances API is 
more direct (no need to signIn/signOut or clean up the whiteboard when a 
machine is terminated).



As to what I did, I'm not sure it's generic enough a solution at this stage 
because I'm depending on : mvn: org.apache.servicemix.bundles / 
org.apache.servicemix.bundles.aws-java-sdk / 1.8.9.1_1 because I'm using 
ServiceMix, and I don't know what to depend on if I was to write a patch for 
Karaf: jclouds perhpaps? Using plain AWS REST API would be an option (Hazelcast 
folks do that) but involve some more work I can't put in just now.

Also should be noted that, from my experience, you need to disable the 
automatic port-increment setting in hazelcast.xml otherwise it won't work! I 
suspect AWS watch out for port scanning, in any case the cluster fails to form.



I used the Kubernetes as a template, which works exactly the same except for 
the API used. So:

* implement the ManagedServiceFactory (so you can scan for multiple tags/labels)

* create your API request beforehand

* do the following



      public void init() {

            try {

                  if (amazonEC2 == null) {

                        amazonEC2 = new AmazonEC2Client();

                  }

                  amazonEC2.setRegion(region);



                  describeInstancesRequest = createRequest();



                  LOGGER.debug("CELLAR EC2: discovery service initialized");

            } catch (Exception e) {

                  LOGGER.error("CELLAR EC2: can't init discovery service for 
region " + region, e);

            }

      }



      @Override

      public Set<String> discoverMembers() {

            LOGGER.trace("CELLAR EC2: discover members");



            Set<String> members = new HashSet<String>();



            DescribeInstancesResult describeInstancesResult = 
amazonEC2.describeInstances(describeInstancesRequest);



            List<Reservation> reservations = 
describeInstancesResult.getReservations();

            for (Reservation reservation : reservations) {

                  List<Instance> instances = reservation.getInstances();

                  for (Instance instance : instances) {

                        String privateIpAddress = 
instance.getPrivateIpAddress();

                        if (privateIpAddress != null) {

                              LOGGER.debug("Adding EC2 instance: {} [{}]", 
instance.getInstanceId(), privateIpAddress);

                              members.add(privateIpAddress);

                        }

                  }

            }



            return members;

      }





I look forward to your advice, if you have any other questions feel free to ask.



Thanks,

Dario



-----Original Message-----
From: Jean-Baptiste Onofré [mailto:[email protected]]
Sent: 05 December 2015 05:58
To: [email protected]
Subject: Re: interested in a Amazon EC2 discovery service for Cellar?



Hi Dario,



Thanks for sharing !

I'm curious: do you use the cellar-cloud discovery ?



I'm interested about the step you did. Maybe you can write a blog post about 
that (if you don't have a blog, I would be more than happy to post on mine) ?



Thanks again !

Regards

JB



On 12/04/2015 05:56 PM, Dario Cimafonte wrote:

> Hi,

>

> I did a copy-paste-amend exercise and in 2 hours I got a prototype

> cellar-ec2 discovery service working.

>

> Before I go through the effort of Jira, fork, pull request etc. I

> wanted to check whether anyone is interested in that.

>

> Thanks,

>

> Dario

>



--

Jean-Baptiste Onofré

[email protected]<mailto:[email protected]>

http://blog.nanthrax.net

Talend - http://www.talend.com

Reply via email to