Example #1
0
  public void init(final NodeEngine nodeEngine, Properties properties) {
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    for (int partition = 0; partition < partitionCount; partition++) {
      partitionContainers[partition] = new MultiMapPartitionContainer(this, partition);
    }
    final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
      lockService.registerLockStoreConstructor(
          SERVICE_NAME,
          new ConstructorFunction<ObjectNamespace, LockStoreInfo>() {
            public LockStoreInfo createNew(final ObjectNamespace key) {
              String name = key.getObjectName();
              final MultiMapConfig multiMapConfig = nodeEngine.getConfig().findMultiMapConfig(name);

              return new LockStoreInfo() {
                public int getBackupCount() {
                  return multiMapConfig.getSyncBackupCount();
                }

                public int getAsyncBackupCount() {
                  return multiMapConfig.getAsyncBackupCount();
                }
              };
            }
          });
    }
  }
Example #2
0
  public void init(final NodeEngine nodeEngine, Properties properties) {
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    for (int i = 0; i < partitionCount; i++) {
      partitionContainers[i] = new PartitionContainer(this, i);
    }
    final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
      lockService.registerLockStoreConstructor(
          SERVICE_NAME,
          new ConstructorFunction<ObjectNamespace, LockStoreInfo>() {
            public LockStoreInfo createNew(final ObjectNamespace key) {
              final MapContainer mapContainer = getMapContainer(key.getObjectName());
              return new LockStoreInfo() {
                public int getBackupCount() {
                  return mapContainer.getBackupCount();
                }

                public int getAsyncBackupCount() {
                  return mapContainer.getAsyncBackupCount();
                }
              };
            }
          });
    }
    mapEvictionManager.init();
  }
 public void clearPartition() {
   final LockService lockService =
       mapService.getNodeEngine().getSharedService(LockService.SERVICE_NAME);
   if (lockService != null) {
     lockService.clearLockStore(
         partitionId, new DefaultObjectNamespace(MapService.SERVICE_NAME, name));
   }
   final IndexService indexService = mapContainer.getIndexService();
   if (indexService.hasIndex()) {
     for (Data key : records.keySet()) {
       indexService.removeEntryIndex(key);
     }
   }
   cancelAssociatedSchedulers(records.keySet());
   clearRecordsMap(Collections.<Data, Record>emptyMap());
   resetSizeEstimator();
   resetAccessSequenceNumber();
 }
Example #4
0
 @Override
 public void clearPartition() {
   final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
   final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
   if (lockService != null) {
     final DefaultObjectNamespace namespace =
         new DefaultObjectNamespace(MapService.SERVICE_NAME, name);
     lockService.clearLockStore(partitionId, namespace);
   }
   final IndexService indexService = mapContainer.getIndexService();
   if (indexService.hasIndex()) {
     for (Data key : records.keySet()) {
       indexService.removeEntryIndex(key);
     }
   }
   clearRecordsMap(Collections.<Data, Record>emptyMap());
   resetSizeEstimator();
   resetAccessSequenceNumber();
   mapDataStore.clear();
 }
 public DefaultRecordStore(String name, MapService mapService, int partitionId) {
   this.name = name;
   this.partitionId = partitionId;
   this.mapService = mapService;
   this.mapContainer = mapService.getMapContainer(name);
   this.logger = mapService.getNodeEngine().getLogger(this.getName());
   recordFactory = mapContainer.getRecordFactory();
   NodeEngine nodeEngine = mapService.getNodeEngine();
   final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
   this.lockStore =
       lockService == null
           ? null
           : lockService.createLockStore(
               partitionId, new DefaultObjectNamespace(MapService.SERVICE_NAME, name));
   this.sizeEstimator = SizeEstimators.createMapSizeEstimator();
   final int mapLoadChunkSize = nodeEngine.getGroupProperties().MAP_LOAD_CHUNK_SIZE.getInteger();
   final Queue<Map> chunks = new LinkedList<Map>();
   if (nodeEngine
       .getThisAddress()
       .equals(nodeEngine.getPartitionService().getPartitionOwner(partitionId))) {
     if (mapContainer.getStore() != null && !loaded.get()) {
       Map<Data, Object> loadedKeys = mapContainer.getInitialKeys();
       if (loadedKeys != null && !loadedKeys.isEmpty()) {
         Map<Data, Object> partitionKeys = new HashMap<Data, Object>();
         Iterator<Map.Entry<Data, Object>> iterator = loadedKeys.entrySet().iterator();
         while (iterator.hasNext()) {
           final Map.Entry<Data, Object> entry = iterator.next();
           final Data data = entry.getKey();
           if (partitionId == nodeEngine.getPartitionService().getPartitionId(data)) {
             partitionKeys.put(data, entry.getValue());
             // split into chunks
             if (partitionKeys.size() >= mapLoadChunkSize) {
               chunks.add(partitionKeys);
               partitionKeys = new HashMap<Data, Object>();
             }
             iterator.remove();
           }
         }
         if (!partitionKeys.isEmpty()) {
           chunks.add(partitionKeys);
         }
         if (!chunks.isEmpty()) {
           try {
             Map<Data, Object> chunkedKeys;
             final AtomicInteger checkIfMapLoaded = new AtomicInteger(chunks.size());
             while ((chunkedKeys = chunks.poll()) != null) {
               nodeEngine
                   .getExecutionService()
                   .submit("hz:map-load", new MapLoadAllTask(chunkedKeys, checkIfMapLoaded));
             }
           } catch (Throwable t) {
             throw ExceptionUtil.rethrow(t);
           }
         } else {
           loaded.set(true);
         }
       } else {
         loaded.set(true);
       }
     }
   } else {
     loaded.set(true);
   }
 }