Cluster object has a getMember(memberId) method, so iterating through the
members is not needed.

Furthermore, is it possible for the Service to maintain a list of active
members by modifying the MemberActivatedMessageProcessor and
MemberSuspendedMessageProcessor?


Regards,
Chamila de Alwis
Software Engineer | WSO2 | +94772207163
Blog: code.chamiladealwis.com



On Wed, Sep 24, 2014 at 3:59 PM, Akila Ravihansa Perera <[email protected]>
wrote:

> Any thoughts, please.
>
> On Tue, Sep 23, 2014 at 11:37 PM, Akila Ravihansa Perera
> <[email protected]> wrote:
> > Hi,
> >
> > If we need to retrieve a Member object from the topology for a given
> > member id, we need to perform a 3 level iteration to look it up. This
> > is a limitation of current topology data structure. Following is a
> > sample code I had to use for this.
> >
> >       for (Service service : topology.getServices()) {
> >             if (service.getClusters() != null) {
> >                 for (Cluster cluster : service.getClusters()) {
> >                     if (cluster.getMembers() != null) {
> >                         for (Member member : cluster.getMembers()) {
> >                             // we are checking faulty status only in
> > previously activated members
> >                             if (member != null &&
> > MemberStatus.Activated.equals(member.getStatus())) {
> >                                 // get the member
> >                             }
> >                         }
> >                     }
> >                 }
> >             }
> >         }
> >
> > Is there a better way to do this? If not, shall we add more efficient
> > APIs to retrieve these kind of information?
> >
> > Thanks.
> >
> > --
> > Akila Ravihansa Perera
> > Software Engineer, WSO2
> >
> > Blog: http://ravihansa3000.blogspot.com
>
>
>
> --
> Akila Ravihansa Perera
> Software Engineer, WSO2
>
> Blog: http://ravihansa3000.blogspot.com
>

Reply via email to