Search in sources :

Example 36 with InternalPartitionService

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

the class SafeStateCheckOperation method run.

@Override
public void run() throws Exception {
    final InternalPartitionService service = getService();
    safe = service.isMemberStateSafe();
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService)

Example 37 with InternalPartitionService

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

the class MapLoaderTest method findOwnerAndReplicas.

private HazelcastInstance[] findOwnerAndReplicas(HazelcastInstance[] instances, String name) {
    Node node = getNode(instances[0]);
    InternalPartitionService partitionService = node.getPartitionService();
    int partitionId = partitionService.getPartitionId(name);
    InternalPartition partition = partitionService.getPartition(partitionId);
    HazelcastInstance[] ownerAndReplicas = new HazelcastInstance[instances.length];
    for (int i = 0; i < instances.length; i++) {
        ownerAndReplicas[i] = getInstanceForAddress(instances, partition.getReplicaAddress(i));
    }
    return ownerAndReplicas;
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Node(com.hazelcast.instance.Node) InternalPartition(com.hazelcast.internal.partition.InternalPartition)

Example 38 with InternalPartitionService

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

the class QueryResultSizeLimiterTest method initMocksWithConfiguration.

private void initMocksWithConfiguration(int maxResultSizeLimit, int maxLocalPartitionLimitForPreCheck, int partitionCount) {
    Config config = new Config();
    config.setProperty(QUERY_RESULT_SIZE_LIMIT.getName(), valueOf(maxResultSizeLimit));
    config.setProperty(QUERY_MAX_LOCAL_PARTITION_LIMIT_FOR_PRE_CHECK.getName(), valueOf(maxLocalPartitionLimitForPreCheck));
    config.setProperty(PARTITION_COUNT.getName(), valueOf(partitionCount));
    HazelcastProperties hazelcastProperties = new HazelcastProperties(config);
    InternalPartitionService partitionService = mock(InternalPartitionService.class);
    when(partitionService.getPartitionCount()).thenReturn(partitionCount);
    NodeEngine nodeEngine = mock(NodeEngine.class);
    when(nodeEngine.getProperties()).thenReturn(hazelcastProperties);
    when(nodeEngine.getPartitionService()).thenReturn(partitionService);
    RecordStore recordStore = mock(RecordStore.class);
    when(recordStore.size()).then(new RecordStoreAnswer(localPartitions.values()));
    MapServiceContext mapServiceContext = mock(MapServiceContext.class);
    when(mapServiceContext.getNodeEngine()).thenReturn(nodeEngine);
    when(mapServiceContext.getRecordStore(anyInt(), anyString())).thenReturn(recordStore);
    when(mapServiceContext.getOwnedPartitions()).thenReturn(localPartitions.keySet());
    limiter = new QueryResultSizeLimiter(mapServiceContext, Logger.getLogger(QueryResultSizeLimiterTest.class));
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Config(com.hazelcast.config.Config) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 39 with InternalPartitionService

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

the class InvalidationMetadataDistortionTest method distortRandomPartitionSequence.

private void distortRandomPartitionSequence(String mapName, HazelcastInstance member) {
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
    MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    Invalidator invalidator = mapNearCacheManager.getInvalidator();
    MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
    InternalPartitionService partitionService = nodeEngineImpl.getPartitionService();
    int partitionCount = partitionService.getPartitionCount();
    metaDataGenerator.setCurrentSequence(mapName, getInt(partitionCount), getInt(MAX_VALUE));
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 40 with InternalPartitionService

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

the class TestPartitionUtils method getAllReplicaAddresses.

public static Map<Integer, List<Address>> getAllReplicaAddresses(Node node) {
    Map<Integer, List<Address>> allReplicaAddresses = new HashMap<Integer, List<Address>>();
    InternalPartitionService partitionService = node.getPartitionService();
    for (int partitionId = 0; partitionId < partitionService.getPartitionCount(); partitionId++) {
        allReplicaAddresses.put(partitionId, getReplicaAddresses(node, partitionId));
    }
    return allReplicaAddresses;
}
Also used : Address(com.hazelcast.nio.Address) HashMap(java.util.HashMap) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) ArrayList(java.util.ArrayList) List(java.util.List)

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