Search in sources :

Example 21 with IPartitionService

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

the class AddMigrationListenerMessageTask method processInternal.

@Override
protected CompletableFuture<UUID> processInternal() {
    IPartitionService partitionService = getService(getServiceName());
    MigrationListener listener = createMigrationListener();
    if (parameters) {
        return newCompletedFuture(partitionService.addLocalMigrationListener(listener));
    }
    return partitionService.addMigrationListenerAsync(listener);
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) MigrationListener(com.hazelcast.partition.MigrationListener)

Example 22 with IPartitionService

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

the class PartitionContainer method createRecordStore.

private RecordStore createRecordStore(String name) {
    MapServiceContext serviceContext = mapService.getMapServiceContext();
    MapContainer mapContainer = serviceContext.getMapContainer(name);
    MapConfig mapConfig = mapContainer.getMapConfig();
    NodeEngine nodeEngine = serviceContext.getNodeEngine();
    IPartitionService ps = nodeEngine.getPartitionService();
    OperationService opService = nodeEngine.getOperationService();
    ExecutionService execService = nodeEngine.getExecutionService();
    HazelcastProperties hazelcastProperties = nodeEngine.getProperties();
    MapKeyLoader keyLoader = new MapKeyLoader(name, opService, ps, nodeEngine.getClusterService(), execService, mapContainer.toData(), serviceContext.getNodeWideLoadedKeyLimiter());
    keyLoader.setMaxBatch(hazelcastProperties.getInteger(ClusterProperty.MAP_LOAD_CHUNK_SIZE));
    keyLoader.setMaxSize(getMaxSizePerNode(mapConfig.getEvictionConfig()));
    keyLoader.setHasBackup(mapConfig.getTotalBackupCount() > 0);
    keyLoader.setMapOperationProvider(serviceContext.getMapOperationProvider(name));
    if (!mapContainer.isGlobalIndexEnabled()) {
        Indexes indexesForMap = mapContainer.createIndexes(false);
        indexes.putIfAbsent(name, indexesForMap);
    }
    RecordStore recordStore = serviceContext.createRecordStore(mapContainer, partitionId, keyLoader);
    recordStore.init();
    return recordStore;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) IPartitionService(com.hazelcast.internal.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapConfig(com.hazelcast.config.MapConfig) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) Indexes(com.hazelcast.query.impl.Indexes)

Example 23 with IPartitionService

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

the class MapReplicationStateHolder method entryCountOnThisNode.

// owned or backup
private long entryCountOnThisNode(MapContainer mapContainer) {
    int replicaIndex = operation.getReplicaIndex();
    long owned = 0;
    if (mapContainer.getEvictor() != Evictor.NULL_EVICTOR && PER_NODE == mapContainer.getMapConfig().getEvictionConfig().getMaxSizePolicy()) {
        MapService mapService = operation.getService();
        MapServiceContext mapServiceContext = mapService.getMapServiceContext();
        IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
        int partitionCount = partitionService.getPartitionCount();
        for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
            if (replicaIndex == 0 ? partitionService.isPartitionOwner(partitionId) : !partitionService.isPartitionOwner(partitionId)) {
                RecordStore store = mapServiceContext.getExistingRecordStore(partitionId, mapContainer.getName());
                if (store != null) {
                    owned += store.size();
                }
            }
        }
    }
    return owned;
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 24 with IPartitionService

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

the class GetAllOperation method runInternal.

@Override
protected void runInternal() {
    IPartitionService partitionService = getNodeEngine().getPartitionService();
    int partitionId = getPartitionId();
    final int roughSize = (int) (keys.size() * SIZING_FUDGE_FACTOR / partitionService.getPartitionCount());
    Set<Data> partitionKeySet = createHashSet(roughSize);
    for (Data key : keys) {
        if (partitionId == partitionService.getPartitionId(key)) {
            partitionKeySet.add(key);
        }
    }
    entries = recordStore.getAll(partitionKeySet, getCallerAddress());
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) Data(com.hazelcast.internal.serialization.Data)

Example 25 with IPartitionService

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

the class XAResourceImpl method clearRemoteTransactions.

private void clearRemoteTransactions(Xid xid) {
    NodeEngine nodeEngine = getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    OperationService operationService = nodeEngine.getOperationService();
    SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
    Data xidData = nodeEngine.toData(serializableXID);
    int partitionId = partitionService.getPartitionId(xidData);
    ClearRemoteTransactionOperation operation = new ClearRemoteTransactionOperation(xidData);
    operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) ClearRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.ClearRemoteTransactionOperation) IPartitionService(com.hazelcast.internal.partition.IPartitionService) Data(com.hazelcast.internal.serialization.Data) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Aggregations

IPartitionService (com.hazelcast.internal.partition.IPartitionService)36 Data (com.hazelcast.internal.serialization.Data)10 NodeEngine (com.hazelcast.spi.impl.NodeEngine)10 Address (com.hazelcast.cluster.Address)8 List (java.util.List)7 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)5 IPartition (com.hazelcast.internal.partition.IPartition)4 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)4 MapService (com.hazelcast.map.impl.MapService)4 ClusterService (com.hazelcast.internal.cluster.ClusterService)3 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)3 ICacheService (com.hazelcast.cache.impl.ICacheService)2 Connection (com.hazelcast.internal.nio.Connection)2 JobConfig (com.hazelcast.jet.config.JobConfig)2 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)2 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)2