use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterHeartbeatManager method onInvalidHeartbeat.
private void onInvalidHeartbeat(MembersViewMetadata senderMembersViewMetadata) {
Address senderAddress = senderMembersViewMetadata.getMemberAddress();
if (clusterService.isMaster()) {
if (!clusterService.getClusterJoinManager().isMastershipClaimInProgress()) {
logger.fine("Sending explicit suspicion to " + senderAddress + " for heartbeat " + senderMembersViewMetadata + ", because it is not a member of this cluster" + " or its heartbeat cannot be validated!");
clusterService.sendExplicitSuspicion(senderMembersViewMetadata);
}
} else {
MemberImpl master = clusterService.getMember(clusterService.getMasterAddress());
if (clusterService.getMembershipManager().isMemberSuspected(master)) {
logger.fine("Not sending heartbeat complaint for " + senderMembersViewMetadata + " to suspected master: " + master.getAddress());
return;
}
logger.fine("Sending heartbeat complaint to master " + master.getAddress() + " for heartbeat " + senderMembersViewMetadata + ", because it is not a member of this cluster" + " or its heartbeat cannot be validated!");
sendHeartbeatComplaintToMaster(senderMembersViewMetadata);
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterHeartbeatManager method resetHeartbeats.
/**
* Reset all heartbeats to the current cluster time. Called when system clock jump is detected.
*/
private void resetHeartbeats() {
SplitBrainProtectionServiceImpl splitBrainProtectionService = nodeEngine.getSplitBrainProtectionService();
long now = clusterClock.getClusterTime();
for (MemberImpl member : clusterService.getMemberImpls()) {
heartbeatFailureDetector.heartbeat(member, now);
splitBrainProtectionService.onHeartbeat(member, now);
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterStateManager method changeClusterState.
void changeClusterState(@Nonnull ClusterStateChange stateChange, @Nonnull MemberMap memberMap, @Nonnull TransactionOptions options, long partitionStateStamp, boolean isTransient) {
checkParameters(stateChange, options);
if (isCurrentStateEqualToRequestedOne(stateChange)) {
return;
}
ClusterState oldState = getState();
ClusterState requestedState = stateChange.getClusterStateOrNull();
NodeEngineImpl nodeEngine = node.getNodeEngine();
TransactionManagerServiceImpl txManagerService = (TransactionManagerServiceImpl) nodeEngine.getTransactionManagerService();
Transaction tx = txManagerService.newAllowedDuringPassiveStateTransaction(options);
notifyBeforeStateChange(oldState, requestedState, isTransient);
tx.begin();
try {
UUID txnId = tx.getTxnId();
Collection<MemberImpl> members = memberMap.getMembers();
int memberListVersion = memberMap.getVersion();
addTransactionRecords(stateChange, tx, members, memberListVersion, partitionStateStamp, isTransient);
lockClusterStateOnAllMembers(stateChange, nodeEngine, options.getTimeoutMillis(), txnId, members, memberListVersion, partitionStateStamp);
checkMemberListChange(memberListVersion);
tx.prepare();
} catch (Throwable e) {
tx.rollback();
notifyAfterStateChange(oldState, requestedState, isTransient);
if (e instanceof TargetNotMemberException || e.getCause() instanceof MemberLeftException) {
throw new IllegalStateException("Cluster members changed during state change!", e);
}
throw ExceptionUtil.rethrow(e);
}
try {
tx.commit();
} catch (Throwable e) {
if (e instanceof TargetNotMemberException || e.getCause() instanceof MemberLeftException) {
// if new state is passive or frozen. They will be able to rejoin later.
return;
}
throw ExceptionUtil.rethrow(e);
} finally {
notifyAfterStateChange(oldState, requestedState, isTransient);
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMap method createNew.
/**
* Creates a new {@code MemberMap} including given members.
*
* @param version version
* @param members members
* @return a new {@code MemberMap}
*/
static MemberMap createNew(int version, MemberImpl... members) {
Map<Address, MemberImpl> addressMap = createLinkedHashMap(members.length);
Map<UUID, MemberImpl> uuidMap = createLinkedHashMap(members.length);
for (MemberImpl member : members) {
putMember(addressMap, uuidMap, member);
}
return new MemberMap(version, addressMap, uuidMap);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method createMember.
private MemberImpl createMember(MemberInfo memberInfo, Map<String, String> attributes) {
Address address = memberInfo.getAddress();
Address thisAddress = node.getThisAddress();
String ipV6ScopeId = thisAddress.getScopeId();
address.setScopeId(ipV6ScopeId);
boolean localMember = thisAddress.equals(address);
MemberImpl.Builder builder;
if (memberInfo.getAddressMap() != null && memberInfo.getAddressMap().containsKey(MEMBER)) {
builder = new MemberImpl.Builder(memberInfo.getAddressMap());
} else {
builder = new MemberImpl.Builder(memberInfo.getAddress());
}
return builder.version(memberInfo.getVersion()).localMember(localMember).uuid(memberInfo.getUuid()).attributes(attributes).liteMember(memberInfo.isLiteMember()).memberListJoinVersion(memberInfo.getMemberListJoinVersion()).instance(node.hazelcastInstance).build();
}
Aggregations