Hazelcast.getAllHazelcastInstances() not work as expected.

44 views
Skip to first unread message

Cidy Long

unread,
May 17, 2021, 8:43:44 PM5/17/21
to Payara Forum
I'm trying to fetch all Hazelcast Instances by programmatically, but, unfortunately, I got wrong instances.

I had put the case into stackoverflow.com, linkage as:


If any one has idea, please advise.

Cidy


Rudy De Busscher

unread,
May 22, 2021, 11:00:57 AM5/22/21
to Payara Forum
Hi Cidy,

Can you try to inject the HazelcastInstance in any CDI bean and use the following code snippet:

@Inject
private HazelcastInstance hzInstance;

hzInstance.getCluster().getMembers();

Rudy

Cidy Long

unread,
May 25, 2021, 6:30:13 PM5/25/21
to Payara Forum
Hi. Rudy

I will try your way, hope it works

Cidy

Cidy Long

unread,
Jun 3, 2021, 8:15:15 PM6/3/21
to Payara Forum
Hi, Rudy

I tried your solution today, and I found the Member of [hzInstance.getCluster().getMembers()] is not a Hazelcast Instance but a [com.hazelcast.cluster.impl.MemberImpl], it can't be cast to [HazelcastInstance] as well.

I need to access configured Hazelcast Instance instead of a [com.hazelcast.cluster.impl.MemberImpl].

Please advise!

Appreciation

Cidy
On Sunday, May 23, 2021 at 1:00:57 AM UTC+10 Rudy De Busscher wrote:

Rudy De Busscher

unread,
Jun 4, 2021, 2:47:47 AM6/4/21
to Payara Forum
Hi Cidy,

There is only 1 Hazelcast instance per JVM, but multiple members in the cluster.

From what I read in the documentation, Hazelcast can give you only a reference to the instance of the JVM itself (and give you the members in the clusters but not a reference to those instances as they are in another JVM)

So what is your requirement to access the other instances (in the other JVMs)?

Rudy

Ondro Mihályi

unread,
Jun 4, 2021, 2:56:05 AM6/4/21
to Cidy Long, Payara Forum
Hi,

According to your question on SO you're looking for other Payara instances in the datagrid. Then you really need to look for a Hazelcast Member and HazelcastInstance. There's a difference in the terminology between Payara and Hazelcast. What's an instance in Payara Server is called Member in Hazelcast. HazelcastInstance is actually just an entry point into a single Hazelcast cluster. You can have multiple Hazelcast clusters to which your application is connected and all of them would be represented by a different HazelcastInstance. So, the Hazelcast class is just a singleton (actually it only contains static methods), HazelcastInstance is a Hazelcast engine object that is connected to the Hazelcast cluster.

Payara Server will provide you an instance of HazelcastInstance if you want to access the same Hazelcast cluster used by Payara Server. If you call Hazelcast.getAllHazelcastInstances() on Payara Server, you will get this single HazelcastInstance, the same one that can be injected as in Rudy's example or retrieved by JNDI, unless you create more instances with newHazelcastInstance.

So what you're really looking for is a list of Members as in Rudy's example. If you want to get its name as it appears in Payara Admin Console or Asadmin CLI, you need to dig into Payara Source code here to find out how - the name is only known to Payara Server and not to Hazelcast. It's stored in a Hazelcast map under the UUID of the member.

Ondro

pi 4. 6. 2021 o 2:15 Cidy Long <cidy...@gmail.com> napísal(a):
--
You received this message because you are subscribed to the Google Groups "Payara Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to payara-forum...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/payara-forum/0db1a46b-a4c1-4dcf-aef5-5644a7f6b373n%40googlegroups.com.

Cidy Long

unread,
Jun 4, 2021, 6:21:18 PM6/4/21
to Payara Forum
Hi. Ondro

Thank you for your kindly explain. As I got solid WebLogic experience but with very limited understanding with Payara, so your and Rudy's explanation is valuable for my next explore. 

Have a good weekend.

Cidy

Cidy Long

unread,
Jun 4, 2021, 6:41:54 PM6/4/21
to Payara Forum
Hi. Rudy

Actually, I'm trying to access Payara Server Instances (That added by using admin-UI) by name from my EJB services. 

I'm still very confuse with Payara Objects (domain, nodes, cluster, Instances, resources, Applications) relationship hierarchy (tree, grid or mixture?), and How Hazelcast was embedded into Payara application platform? How Payara interact with Hazelcast Instance? etc. 

Personally, I have very strong Application Architecture background. If I don't see a big picture of application platform such as Payara, I can't find a good entry point to start off.

Have a good weekend!

Cidy from Australia

Rudy De Busscher

unread,
Jun 11, 2021, 3:37:25 AM6/11/21
to Payara Forum
Hi Cidy,

The domain data Grid (Hazelcast) has 2 purposes (closely related)
- JCache implementation
- Provide clustering capabilities

I have the feeling you are trying to use it as a service discovery mechanism (which it is not designed for)

Some terminology
Node: The 'physical' environment where 'Payara code' can run like a VM accessible through SSH.
Instance: A Payara 'server' instance running your application and handling user requests.
DAS (Domain server): The instance managing the entire environment (configuration, instances, ...). It can also be used to run your application.
Deployment Group (our cluster implementation): A group of instances that run your application and can distribute the HTTP session information between them. But it is more flexible than a traditional cluster since one instance can be part of multiple Deployment Groups.

Hopes this helps
Rudy

Reply all
Reply to author
Forward
0 new messages