Search in sources :

Example 26 with Partition

use of com.hazelcast.partition.Partition in project hazelcast by hazelcast.

the class MapFetchIndexOperationTest method getLocalPartitions.

private static PartitionIdSet getLocalPartitions(HazelcastInstance member) {
    PartitionService partitionService = member.getPartitionService();
    PartitionIdSet res = new PartitionIdSet(partitionService.getPartitions().size());
    for (Partition partition : partitionService.getPartitions()) {
        if (partition.getOwner().localMember()) {
            res.add(partition.getPartitionId());
        }
    }
    return res;
}
Also used : Partition(com.hazelcast.partition.Partition) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) PartitionService(com.hazelcast.partition.PartitionService)

Example 27 with Partition

use of com.hazelcast.partition.Partition in project hazelcast by hazelcast.

the class SingleValueBitmapIndexTest method testClearedIndexes.

@Test
public void testClearedIndexes() {
    for (int i = BATCH_COUNT - 1; i >= 0; --i) {
        for (long j = 0; j < BATCH_SIZE; ++j) {
            long id = i * BATCH_SIZE + j;
            put(id, (int) id);
        }
        verifyQueries();
    }
    for (HazelcastInstance instance : factory.getAllHazelcastInstances()) {
        HazelcastInstanceImpl instanceImpl = (HazelcastInstanceImpl) instance;
        MapService mapService = instanceImpl.node.getNodeEngine().getService(MapService.SERVICE_NAME);
        Indexes indexes = mapService.getMapServiceContext().getMapContainer(persons.getName()).getIndexes();
        indexes.clearAll();
        for (Partition partition : instanceImpl.getPartitionService().getPartitions()) {
            if (partition.getOwner().localMember()) {
                Indexes.beginPartitionUpdate(indexes.getIndexes());
                Indexes.markPartitionAsIndexed(partition.getPartitionId(), indexes.getIndexes());
            }
        }
    }
    for (ExpectedQuery expectedQuery : expectedQueries) {
        expectedQuery.clear();
    }
    // Repopulate the index and run queries. Technically, we are doing index
    // updates here instead of inserts since the map is still populated, but
    // the index interprets them as inserts.
    persons.getLocalMapStats().getIndexStats();
    for (int i = BATCH_COUNT - 1; i >= 0; --i) {
        for (long j = 0; j < BATCH_SIZE; ++j) {
            long id = i * BATCH_SIZE + j;
            put(id, (int) id);
        }
        verifyQueries();
    }
    LocalIndexStats statsA = personsA.getLocalMapStats().getIndexStats().values().iterator().next();
    LocalIndexStats statsB = personsB.getLocalMapStats().getIndexStats().values().iterator().next();
    assertEquals(BATCH_COUNT * BATCH_SIZE, statsA.getInsertCount() + statsB.getInsertCount());
    assertEquals(BATCH_COUNT * BATCH_SIZE, statsA.getUpdateCount() + statsB.getUpdateCount());
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) Partition(com.hazelcast.partition.Partition) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapService(com.hazelcast.map.impl.MapService) Indexes(com.hazelcast.query.impl.Indexes) LocalIndexStats(com.hazelcast.query.LocalIndexStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with Partition

use of com.hazelcast.partition.Partition in project hazelcast by hazelcast.

the class Invocation_ServerConnectionManagerTest method testInvocation_whenEndpointManagerIsNoop.

@Test
public void testInvocation_whenEndpointManagerIsNoop() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    String key = generateKeyOwnedBy(hz2);
    Data dataKey = getSerializationService(hz1).toData(key);
    Partition partition = hz1.getPartitionService().getPartition(key);
    Operation op = new GetOperation("test", dataKey);
    InvocationBuilder builder = getNodeEngineImpl(hz1).getOperationService().createInvocationBuilder(MapService.SERVICE_NAME, op, partition.getPartitionId());
    builder.setConnectionManager(new NoopEndpointManager());
    expected.expect(UnsupportedOperationException.class);
    expected.expectMessage(EXPECTED_MSG);
    builder.invoke().join();
}
Also used : Partition(com.hazelcast.partition.Partition) GetOperation(com.hazelcast.map.impl.operation.GetOperation) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Data(com.hazelcast.internal.serialization.Data) Operation(com.hazelcast.spi.impl.operationservice.Operation) GetOperation(com.hazelcast.map.impl.operation.GetOperation) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Partition (com.hazelcast.partition.Partition)28 PartitionService (com.hazelcast.partition.PartitionService)13 Member (com.hazelcast.cluster.Member)12 Test (org.junit.Test)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 IPartition (com.hazelcast.internal.partition.IPartition)5 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)5 UUID (java.util.UUID)5 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Cluster (com.hazelcast.cluster.Cluster)3 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)3 Entry (java.util.Map.Entry)3 Config (com.hazelcast.config.Config)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Assert.assertEquals (org.junit.Assert.assertEquals)2