コード例 #1
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;
 }
コード例 #2
0
  /**
   * Initializes all mocks needed to execute a query operation.
   *
   * @param nodeResultLimit configures the result size limit, use <code>Long.MAX_VALUE</code> to
   *     disable feature
   * @param numberOfReturnedQueryEntries configures the number of returned entries of the query
   *     operation
   */
  protected void initMocks(long nodeResultLimit, int numberOfReturnedQueryEntries) {
    for (int i = 0; i < numberOfReturnedQueryEntries; i++) {
      QueryableEntry queryableEntry = mock(QueryableEntry.class);
      when(queryableEntry.getKeyData()).thenAnswer(randomDataAnswer);
      when(queryableEntry.getIndexKey()).thenAnswer(randomDataAnswer);
      when(queryableEntry.getValueData()).thenAnswer(randomDataAnswer);

      queryEntries.add(queryableEntry);
      queryEntrySet.add(queryableEntry);
    }

    QueryResult queryResult = new QueryResult(nodeResultLimit);

    when(mapContextQuerySupport.newQueryResult(anyInt())).thenReturn(queryResult);
    when(mapContextQuerySupport.queryOnPartition(
            MAP_NAME, TruePredicate.INSTANCE, Operation.GENERIC_PARTITION_ID))
        .thenReturn(queryEntries);

    IndexService indexService = mock(IndexService.class);
    when(indexService.query(TruePredicate.INSTANCE)).thenReturn(queryEntrySet);

    MapConfig mapConfig = mock(MapConfig.class);
    when(mapConfig.isStatisticsEnabled()).thenReturn(false);

    MapServiceContext mapServiceContext = mock(MapServiceContext.class);
    when(mapServiceContext.getMapContextQuerySupport()).thenReturn(mapContextQuerySupport);

    MapService mapService = mock(MapService.class);
    when(mapService.getMapServiceContext()).thenReturn(mapServiceContext);

    queryOperation.mapService = mapService;

    MapContainer mapContainer = mock(MapContainer.class);
    when(mapContainer.getIndexService()).thenReturn(indexService);
    when(mapContainer.getMapConfig()).thenReturn(mapConfig);

    queryOperation.mapContainer = mapContainer;

    InternalPartitionService partitionService = mock(InternalPartitionService.class);
    when(partitionService.getPartitionStateVersion()).thenReturn(0);
    when(partitionService.hasOnGoingMigrationLocal()).thenReturn(false);

    NodeEngine nodeEngine = mock(NodeEngine.class);
    when(nodeEngine.getPartitionService()).thenReturn(partitionService);

    queryOperation.setNodeEngine(nodeEngine);
  }