use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class MasterConfirmationOperation method run.
@Override
public void run() {
final Address endpoint = getCallerAddress();
if (endpoint == null) {
return;
}
final ClusterServiceImpl clusterService = getService();
final ILogger logger = getLogger();
final MemberImpl member = clusterService.getMember(endpoint);
if (member == null) {
logger.warning("MasterConfirmation has been received from " + endpoint + ", but it is not a member of this cluster!");
OperationService operationService = getNodeEngine().getOperationService();
operationService.send(new MemberRemoveOperation(clusterService.getThisAddress()), endpoint);
} else {
if (clusterService.isMaster()) {
clusterService.getClusterHeartbeatManager().acceptMasterConfirmation(member, timestamp);
} else {
logger.warning(endpoint + " has sent MasterConfirmation, but this node is not master!");
}
}
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class TimedMemberStateFactory method createTimedMemberState.
public TimedMemberState createTimedMemberState() {
MemberStateImpl memberState = new MemberStateImpl();
Collection<StatisticsAwareService> services = instance.node.nodeEngine.getServices(StatisticsAwareService.class);
TimedMemberState timedMemberState = new TimedMemberState();
createMemberState(timedMemberState, memberState, services);
timedMemberState.setMaster(instance.node.isMaster());
timedMemberState.setMemberList(new ArrayList<String>());
if (timedMemberState.getMaster()) {
Set<Member> memberSet = instance.getCluster().getMembers();
for (Member member : memberSet) {
MemberImpl memberImpl = (MemberImpl) member;
Address address = memberImpl.getAddress();
timedMemberState.getMemberList().add(address.getHost() + ":" + address.getPort());
}
}
timedMemberState.setMemberState(memberState);
GroupConfig groupConfig = instance.getConfig().getGroupConfig();
timedMemberState.setClusterName(groupConfig.getName());
return timedMemberState;
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class MigrationManager method commitMigrationToDestination.
private boolean commitMigrationToDestination(Address destination, MigrationInfo migration) {
assert migration != null : "No migrations to commit! destination=" + destination;
if (node.getThisAddress().equals(destination)) {
if (logger.isFinestEnabled()) {
logger.finest("Shortcutting migration commit, since destination is master. -> " + migration);
}
return true;
}
MemberImpl member = node.getClusterService().getMember(destination);
if (member == null) {
logger.warning("Destination " + destination + " is not member anymore");
return false;
}
try {
if (logger.isFinestEnabled()) {
logger.finest("Sending commit operation to " + destination + " for " + migration);
}
PartitionRuntimeState partitionState = partitionService.createMigrationCommitPartitionState(migration);
String destinationUuid = member.getUuid();
MigrationCommitOperation operation = new MigrationCommitOperation(partitionState, destinationUuid);
Future<Boolean> future = nodeEngine.getOperationService().createInvocationBuilder(SERVICE_NAME, operation, destination).setTryCount(Integer.MAX_VALUE).setCallTimeout(Long.MAX_VALUE).invoke();
boolean result = future.get();
if (logger.isFinestEnabled()) {
logger.finest("Migration commit result " + result + " from " + destination + " for " + migration);
}
return result;
} catch (Throwable t) {
logMigrationCommitFailure(destination, migration, t);
}
return false;
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class PartitionStateGeneratorImpl method createNodeGroups.
private Queue<NodeGroup> createNodeGroups(Collection<MemberGroup> memberGroups) {
Queue<NodeGroup> nodeGroups = new LinkedList<NodeGroup>();
if (memberGroups == null || memberGroups.isEmpty()) {
return nodeGroups;
}
for (MemberGroup memberGroup : memberGroups) {
NodeGroup nodeGroup;
if (memberGroup.size() == 0) {
continue;
}
if (memberGroup instanceof SingleMemberGroup || memberGroup.size() == 1) {
nodeGroup = new SingleNodeGroup();
MemberImpl next = (MemberImpl) memberGroup.iterator().next();
nodeGroup.addNode(next.getAddress());
} else {
nodeGroup = new DefaultNodeGroup();
Iterator<Member> iter = memberGroup.iterator();
while (iter.hasNext()) {
MemberImpl next = (MemberImpl) iter.next();
nodeGroup.addNode(next.getAddress());
}
}
nodeGroups.add(nodeGroup);
}
return nodeGroups;
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class MemberSelectingCollectionTest method before.
@Before
public void before() throws Exception {
thisMember = new MemberImpl(new Address("localhost", 5701), MemberVersion.of("3.8.0"), true, true);
liteMember = new MemberImpl(new Address("localhost", 5702), MemberVersion.of("3.8.0"), false, true);
dataMember = new MemberImpl(new Address("localhost", 5704), MemberVersion.of("3.8.0"), false, false);
nonExistingMember = new MemberImpl(new Address("localhost", 5705), MemberVersion.of("3.8.0"), false, false);
members = createMembers();
}
Aggregations