Search in sources :

Example 26 with InternalPartition

use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.

the class InternalPartitionServiceImpl method createPromotionCommitPartitionState.

/**
     * Creates a transient PartitionRuntimeState to commit promotions.
     * Results of promotions are applied to partition table.
     * Version of created partition table is incremented by number of promotions.
     */
PartitionRuntimeState createPromotionCommitPartitionState(Collection<MigrationInfo> migrationInfos) {
    lock.lock();
    try {
        if (!partitionStateManager.isInitialized()) {
            return null;
        }
        List<MigrationInfo> completedMigrations = migrationManager.getCompletedMigrationsCopy();
        InternalPartition[] partitions = partitionStateManager.getPartitionsCopy();
        for (MigrationInfo migrationInfo : migrationInfos) {
            int partitionId = migrationInfo.getPartitionId();
            InternalPartitionImpl partition = (InternalPartitionImpl) partitions[partitionId];
            migrationManager.applyMigration(partition, migrationInfo);
            migrationInfo.setStatus(MigrationStatus.SUCCESS);
        }
        int committedVersion = getPartitionStateVersion() + migrationInfos.size();
        return new PartitionRuntimeState(partitions, completedMigrations, committedVersion);
    } finally {
        lock.unlock();
    }
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) InternalPartition(com.hazelcast.internal.partition.InternalPartition)

Aggregations

InternalPartition (com.hazelcast.internal.partition.InternalPartition)26 ParallelTest (com.hazelcast.test.annotation.ParallelTest)13 QuickTest (com.hazelcast.test.annotation.QuickTest)13 Test (org.junit.Test)13 HazelcastInstance (com.hazelcast.core.HazelcastInstance)12 Address (com.hazelcast.nio.Address)12 Config (com.hazelcast.config.Config)8 ListenerConfig (com.hazelcast.config.ListenerConfig)6 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 AssertTask (com.hazelcast.test.AssertTask)4 ClusterState (com.hazelcast.cluster.ClusterState)3 MigrationInfo (com.hazelcast.internal.partition.MigrationInfo)3 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)2 Node (com.hazelcast.instance.Node)2 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)2 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)2 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 TransactionException (com.hazelcast.transaction.TransactionException)2