예제 #1
0
 private void sendCleanupOperations(List<PartitionContainer> partitionContainers) {
   final int maxCleanupOperationCountInOneRound = getMaxCleanupOperationCountInOneRound();
   final int start = 0;
   int end = maxCleanupOperationCountInOneRound;
   if (end > partitionContainers.size()) {
     end = partitionContainers.size();
   }
   final List<PartitionContainer> partitionIds = partitionContainers.subList(start, end);
   for (PartitionContainer container : partitionIds) {
     // mark partition container as has on going expiration operation.
     container.setHasRunningCleanup(true);
     OperationService operationService = mapService.getNodeEngine().getOperationService();
     operationService.executeOperation(
         createExpirationOperation(EXPIRATION_PERCENTAGE, container.getPartitionId()));
   }
 }
예제 #2
0
 @Override
 public final void beforeRun() throws Exception {
   mapService = getService();
   mapContainer = mapService.getMapServiceContext().getMapContainer(name);
   partitionContainer = mapService.getMapServiceContext().getPartitionContainer(getPartitionId());
   recordStore = partitionContainer.getRecordStore(name);
   innerBeforeRun();
 }
예제 #3
0
 private static long getUsedHeapSize(final MapContainer mapContainer) {
   long heapCost = 0L;
   final MapService mapService = mapContainer.getMapService();
   final String mapName = mapContainer.getName();
   final NodeEngine nodeEngine = mapService.getNodeEngine();
   final Address thisAddress = nodeEngine.getThisAddress();
   for (int i = 0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
     if (nodeEngine.getPartitionService().getPartition(i).isOwnerOrBackup(thisAddress)) {
       final PartitionContainer container = mapService.getPartitionContainer(i);
       if (container == null) {
         return -1L;
       }
       heapCost += container.getRecordStore(mapName).getHeapCost();
     }
   }
   heapCost += mapContainer.getNearCacheSizeEstimator().getSize();
   return heapCost;
 }
예제 #4
0
 /**
  * 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.
  */
 private boolean notAnyExpirableRecord(PartitionContainer partitionContainer) {
   boolean notExist = true;
   final ConcurrentMap<String, RecordStore> maps = partitionContainer.getMaps();
   for (RecordStore store : maps.values()) {
     if (expirable(store)) {
       notExist = false;
       break;
     }
   }
   return notExist;
 }
예제 #5
0
 private boolean isContainerEmpty(PartitionContainer container) {
   long size = 0L;
   final ConcurrentMap<String, RecordStore> maps = container.getMaps();
   for (RecordStore store : maps.values()) {
     size += store.size();
     if (size > 0L) {
       return false;
     }
   }
   return true;
 }
예제 #6
0
 private static boolean isEvictablePerPartition(final MapContainer mapContainer) {
   final MapService mapService = mapContainer.getMapService();
   final MaxSizeConfig maxSizeConfig = mapContainer.getMapConfig().getMaxSizeConfig();
   final int maxSize = getApproximateMaxSize(maxSizeConfig.getSize());
   final String mapName = mapContainer.getName();
   final NodeEngine nodeEngine = mapService.getNodeEngine();
   final InternalPartitionService partitionService = nodeEngine.getPartitionService();
   for (int i = 0; i < partitionService.getPartitionCount(); i++) {
     final Address owner = partitionService.getPartitionOwner(i);
     if (nodeEngine.getThisAddress().equals(owner)) {
       final PartitionContainer container = mapService.getPartitionContainer(i);
       if (container == null) {
         return false;
       }
       final int size = container.getRecordStore(mapName).size();
       if (size >= maxSize) {
         return true;
       }
     }
   }
   return false;
 }
예제 #7
0
 @Override
 public int compare(PartitionContainer o1, PartitionContainer o2) {
   final long s1 = o1.getLastCleanupTime();
   final long s2 = o2.getLastCleanupTime();
   return (s1 < s2) ? -1 : ((s1 == s2) ? 0 : 1);
 }
예제 #8
0
 private boolean notInProcessableTimeWindow(PartitionContainer partitionContainer, long now) {
   return now - partitionContainer.getLastCleanupTime() < MIN_MILLIS_DIFF_BETWEEN_TWO_RUNS;
 }
예제 #9
0
 private boolean hasRunningCleanup(PartitionContainer partitionContainer) {
   return partitionContainer.hasRunningCleanup();
 }