Java – how to create a hazelcast instance embedded in process memory without networking?

In my unit test, I want to create an embedded (in-process / in memory) hazelcast instance that does not attempt to start or perform any network operations

What shall I do?

For example:

Config config = new Config();

// what goes here?

HazelcastInstance inProcessOnly = Hazelcast.newHazelcastInstance(config);

Solution

Fwiw I've been in hazelcast 3.6 1 and programmatically disable network clustering using the following code in the constructor This will create a stand - alone server for testing

It's not as fast as using an emulator, but it's faster than accepting the default configuration

Config config = new Config();
config.setProperty("hazelcast.shutdownhook.enabled","false");
NetworkConfig network = config.getNetworkConfig();
network.getJoin().getTcpIpConfig().setEnabled(false);
network.getJoin().getMulticastConfig().setEnabled(false);
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>