use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class MemberMapTest method cloneAdding_failsWithDuplicateUuid.
@Test(expected = IllegalArgumentException.class)
public void cloneAdding_failsWithDuplicateUuid() {
MemberImpl[] members = new MemberImpl[3];
for (int i = 0; i < members.length; i++) {
members[i] = newMember(5000 + i);
}
MemberImpl member = new MemberImpl(newAddress(6000), VERSION, false, members[1].getUuid(), null);
MemberMap.cloneAdding(MemberMap.createNew(members), member);
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class PartitionStateManager method removeUnknownAddresses.
void removeUnknownAddresses() {
ClusterServiceImpl clusterService = node.getClusterService();
for (InternalPartitionImpl partition : partitions) {
for (int i = 0; i < InternalPartition.MAX_REPLICA_COUNT; i++) {
Address address = partition.getReplicaAddress(i);
if (address == null) {
continue;
}
MemberImpl member = clusterService.getMember(address);
if (member == null) {
partition.setReplicaAddress(i, null);
if (logger.isFinestEnabled()) {
logger.finest("PartitionId=" + partition.getPartitionId() + " " + address + " is removed from replica index: " + i + ", partition: " + partition);
}
}
}
}
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class PartitionEventManager method sendMigrationEvent.
void sendMigrationEvent(final MigrationInfo migrationInfo, final MigrationEvent.MigrationStatus status) {
if (migrationInfo.getSourceCurrentReplicaIndex() != 0 && migrationInfo.getDestinationNewReplicaIndex() != 0) {
// only fire events for 0th replica migrations
return;
}
ClusterServiceImpl clusterService = node.getClusterService();
MemberImpl current = clusterService.getMember(migrationInfo.getSource());
MemberImpl newOwner = clusterService.getMember(migrationInfo.getDestination());
MigrationEvent event = new MigrationEvent(migrationInfo.getPartitionId(), current, newOwner, status);
EventService eventService = nodeEngine.getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, MIGRATION_EVENT_TOPIC);
eventService.publishEvent(SERVICE_NAME, registrations, event, event.getPartitionId());
}
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;
}
Aggregations