use of com.hazelcast.instance.NodeContext in project hazelcast by hazelcast.
the class InternalPartitionServiceImplTest method setup.
@Before
public void setup() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
NodeContext nodeContext = new MockNodeContext(factory.getRegistry(), factory.nextAddress()) {
@Override
public NodeExtension createNodeExtension(Node node) {
return new DefaultNodeExtension(node) {
@Override
public boolean isStartCompleted() {
return startupDone.get();
}
};
}
};
instance = HazelcastInstanceFactory.newHazelcastInstance(new Config(), randomName(), nodeContext);
partitionService = (InternalPartitionServiceImpl) getPartitionService(instance);
thisAddress = getNode(instance).getThisAddress();
partitionCount = partitionService.getPartitionCount();
}
use of com.hazelcast.instance.NodeContext in project hazelcast by hazelcast.
the class TestHazelcastInstanceFactory method newHazelcastInstance.
/**
* Creates a new test Hazelcast instance which is only allowed to connect to specified addresses:
* <ul>
* <li>{@code blockedAddresses} are blacklisted in its {@code MockJoiner}</li>
* <li>connections to {@code blockedAddresses} are blocked by its {@code FirewallingConnectionManager}</li>
* </ul>
* This is handy in split-brain tests, when a new instance should be started on a specific network partition
* of the split brain.
*
* @param address the address to use as Member's address; if {@code null}, then uses the next address
* @param config the config to use; use {@code null} to get the default config
* @param blockedAddresses addresses to which the new instance is allowed to communicate
*/
public HazelcastInstance newHazelcastInstance(Address address, Config config, Address[] blockedAddresses) {
final String instanceName = config != null ? config.getInstanceName() : null;
final Address thisAddress = address != null ? address : nextAddress();
if (mockNetwork) {
config = initOrCreateConfig(config);
NodeContext nodeContext = registry.createNodeContext(thisAddress, blockedAddresses == null ? EMPTY_SET : new HashSet<Address>(Arrays.asList(blockedAddresses)));
return HazelcastInstanceFactory.newHazelcastInstance(config, instanceName, nodeContext);
}
throw new UnsupportedOperationException("Explicit address is only available for mock network setup!");
}
use of com.hazelcast.instance.NodeContext in project hazelcast by hazelcast.
the class TestHazelcastInstanceFactory method newHazelcastInstance.
/**
* Creates a new test Hazelcast instance.
*
* @param config the config to use; use {@code null} to get the default config
*/
public HazelcastInstance newHazelcastInstance(Config config) {
String instanceName = config != null ? config.getInstanceName() : null;
if (mockNetwork) {
config = initOrCreateConfig(config);
NodeContext nodeContext = registry.createNodeContext(nextAddress());
return HazelcastInstanceFactory.newHazelcastInstance(config, instanceName, nodeContext);
}
return HazelcastInstanceFactory.newHazelcastInstance(config);
}
use of com.hazelcast.instance.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 (mockNetwork) {
config = initOrCreateConfig(config);
NodeContext nodeContext = registry.createNodeContext(address);
return HazelcastInstanceFactory.newHazelcastInstance(config, instanceName, nodeContext);
}
throw new UnsupportedOperationException("Explicit address is only available for mock network setup!");
}
Aggregations