use of com.hazelcast.internal.server.FirewallingServer in project hazelcast by hazelcast.
the class SplitBrainTestSupport method createHazelcastInstanceInBrain.
/**
* Starts a new {@code HazelcastInstance} which is only able to communicate with members on one of the two brains.
*
* @param brain index of brain to start a new instance in (0 to start instance in first brain or 1 to start instance in
* second brain)
* @return a HazelcastInstance whose {@code MockJoiner} has blacklisted the other brain's members and its connection
* manager blocks connections to other brain's members
* @see TestHazelcastInstanceFactory#newHazelcastInstance(Address, Config, Address[])
*/
protected HazelcastInstance createHazelcastInstanceInBrain(int brain) {
Address newMemberAddress = factory.nextAddress();
Brains brains = getBrains();
HazelcastInstance[] instancesToBlock = brain == 1 ? brains.firstHalf : brains.secondHalf;
List<Address> addressesToBlock = new ArrayList<>(instancesToBlock.length);
for (HazelcastInstance hz : instancesToBlock) {
if (isInstanceActive(hz)) {
addressesToBlock.add(Accessors.getAddress(hz));
// block communication from these instances to the new address
FirewallingServer networkingService = getFireWalledNetworkingService(hz);
FirewallingServer.FirewallingServerConnectionManager endpointManager = (FirewallingServer.FirewallingServerConnectionManager) networkingService.getConnectionManager(MEMBER);
endpointManager.blockNewConnection(newMemberAddress);
endpointManager.closeActiveConnection(newMemberAddress);
}
}
// indicate that we need to unblacklist addresses from the joiner when split-brain will be healed
unblacklistHint = true;
// create a new Hazelcast instance which has blocked addresses blacklisted in its joiner
return factory.newHazelcastInstance(newMemberAddress, config(), addressesToBlock.toArray(new Address[0]));
}
use of com.hazelcast.internal.server.FirewallingServer in project hazelcast by hazelcast.
the class MockNodeContext method createServer.
@Override
public Server createServer(Node node, ServerSocketRegistry serverSocketRegistry, LocalAddressRegistry addressRegistry) {
TcpServerContext serverContext = new TcpServerContext(node, node.nodeEngine);
MockServer mockNetworkingService = new MockServer(serverContext, node, registry);
return new FirewallingServer(mockNetworkingService, initiallyBlockedAddresses);
}
use of com.hazelcast.internal.server.FirewallingServer in project hazelcast by hazelcast.
the class FirewallingConnectionManagerConstructorTest method testConstructor.
@Test
public void testConstructor() throws Exception {
Server delegate = mock(Server.class);
Address address = new Address("172.16.16.1", 4223);
Set<Address> blockedAddresses = Collections.singleton(address);
FirewallingServer ns = new FirewallingServer(delegate, blockedAddresses);
FirewallingNetworkingInstanceConstructor constructor = new FirewallingNetworkingInstanceConstructor(FirewallingServer.class);
FirewallingServer clonedConnectionManager = (FirewallingServer) constructor.createNew(ns);
assertEquals(delegate, getFieldValueReflectively(clonedConnectionManager, "delegate"));
assertEquals(blockedAddresses, getFieldValueReflectively(clonedConnectionManager, "blockedAddresses"));
}
Aggregations