use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.
the class DynamicMapConfigTest method isRecordStoreExpirable.
private boolean isRecordStoreExpirable(IMap map) {
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapService mapService = (MapService) mapProxy.getService();
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
PartitionContainer container = mapServiceContext.getPartitionContainer(0);
RecordStore recordStore = container.getExistingRecordStore(map.getName());
return requireNonNull(recordStore).isExpirable();
}
use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.
the class MapIndexLifecycleTest method assertAllPartitionContainersAreEmpty.
private void assertAllPartitionContainersAreEmpty(HazelcastInstance instance) {
MapServiceContext context = getMapServiceContext(instance);
int partitionCount = getPartitionCount(instance);
for (int i = 0; i < partitionCount; i++) {
PartitionContainer container = context.getPartitionContainer(i);
Map<String, ?> maps = container.getMaps().entrySet().stream().filter(e -> !e.getKey().startsWith(JobRepository.INTERNAL_JET_OBJECTS_PREFIX)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
assertTrue("record stores not empty", maps.isEmpty());
Map<String, Indexes> indexes = container.getIndexes().entrySet().stream().filter(e -> !e.getKey().startsWith(JobRepository.INTERNAL_JET_OBJECTS_PREFIX)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
assertTrue("indexes not empty", indexes.isEmpty());
}
}
use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.
the class MapIndexLifecycleTest method assertAllPartitionContainersAreInitialized.
private void assertAllPartitionContainersAreInitialized(HazelcastInstance instance) {
MapServiceContext context = getMapServiceContext(instance);
int partitionCount = getPartitionCount(instance);
final AtomicInteger authorRecordsCounter = new AtomicInteger();
final AtomicInteger yearRecordsCounter = new AtomicInteger();
String authorOwned = findAuthorOwnedBy(instance);
Integer yearOwned = findYearOwnedBy(instance);
for (int i = 0; i < partitionCount; i++) {
if (!getNode(instance).getPartitionService().isPartitionOwner(i)) {
continue;
}
PartitionContainer container = context.getPartitionContainer(i);
ConcurrentMap<String, RecordStore> maps = container.getMaps();
RecordStore recordStore = maps.get(mapName);
assertNotNull("record store is null: ", recordStore);
if (!globalIndex()) {
// also assert contents of partition indexes when NATIVE memory format
ConcurrentMap<String, Indexes> indexes = container.getIndexes();
final Indexes index = indexes.get(mapName);
assertNotNull("indexes is null", indexes);
assertEquals(2, index.getIndexes().length);
assertNotNull("There should be a partition index for attribute 'author'", index.getIndex("author"));
assertNotNull("There should be a partition index for attribute 'year'", index.getIndex("year"));
authorRecordsCounter.getAndAdd(numberOfPartitionQueryResults(instance, i, "author", authorOwned));
yearRecordsCounter.getAndAdd(numberOfPartitionQueryResults(instance, i, "year", yearOwned));
}
}
if (!globalIndex()) {
assertTrue("Author index should contain records", authorRecordsCounter.get() > 0);
assertTrue("Year index should contain records", yearRecordsCounter.get() > 0);
}
}
use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.
the class MapBackupAccessor method get.
@Override
public V get(K key) {
IPartition partition = getPartitionForKey(key);
HazelcastInstance hz = getHazelcastInstance(partition);
Node node = getNode(hz);
SerializationService serializationService = node.getSerializationService();
MapService mapService = node.getNodeEngine().getService(MapService.SERVICE_NAME);
MapServiceContext context = mapService.getMapServiceContext();
int partitionId = partition.getPartitionId();
PartitionContainer partitionContainer = context.getPartitionContainer(partitionId);
return runOnPartitionThread(hz, new GetValueCallable(serializationService, partitionContainer, key), partitionId);
}
use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.
the class MapBackupAccessor method size.
@Override
public int size() {
InternalPartitionService partitionService = getNode(cluster[0]).getPartitionService();
IPartition[] partitions = partitionService.getPartitions();
int count = 0;
for (IPartition partition : partitions) {
Address replicaAddress = partition.getReplicaAddress(replicaIndex);
if (replicaAddress == null) {
continue;
}
HazelcastInstance hz = getInstanceWithAddress(replicaAddress);
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext context = mapService.getMapServiceContext();
int partitionId = partition.getPartitionId();
PartitionContainer partitionContainer = context.getPartitionContainer(partitionId);
count += runOnPartitionThread(hz, new SizeCallable(partitionContainer), partitionId);
}
return count;
}
Aggregations