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;
}
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());
}
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();
}
Aggregations