use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class FrozenPartitionTableTest method partitionTable_shouldBeFixed_whenMemberRestarts_usingUuidOfAnotherMissingMember.
@Test
public void partitionTable_shouldBeFixed_whenMemberRestarts_usingUuidOfAnotherMissingMember() {
ruleStaleJoinPreventionDuration.setOrClearProperty("5");
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz1 = factory.newHazelcastInstance();
HazelcastInstance hz2 = factory.newHazelcastInstance();
HazelcastInstance hz3 = factory.newHazelcastInstance();
HazelcastInstance hz4 = factory.newHazelcastInstance();
assertClusterSizeEventually(4, hz2, hz3);
warmUpPartitions(hz1, hz2, hz3, hz4);
changeClusterStateEventually(hz4, ClusterState.FROZEN);
int member3PartitionId = getPartitionId(hz3);
int member4PartitionId = getPartitionId(hz4);
MemberImpl member3 = getNode(hz3).getLocalMember();
MemberImpl member4 = getNode(hz4).getLocalMember();
hz3.shutdown();
hz4.shutdown();
assertClusterSizeEventually(2, hz1, hz2);
newHazelcastInstance(initOrCreateConfig(new Config()), randomName(), new StaticMemberNodeContext(factory, member4.getUuid(), member3.getAddress()));
assertClusterSizeEventually(3, hz1, hz2);
waitAllForSafeState(hz1, hz2);
OperationServiceImpl operationService = getOperationService(hz1);
operationService.invokeOnPartition(null, new NonRetryablePartitionOperation(), member3PartitionId).join();
try {
operationService.invokeOnPartition(null, new NonRetryablePartitionOperation(), member4PartitionId).joinInternal();
fail("Invocation to missing member should have failed!");
} catch (TargetNotMemberException ignored) {
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class SerializationIssueTest method testMemberLeftException.
private void testMemberLeftException(UUID uuid, String host, int port, Member member) throws Exception {
MemberLeftException exception = new MemberLeftException(member);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bout);
out.writeObject(exception);
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
ObjectInputStream in = new ObjectInputStream(bin);
MemberLeftException exception2 = (MemberLeftException) in.readObject();
MemberImpl member2 = (MemberImpl) exception2.getMember();
assertEquals(uuid, member2.getUuid());
assertEquals(host, member2.getAddress().getHost());
assertEquals(port, member2.getAddress().getPort());
assertEquals(member.isLiteMember(), member2.isLiteMember());
assertEquals(member.getVersion(), member2.getVersion());
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class TcpClientConnectionManagerTranslateTest method testTranslateFromMemberIsNotUsedWhenAlreadyTranslatedByAddressProvider.
@Test(expected = Exception.class)
public void testTranslateFromMemberIsNotUsedWhenAlreadyTranslatedByAddressProvider() throws UnknownHostException {
// given
ClientConfig clientConfig = new ClientConfig();
clientConfig.setProperty(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED.getName(), "true");
TestAddressProvider provider = new TestAddressProvider(false);
HazelcastInstance client = HazelcastClientUtil.newHazelcastClient(provider, clientConfig);
TcpClientConnectionManager clientConnectionManager = new TcpClientConnectionManager(getHazelcastClientInstanceImpl(client));
clientConnectionManager.start();
provider.shouldTranslate = true;
privateAddress = new Address("192.168.0.1", 5702);
// private member address is correct
Member member = new MemberImpl(privateAddress, VERSION, false, UUID.randomUUID());
// public member address is correct
member.getAddressMap().put(EndpointQualifier.resolve(ProtocolType.CLIENT, "public"), new Address("127.0.0.1", 5701));
// when
clientConnectionManager.getOrConnectToMember(member, false);
// then
// throws exception because it can't connect to the incorrect address
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class FlakeIdGenerator_NodeIdOverflowIntegrationTest method assignOverflowedNodeId.
private static void assignOverflowedNodeId(HazelcastInstance instance2) {
MemberImpl member = (MemberImpl) instance2.getCluster().getLocalMember();
member.setMemberListJoinVersion(100000);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class AddPartitionLostListenerMessageTask method processInternal.
@Override
protected CompletableFuture<UUID> processInternal() {
final IPartitionService partitionService = getService(getServiceName());
final PartitionLostListener listener = event -> {
if (endpoint.isAlive()) {
ClusterService clusterService = getService(ClusterServiceImpl.SERVICE_NAME);
Address eventSource = event.getEventSource();
MemberImpl member = clusterService.getMember(eventSource);
ClientMessage eventMessage = ClientAddPartitionLostListenerCodec.encodePartitionLostEvent(event.getPartitionId(), event.getLostBackupCount(), member.getUuid());
sendClientMessage(null, eventMessage);
}
};
if (parameters) {
return newCompletedFuture(partitionService.addLocalPartitionLostListener(listener));
}
return partitionService.addPartitionLostListenerAsync(listener);
}
Aggregations