Search in sources :

Example 31 with IPartitionService

use of com.hazelcast.spi.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());
    keyLoader.setMaxBatch(hazelcastProperties.getInteger(GroupProperty.MAP_LOAD_CHUNK_SIZE));
    keyLoader.setMaxSize(getMaxSizePerNode(mapConfig.getMaxSizeConfig()));
    keyLoader.setHasBackup(mapConfig.getTotalBackupCount() > 0);
    keyLoader.setMapOperationProvider(serviceContext.getMapOperationProvider(name));
    RecordStore recordStore = serviceContext.createRecordStore(mapContainer, partitionId, keyLoader);
    recordStore.init();
    return recordStore;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) IPartitionService(com.hazelcast.spi.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapConfig(com.hazelcast.config.MapConfig) OperationService(com.hazelcast.spi.OperationService) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 32 with IPartitionService

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

the class EvictionChecker method isOwnerOrBackup.

protected boolean isOwnerOrBackup(int partitionId) {
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final IPartitionService partitionService = nodeEngine.getPartitionService();
    final IPartition partition = partitionService.getPartition(partitionId, false);
    final Address thisAddress = nodeEngine.getThisAddress();
    return partition.isOwnerOrBackup(thisAddress);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) IPartitionService(com.hazelcast.spi.partition.IPartitionService) IPartition(com.hazelcast.spi.partition.IPartition)

Example 33 with IPartitionService

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

the class EvictionChecker method findPartitionIds.

protected List<Integer> findPartitionIds() {
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final IPartitionService partitionService = nodeEngine.getPartitionService();
    final int partitionCount = partitionService.getPartitionCount();
    List<Integer> partitionIds = null;
    for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
        if (isOwnerOrBackup(partitionId)) {
            if (partitionIds == null) {
                partitionIds = new ArrayList<Integer>();
            }
            partitionIds.add(partitionId);
        }
    }
    return partitionIds == null ? Collections.<Integer>emptyList() : partitionIds;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) IPartitionService(com.hazelcast.spi.partition.IPartitionService)

Example 34 with IPartitionService

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

the class GetAllOperation method run.

@Override
public void run() {
    IPartitionService partitionService = getNodeEngine().getPartitionService();
    int partitionId = getPartitionId();
    Set<Data> partitionKeySet = new HashSet<Data>();
    for (Data key : keys) {
        if (partitionId == partitionService.getPartitionId(key)) {
            partitionKeySet.add(key);
        }
    }
    entries = recordStore.getAll(partitionKeySet);
}
Also used : IPartitionService(com.hazelcast.spi.partition.IPartitionService) Data(com.hazelcast.nio.serialization.Data) HashSet(java.util.HashSet)

Example 35 with IPartitionService

use of com.hazelcast.spi.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.NodeEngine) ClearRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.ClearRemoteTransactionOperation) IPartitionService(com.hazelcast.spi.partition.IPartitionService) Data(com.hazelcast.nio.serialization.Data) OperationService(com.hazelcast.spi.OperationService)

Aggregations

IPartitionService (com.hazelcast.spi.partition.IPartitionService)48 Data (com.hazelcast.nio.serialization.Data)11 NodeEngine (com.hazelcast.spi.NodeEngine)11 Address (com.hazelcast.nio.Address)8 HashMap (java.util.HashMap)8 OperationService (com.hazelcast.spi.OperationService)7 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)7 Map (java.util.Map)7 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)5 IPartition (com.hazelcast.spi.partition.IPartition)5 MapService (com.hazelcast.map.impl.MapService)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 ICacheService (com.hazelcast.cache.impl.ICacheService)2 CacheRecord (com.hazelcast.cache.impl.record.CacheRecord)2 QueueReplicationOperation (com.hazelcast.collection.impl.queue.operations.QueueReplicationOperation)2 Member (com.hazelcast.core.Member)2 ClusterService (com.hazelcast.internal.cluster.ClusterService)2 MapEvictionPolicy (com.hazelcast.map.eviction.MapEvictionPolicy)2