use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method publishPartitionRuntimeState.
@SuppressWarnings("checkstyle:npathcomplexity")
void publishPartitionRuntimeState() {
if (!partitionStateManager.isInitialized()) {
// do not send partition state until initialized!
return;
}
if (!node.isMaster()) {
return;
}
if (!isReplicaSyncAllowed()) {
// migration is disabled because of a member leave, wait till enabled!
return;
}
PartitionRuntimeState partitionState = createPartitionStateInternal();
if (partitionState == null) {
return;
}
if (logger.isFineEnabled()) {
logger.fine("Publishing partition state, version: " + partitionState.getVersion());
}
PartitionStateOperation op = new PartitionStateOperation(partitionState);
OperationService operationService = nodeEngine.getOperationService();
Collection<MemberImpl> members = node.clusterService.getMemberImpls();
for (MemberImpl member : members) {
if (!member.localMember()) {
try {
operationService.send(op, member.getAddress());
} catch (Exception e) {
logger.finest(e);
}
}
}
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method syncPartitionRuntimeState.
@SuppressWarnings("checkstyle:npathcomplexity")
boolean syncPartitionRuntimeState() {
if (!partitionStateManager.isInitialized()) {
// do not send partition state until initialized!
return false;
}
if (!node.isMaster()) {
return false;
}
PartitionRuntimeState partitionState = createPartitionStateInternal();
if (partitionState == null) {
return false;
}
if (logger.isFineEnabled()) {
logger.fine("Sync'ing partition state, version: " + partitionState.getVersion());
}
OperationService operationService = nodeEngine.getOperationService();
Collection<MemberImpl> members = node.clusterService.getMemberImpls();
List<Future<Boolean>> calls = firePartitionStateOperation(members, partitionState, operationService);
Collection<Boolean> results = returnWithDeadline(calls, PTABLE_SYNC_TIMEOUT_SECONDS, TimeUnit.SECONDS, partitionStateSyncTimeoutHandler);
if (calls.size() != results.size()) {
return false;
}
for (Boolean result : results) {
if (!result) {
if (logger.isFineEnabled()) {
logger.fine("Partition state, version: " + partitionState.getVersion() + " sync failed to one of the members!");
}
return false;
}
}
return true;
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method firePartitionStateOperation.
private List<Future<Boolean>> firePartitionStateOperation(Collection<MemberImpl> members, PartitionRuntimeState partitionState, OperationService operationService) {
final ClusterServiceImpl clusterService = node.clusterService;
List<Future<Boolean>> calls = new ArrayList<Future<Boolean>>(members.size());
for (MemberImpl member : members) {
if (!(member.localMember() || clusterService.isMemberRemovedWhileClusterIsNotActive(member.getAddress()))) {
try {
Address address = member.getAddress();
PartitionStateOperation operation = new PartitionStateOperation(partitionState, true);
Future<Boolean> f = operationService.invokeOnTarget(SERVICE_NAME, operation, address);
calls.add(f);
} catch (Exception e) {
logger.finest(e);
}
}
}
return calls;
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class ClusterServiceImpl method doRemoveAddress.
void doRemoveAddress(Address deadAddress, String reason, boolean destroyConnection) {
if (!ensureMemberIsRemovable(deadAddress)) {
return;
}
lock.lock();
try {
if (deadAddress.equals(node.getMasterAddress())) {
assignNewMaster();
}
if (node.isMaster()) {
clusterJoinManager.removeJoin(deadAddress);
}
Connection conn = node.connectionManager.getConnection(deadAddress);
if (destroyConnection && conn != null) {
conn.close(reason, null);
}
MemberImpl deadMember = getMember(deadAddress);
if (deadMember != null) {
removeMember(deadMember);
logger.info(membersString());
}
} finally {
lock.unlock();
}
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class DiscoveryJoiner method getPossibleAddresses.
@Override
protected Collection<Address> getPossibleAddresses() {
Iterable<DiscoveryNode> discoveredNodes = checkNotNull(discoveryService.discoverNodes(), "Discovered nodes cannot be null!");
MemberImpl localMember = node.nodeEngine.getLocalMember();
Address localAddress = localMember.getAddress();
Collection<Address> possibleMembers = new ArrayList<Address>();
for (DiscoveryNode discoveryNode : discoveredNodes) {
Address discoveredAddress = usePublicAddress ? discoveryNode.getPublicAddress() : discoveryNode.getPrivateAddress();
if (localAddress.equals(discoveredAddress)) {
continue;
}
possibleMembers.add(discoveredAddress);
}
return possibleMembers;
}
Aggregations