Search in sources :

Example 6 with InternalPartitionService

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

the class BaseMigrationOperation method verifyPartitionStateVersion.

private void verifyPartitionStateVersion() {
    InternalPartitionService partitionService = getService();
    int localPartitionStateVersion = partitionService.getPartitionStateVersion();
    if (partitionStateVersion != localPartitionStateVersion) {
        if (getNodeEngine().getThisAddress().equals(migrationInfo.getMaster())) {
            return;
        }
        // this is expected when cluster member list changes during migration
        throw new PartitionStateVersionMismatchException(partitionStateVersion, localPartitionStateVersion);
    }
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) PartitionStateVersionMismatchException(com.hazelcast.internal.partition.PartitionStateVersionMismatchException)

Example 7 with InternalPartitionService

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

the class OperationBackupHandler method syncBackups.

int syncBackups(int requestedSyncBackups, int requestedAsyncBackups, boolean syncForced) {
    if (syncForced) {
        // if force sync enabled, then the sum of the backups
        requestedSyncBackups += requestedAsyncBackups;
    }
    InternalPartitionService partitionService = node.getPartitionService();
    int maxBackupCount = partitionService.getMaxAllowedBackupCount();
    return min(maxBackupCount, requestedSyncBackups);
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService)

Example 8 with InternalPartitionService

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

the class OperationBackupHandler method makeBackups.

private int makeBackups(BackupAwareOperation backupAwareOp, int partitionId, long[] replicaVersions, int syncBackups, int asyncBackups) {
    int sendSyncBackups;
    int totalBackups = syncBackups + asyncBackups;
    InternalPartitionService partitionService = node.getPartitionService();
    InternalPartition partition = partitionService.getPartition(partitionId);
    if (totalBackups == 1) {
        sendSyncBackups = sendSingleBackup(backupAwareOp, partition, replicaVersions, syncBackups);
    } else {
        sendSyncBackups = sendMultipleBackups(backupAwareOp, partition, replicaVersions, syncBackups, totalBackups);
    }
    return sendSyncBackups;
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) InternalPartition(com.hazelcast.internal.partition.InternalPartition)

Example 9 with InternalPartitionService

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

the class OperationBackupHandler method sendBackups0.

int sendBackups0(BackupAwareOperation backupAwareOp) throws Exception {
    int requestedSyncBackups = requestedSyncBackups(backupAwareOp);
    int requestedAsyncBackups = requestedAsyncBackups(backupAwareOp);
    int requestedTotalBackups = requestedTotalBackups(backupAwareOp);
    if (requestedTotalBackups == 0) {
        return 0;
    }
    Operation op = (Operation) backupAwareOp;
    InternalPartitionService partitionService = node.getPartitionService();
    long[] replicaVersions = partitionService.incrementPartitionReplicaVersions(op.getPartitionId(), requestedTotalBackups);
    boolean syncForced = backpressureRegulator.isSyncForced(backupAwareOp);
    int syncBackups = syncBackups(requestedSyncBackups, requestedAsyncBackups, syncForced);
    int asyncBackups = asyncBackups(requestedSyncBackups, requestedAsyncBackups, syncForced);
    // TODO: This could cause a problem with back pressure
    if (!op.returnsResponse()) {
        asyncBackups += syncBackups;
        syncBackups = 0;
    }
    if (syncBackups + asyncBackups == 0) {
        return 0;
    }
    return makeBackups(backupAwareOp, op.getPartitionId(), replicaVersions, syncBackups, asyncBackups);
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Operation(com.hazelcast.spi.Operation) BackupAwareOperation(com.hazelcast.spi.BackupAwareOperation)

Example 10 with InternalPartitionService

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

the class OperationServiceImpl method invokeOnPartitions.

@Override
public Map<Integer, Object> invokeOnPartitions(String serviceName, OperationFactory operationFactory, Collection<Integer> partitions) throws Exception {
    Map<Address, List<Integer>> memberPartitions = new HashMap<Address, List<Integer>>(3);
    InternalPartitionService partitionService = nodeEngine.getPartitionService();
    for (int partition : partitions) {
        Address owner = partitionService.getPartitionOwnerOrWait(partition);
        if (!memberPartitions.containsKey(owner)) {
            memberPartitions.put(owner, new ArrayList<Integer>());
        }
        memberPartitions.get(owner).add(partition);
    }
    InvokeOnPartitions invokeOnPartitions = new InvokeOnPartitions(this, serviceName, operationFactory, memberPartitions);
    return invokeOnPartitions.invoke();
}
Also used : Address(com.hazelcast.nio.Address) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) List(java.util.List) ArrayList(java.util.ArrayList) CollectionUtil.toIntegerList(com.hazelcast.util.CollectionUtil.toIntegerList)

Aggregations

InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)45 Address (com.hazelcast.nio.Address)11 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 Test (org.junit.Test)10 Node (com.hazelcast.instance.Node)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 ArrayList (java.util.ArrayList)8 Config (com.hazelcast.config.Config)6 Data (com.hazelcast.nio.serialization.Data)6 IPartition (com.hazelcast.spi.partition.IPartition)6 HashMap (java.util.HashMap)6 InternalPartition (com.hazelcast.internal.partition.InternalPartition)5 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)5 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)5 List (java.util.List)5 Map (java.util.Map)5 ICacheService (com.hazelcast.cache.impl.ICacheService)4 ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)3 CacheConfig (com.hazelcast.config.CacheConfig)3