Search in sources :

Example 6 with NodeContext

use of com.hazelcast.instance.impl.NodeContext in project hazelcast by hazelcast.

the class TestHazelcastInstanceFactory method newHazelcastInstance.

/**
 * Creates a new test Hazelcast instance.
 *
 * @param address the address to use as Member's address instead of picking the next address
 * @param config  the config to use; use {@code null} to get the default config
 */
public HazelcastInstance newHazelcastInstance(Address address, Config config) {
    final String instanceName = config != null ? config.getInstanceName() : null;
    if (isMockNetwork) {
        config = initOrCreateConfig(config);
        NodeContext nodeContext = registry.createNodeContext(address);
        HazelcastInstance hazelcastInstance = HazelcastInstanceFactory.newHazelcastInstance(config, instanceName, nodeContext);
        registerTestMetricsPublisher(hazelcastInstance);
        return hazelcastInstance;
    }
    throw new UnsupportedOperationException("Explicit address is only available for mock network setup!");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) DefaultNodeContext(com.hazelcast.instance.impl.DefaultNodeContext) NodeContext(com.hazelcast.instance.impl.NodeContext)

Aggregations

NodeContext (com.hazelcast.instance.impl.NodeContext)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 DefaultNodeContext (com.hazelcast.instance.impl.DefaultNodeContext)4 Config (com.hazelcast.config.Config)2 Address (com.hazelcast.cluster.Address)1 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)1 ServiceConfig (com.hazelcast.config.ServiceConfig)1 StaticMemberNodeContext (com.hazelcast.instance.StaticMemberNodeContext)1 DefaultNodeExtension (com.hazelcast.instance.impl.DefaultNodeExtension)1 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)1 Node (com.hazelcast.instance.impl.Node)1 Accessors.getAddress (com.hazelcast.test.Accessors.getAddress)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 TestHazelcastInstanceFactory.initOrCreateConfig (com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 MockNodeContext (com.hazelcast.test.mocknetwork.MockNodeContext)1 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 Test (org.junit.Test)1