You are viewing the documentation for a prerelease version.

View the latest stable version

Creating Clusters

You can create clusters using the cluster-name configuration element.

You can separate and group your clusters in a simple way by specifying cluster names. Example groupings can be by development, production, test, app, etc. The following is an example declarative configuration.

  • XML

  • YAML

<hazelcast>
    <cluster-name>production</cluster-name>
</hazelcast>
hazelcast:
  cluster-name: production

You can also define the cluster configuration programmatically. A JVM can host multiple Hazelcast instances. Each Hazelcast instance can only participate in one group. Each Hazelcast instance only joins to its own group and does not interact with other groups. The following code example creates three separate Hazelcast instances--h1 belongs to the production cluster, while h2 and h3 belong to the development cluster.

        Config configProd = new Config();
        configProd.setClusterName( "production" );

        Config configDev = new Config();
        configDev.setClusterName( "development" );

        HazelcastInstance h1 = Hazelcast.newHazelcastInstance( configProd );
        HazelcastInstance h2 = Hazelcast.newHazelcastInstance( configDev );
        HazelcastInstance h3 = Hazelcast.newHazelcastInstance( configDev );