Search in sources :

Example 81 with MemberImpl

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);
}
Also used : MemberImpl(com.hazelcast.instance.MemberImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 82 with MemberImpl

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);
                }
            }
        }
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 83 with MemberImpl

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());
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) MemberImpl(com.hazelcast.instance.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) EventService(com.hazelcast.spi.EventService) MigrationEvent(com.hazelcast.core.MigrationEvent)

Example 84 with MemberImpl

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);
            }
        }
    }
}
Also used : MemberImpl(com.hazelcast.instance.MemberImpl) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) OperationService(com.hazelcast.spi.OperationService) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) FetchPartitionStateOperation(com.hazelcast.internal.partition.operation.FetchPartitionStateOperation) PartitionStateOperation(com.hazelcast.internal.partition.operation.PartitionStateOperation) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException)

Example 85 with MemberImpl

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;
}
Also used : MemberImpl(com.hazelcast.instance.MemberImpl) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.OperationService) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Aggregations

MemberImpl (com.hazelcast.instance.MemberImpl)86 Address (com.hazelcast.nio.Address)37 Test (org.junit.Test)18 Member (com.hazelcast.core.Member)17 QuickTest (com.hazelcast.test.annotation.QuickTest)16 ParallelTest (com.hazelcast.test.annotation.ParallelTest)14 ArrayList (java.util.ArrayList)12 InetAddress (java.net.InetAddress)9 Future (java.util.concurrent.Future)9 HashSet (java.util.HashSet)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)7 ClusterService (com.hazelcast.internal.cluster.ClusterService)5 MemberInfoUpdateOperation (com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)5 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)5 ILogger (com.hazelcast.logging.ILogger)5 OperationService (com.hazelcast.spi.OperationService)5 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)5 Before (org.junit.Before)5 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)4