@Override public Iterator<RecordStore> storeIterator(PartitionContainer container) { return container.getMaps().values().iterator(); }
@Override public Iterator<RecordStore> storeIterator(PartitionContainer container) { return container.getMaps().values().iterator(); }
@Override protected boolean isContainerEmpty(PartitionContainer container) { long size = 0L; ConcurrentMap<String, RecordStore> maps = container.getMaps(); for (RecordStore store : maps.values()) { size += store.size(); if (size > 0L) { return false; } } return true; }
@Override protected boolean isContainerEmpty(PartitionContainer container) { long size = 0L; ConcurrentMap<String, RecordStore> maps = container.getMaps(); for (RecordStore store : maps.values()) { size += store.size(); if (size > 0L) { return false; } } return true; }
/** * Here we check if that partition has any expirable record or not, * if no expirable record exists in that partition no need to fire an expiration operation. * * @param partitionContainer corresponding partition container. * @return <code>true</code> if no expirable record in that partition <code>false</code> otherwise. */ @Override protected boolean notHaveAnyExpirableRecord(PartitionContainer partitionContainer) { boolean notExist = true; final ConcurrentMap<String, RecordStore> maps = partitionContainer.getMaps(); for (RecordStore store : maps.values()) { if (store.isExpirable()) { notExist = false; break; } } return notExist; }
/** * Here we check if that partition has any expirable record or not, * if no expirable record exists in that partition no need to fire * an expiration operation. * * @param partitionContainer corresponding partition container. * @return <code>true</code> if no expirable record in that * partition <code>false</code> otherwise. */ @Override protected boolean notHaveAnyExpirableRecord(PartitionContainer partitionContainer) { boolean notExist = true; final ConcurrentMap<String, RecordStore> maps = partitionContainer.getMaps(); for (RecordStore store : maps.values()) { if (store.isExpirable()) { notExist = false; break; } } return notExist; }
@Override protected boolean hasExpiredKeyToSendBackup(PartitionContainer container) { long size = 0L; ConcurrentMap<String, RecordStore> maps = container.getMaps(); for (RecordStore store : maps.values()) { size += store.getExpiredKeysQueue().size(); if (size > 0L) { return true; } } return false; }
@Override protected boolean hasExpiredKeyToSendBackup(PartitionContainer container) { long size = 0L; ConcurrentMap<String, RecordStore> maps = container.getMaps(); for (RecordStore store : maps.values()) { size += store.getExpiredKeysQueue().size(); if (size > 0L) { return true; } } return false; }
@Override public void removeRecordStoresFromPartitionMatchingWith(Predicate<RecordStore> predicate, int partitionId, boolean onShutdown, boolean onRecordStoreDestroy) { PartitionContainer container = partitionContainers[partitionId]; if (container == null) { return; } Iterator<RecordStore> partitionIterator = container.getMaps().values().iterator(); while (partitionIterator.hasNext()) { RecordStore partition = partitionIterator.next(); if (predicate.test(partition)) { partition.clearPartition(onShutdown, onRecordStoreDestroy); partitionIterator.remove(); } } }
@Override public void removeRecordStoresFromPartitionMatchingWith(Predicate<RecordStore> predicate, int partitionId, boolean onShutdown, boolean onRecordStoreDestroy) { PartitionContainer container = partitionContainers[partitionId]; if (container == null) { return; } Iterator<RecordStore> partitionIterator = container.getMaps().values().iterator(); while (partitionIterator.hasNext()) { RecordStore partition = partitionIterator.next(); if (predicate.test(partition)) { partition.clearPartition(onShutdown, onRecordStoreDestroy); partitionIterator.remove(); } } }
/** * This can happen due to the partition ownership changes. */ @Override protected void clearLeftoverExpiredKeyQueues(PartitionContainer container) { ConcurrentMap<String, RecordStore> maps = container.getMaps(); for (RecordStore store : maps.values()) { InvalidationQueue expiredKeys = store.getExpiredKeysQueue(); for (; ; ) { if (expiredKeys.poll() == null) { break; } } } }
protected void equalizeBackupSizeWithPrimary(PartitionContainer container) { if (!canPrimaryDriveExpiration()) { return; } ConcurrentMap<String, RecordStore> maps = container.getMaps(); for (RecordStore recordStore : maps.values()) { int totalBackupCount = recordStore.getMapContainer().getTotalBackupCount(); toBackupSender.invokeBackupExpiryOperation(Collections.<ExpiredKey>emptyList(), totalBackupCount, recordStore.getPartitionId(), recordStore); } }
protected void equalizeBackupSizeWithPrimary(PartitionContainer container) { if (!canPrimaryDriveExpiration()) { return; } ConcurrentMap<String, RecordStore> maps = container.getMaps(); for (RecordStore recordStore : maps.values()) { int totalBackupCount = recordStore.getMapContainer().getTotalBackupCount(); toBackupSender.invokeBackupExpiryOperation(Collections.<ExpiredKey>emptyList(), totalBackupCount, recordStore.getPartitionId(), recordStore); } }
private void clearNonGlobalIndexes(PartitionMigrationEvent event) { final PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId()); for (RecordStore recordStore : container.getMaps().values()) { final MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName()); final Indexes indexes = mapContainer.getIndexes(event.getPartitionId()); if (!indexes.hasIndex() || indexes.isGlobal()) { // no indexes to work with continue; } indexes.clearAll(); } }
private void clearNonGlobalIndexes(PartitionMigrationEvent event) { final PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId()); for (RecordStore recordStore : container.getMaps().values()) { final MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName()); final Indexes indexes = mapContainer.getIndexes(event.getPartitionId()); if (!indexes.haveAtLeastOneIndex() || indexes.isGlobal()) { // no indexes to work with continue; } indexes.clearAll(); } }
private void depopulateIndexes(PartitionMigrationEvent event) { assert event.getMigrationEndpoint() == SOURCE; assert event.getNewReplicaIndex() != 0 : "Invalid migration event: " + event; if (event.getCurrentReplicaIndex() != 0) { // backup partitions have no indexes to depopulate return; } final long now = getNow(); final PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId()); for (RecordStore recordStore : container.getMaps().values()) { final MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName()); final Indexes indexes = mapContainer.getIndexes(event.getPartitionId()); if (!indexes.hasIndex()) { // no indexes to work with continue; } final Iterator<Record> iterator = recordStore.iterator(now, false); while (iterator.hasNext()) { final Record record = iterator.next(); final Data key = record.getKey(); final Object value = Records.getValueOrCachedValue(record, serializationService); indexes.removeEntryIndex(key, value, Index.OperationSource.SYSTEM); } } }
@Override public void run() throws Exception { if (getNodeEngine().getLocalMember().isLiteMember()) { // this operation shouldn't run on lite members. This situation can potentially be seen // when converting a data-member to lite-member during merge operations. return; } MapService mapService = getService(); MapServiceContext mapServiceContext = mapService.getMapServiceContext(); PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(getPartitionId()); ConcurrentMap<String, RecordStore> recordStores = partitionContainer.getMaps(); boolean backup = !isOwner(); for (final RecordStore recordStore : recordStores.values()) { if (recordStore.size() > 0 && recordStore.isExpirable()) { recordStore.evictExpiredEntries(expirationPercentage, backup); recordStore.disposeDeferredBlocks(); } } }
@Override public void run() throws Exception { if (getNodeEngine().getLocalMember().isLiteMember()) { // this operation shouldn't run on lite members. This situation can potentially be seen // when converting a data-member to lite-member during merge operations. return; } MapService mapService = getService(); MapServiceContext mapServiceContext = mapService.getMapServiceContext(); PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(getPartitionId()); ConcurrentMap<String, RecordStore> recordStores = partitionContainer.getMaps(); boolean backup = !isOwner(); for (final RecordStore recordStore : recordStores.values()) { if (recordStore.size() > 0 && recordStore.isExpirable()) { recordStore.evictExpiredEntries(expirationPercentage, backup); recordStore.disposeDeferredBlocks(); } } }
private void depopulateIndexes(PartitionMigrationEvent event) { assert event.getMigrationEndpoint() == SOURCE; assert event.getNewReplicaIndex() != 0 : "Invalid migration event: " + event; if (event.getCurrentReplicaIndex() != 0) { // backup partitions have no indexes to depopulate return; } final long now = getNow(); final PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId()); for (RecordStore recordStore : container.getMaps().values()) { final MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName()); final Indexes indexes = mapContainer.getIndexes(event.getPartitionId()); if (!indexes.haveAtLeastOneIndex()) { // no indexes to work with continue; } final InternalIndex[] indexesSnapshot = indexes.getIndexes(); final Iterator<Record> iterator = recordStore.iterator(now, false); while (iterator.hasNext()) { final Record record = iterator.next(); final Data key = record.getKey(); final Object value = Records.getValueOrCachedValue(record, serializationService); indexes.removeEntry(key, value, Index.OperationSource.SYSTEM); } Indexes.markPartitionAsUnindexed(event.getPartitionId(), indexesSnapshot); } }
for (RecordStore recordStore : container.getMaps().values()) { final MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName());