コード例 #1
0
 public static void logPartitionStatistics(
     ILogger log, String basename, IMap<Object, Integer> map, boolean printSizes) {
   MapProxyImpl mapProxy = (MapProxyImpl) map;
   MapService mapService = (MapService) mapProxy.getService();
   MapServiceContext mapServiceContext = mapService.getMapServiceContext();
   Collection<Integer> localPartitions = mapServiceContext.getOwnedPartitions();
   int localSize = 0;
   StringBuilder partitionIDs = new StringBuilder();
   StringBuilder partitionSizes = new StringBuilder();
   String separator = "";
   for (int partitionId : localPartitions) {
     int partitionSize = mapServiceContext.getRecordStore(partitionId, map.getName()).size();
     localSize += partitionSize;
     partitionIDs.append(separator).append(partitionId);
     partitionSizes.append(separator).append(partitionSize);
     separator = ", ";
   }
   log.info(
       format(
           "%s: Local partitions (count %d) (size %d) (avg %.2f) (IDs %s)%s",
           basename,
           localPartitions.size(),
           localSize,
           localSize / (float) localPartitions.size(),
           partitionIDs.toString(),
           printSizes ? format(" (sizes %s)", partitionSizes.toString()) : ""));
 }
コード例 #2
0
 private boolean isEvictionEnabled(IMap map) {
   MapProxyImpl mapProxy = (MapProxyImpl) map;
   MapService mapService = (MapService) mapProxy.getService();
   MapServiceContext mapServiceContext = (MapServiceContext) mapService.getMapServiceContext();
   MapContainer mapContainer = mapServiceContext.getMapContainer(map.getName());
   EvictionPolicy evictionPolicy = mapContainer.getMapConfig().getEvictionPolicy();
   return evictionPolicy != NONE;
 }
コード例 #3
0
 private boolean isRecordStoreExpirable(IMap map) {
   MapProxyImpl mapProxy = (MapProxyImpl) map;
   MapService mapService = (MapService) mapProxy.getService();
   MapServiceContext mapServiceContext = (MapServiceContext) mapService.getMapServiceContext();
   PartitionContainer container = mapServiceContext.getPartitionContainer(0);
   RecordStore recordStore = container.getExistingRecordStore(map.getName());
   return recordStore.isExpirable();
 }
コード例 #4
0
  @Test(timeout = 120000)
  public void testReadingConfiguration() throws Exception {
    String mapName = "mapstore-test";
    InputStream is =
        getClass().getResourceAsStream("/com/hazelcast/config/hazelcast-mapstore-config.xml");
    XmlConfigBuilder builder = new XmlConfigBuilder(is);
    Config config = builder.build();
    HazelcastInstance hz = createHazelcastInstance(config);
    MapProxyImpl map = (MapProxyImpl) hz.getMap(mapName);
    MapService mapService = (MapService) map.getService();
    MapContainer mapContainer = mapService.getMapServiceContext().getMapContainer(mapName);
    MapStoreWrapper mapStoreWrapper = mapContainer.getMapStoreContext().getMapStoreWrapper();
    Iterator keys = mapStoreWrapper.loadAllKeys().iterator();

    final Set<String> loadedKeySet = loadedKeySet(keys);
    final Set<String> expectedKeySet = expectedKeySet();

    assertEquals(expectedKeySet, loadedKeySet);

    assertEquals("true", mapStoreWrapper.load("my-prop-1"));
    assertEquals("foo", mapStoreWrapper.load("my-prop-2"));
  }