use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class NodeQueryCacheEndToEndConstructor method createPublishersAndGetQueryResults.
private Collection<QueryResult> createPublishersAndGetQueryResults(AccumulatorInfo info) {
InvokerWrapper invokerWrapper = context.getInvokerWrapper();
Collection<Member> members = context.getMemberList();
List<Future<QueryResult>> futures = new ArrayList<>(members.size());
for (Member member : members) {
Future future = invokerWrapper.invokeOnTarget(new PublisherCreateOperation(info), member);
futures.add(future);
}
return returnWithDeadline(futures, OPERATION_WAIT_TIMEOUT_MINUTES, MINUTES);
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class OperationRunnerImpl method ensureNoPartitionProblems.
private void ensureNoPartitionProblems(Operation op) {
int partitionId = op.getPartitionId();
if (partitionId < 0) {
return;
}
if (partitionId != getPartitionId()) {
throw new IllegalStateException("wrong partition, expected: " + getPartitionId() + " but found:" + partitionId);
}
if (internalPartition == null) {
internalPartition = nodeEngine.getPartitionService().getPartition(partitionId);
}
if (!isAllowedToRetryDuringMigration(op) && internalPartition.isMigrating()) {
throw new PartitionMigratingException(thisAddress, partitionId, op.getClass().getName(), op.getServiceName());
}
PartitionReplica owner = internalPartition.getReplica(op.getReplicaIndex());
if (op.validatesTarget() && (owner == null || !owner.isIdentical(node.getLocalMember()))) {
Member target = owner != null ? node.getClusterService().getMember(owner.address(), owner.uuid()) : null;
throw new WrongTargetException(node.getLocalMember(), target, partitionId, op.getReplicaIndex(), op.getClass().getName(), op.getServiceName());
}
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class CacheSerializationTest method testCachePartitionEventData.
@Test
public void testCachePartitionEventData() throws UnknownHostException {
Address address = new Address("127.0.0.1", 5701);
Member member = new MemberImpl(address, MemberVersion.UNKNOWN, true);
CachePartitionEventData cachePartitionEventData = new CachePartitionEventData("test", 1, member);
CachePartitionEventData deserialized = service.toObject(cachePartitionEventData);
assertEquals(cachePartitionEventData, deserialized);
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class ClientMemberAttributeTest method testConfigAttributes.
@Test(timeout = 120000)
public void testConfigAttributes() throws Exception {
Config c = new Config();
JoinConfig join = c.getNetworkConfig().getJoin();
join.getTcpIpConfig().addMember("127.0.0.1").setEnabled(true);
join.getMulticastConfig().setEnabled(false);
MemberAttributeConfig memberAttributeConfig = c.getMemberAttributeConfig();
memberAttributeConfig.setAttribute("Test", "123");
HazelcastInstance h1 = hazelcastFactory.newHazelcastInstance(c);
Member m1 = h1.getCluster().getLocalMember();
assertEquals("123", m1.getAttribute("Test"));
HazelcastInstance h2 = hazelcastFactory.newHazelcastInstance(c);
Member m2 = h2.getCluster().getLocalMember();
assertEquals("123", m2.getAttribute("Test"));
assertClusterSize(2, h2);
Member member = null;
for (Member m : h2.getCluster().getMembers()) {
if (m.equals(h2.getCluster().getLocalMember())) {
continue;
}
member = m;
}
assertNotNull(member);
assertEquals(m1, member);
assertNotNull(member.getAttribute("Test"));
assertEquals("123", member.getAttribute("Test"));
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
Collection<Member> members = client.getCluster().getMembers();
for (Member m : members) {
assertEquals("123", m.getAttribute("Test"));
}
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class ClientClusterRestartEventTest method testMultiMemberRestart.
@Test
public void testMultiMemberRestart() throws ExecutionException, InterruptedException {
HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance(newConfig());
HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance(newConfig());
HazelcastInstance client = hazelcastFactory.newHazelcastClient(newClientConfig());
Member oldMember1 = instance1.getCluster().getLocalMember();
Member oldMember2 = instance2.getCluster().getLocalMember();
final CountDownLatch memberAdded = new CountDownLatch(2);
final Set<Member> addedMembers = Collections.newSetFromMap(new ConcurrentHashMap<Member, Boolean>());
final CountDownLatch memberRemoved = new CountDownLatch(2);
final Set<Member> removedMembers = Collections.newSetFromMap(new ConcurrentHashMap<Member, Boolean>());
client.getCluster().addMembershipListener(new MembershipListener() {
@Override
public void memberAdded(MembershipEvent membershipEvent) {
addedMembers.add(membershipEvent.getMember());
memberAdded.countDown();
}
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
removedMembers.add(membershipEvent.getMember());
memberRemoved.countDown();
}
});
Cluster cluster = instance1.getCluster();
assertTrueEventually(() -> {
try {
cluster.shutdown();
} catch (Exception e) {
throw new AssertionError(e);
}
});
// Allow same addresses to be used to test hot restart correctly
hazelcastFactory.cleanup();
Future<HazelcastInstance> f1 = spawn(() -> hazelcastFactory.newHazelcastInstance(newConfig()));
Future<HazelcastInstance> f2 = spawn(() -> hazelcastFactory.newHazelcastInstance(newConfig()));
instance1 = f1.get();
instance2 = f2.get();
Member newMember1 = instance1.getCluster().getLocalMember();
Member newMember2 = instance2.getCluster().getLocalMember();
assertOpenEventually(memberRemoved);
assertEquals(2, removedMembers.size());
assertContains(removedMembers, oldMember1);
assertContains(removedMembers, oldMember2);
assertOpenEventually(memberAdded);
assertEquals(2, addedMembers.size());
assertContains(addedMembers, newMember1);
assertContains(addedMembers, newMember2);
Set<Member> members = client.getCluster().getMembers();
assertContains(members, newMember1);
assertContains(members, newMember2);
assertEquals(2, members.size());
}
Aggregations