Exemplo n.º 1
0
  @Test
  public void testGC2() throws Exception {
    int reduceSize = 500;
    int gcRuns = PictureTilingCacheGCManager.getGCRuns();
    int gcCalls = PictureTilingCacheGCManager.getGCCalls();
    PictureTilingComponent.endGC();

    String maxStr =
        PictureTilingComponent.getEnvValue(
            PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KEY,
            Long.toString(PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KB));
    PictureTilingComponent.setEnvValue(
        PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KEY, Integer.toString(reduceSize));

    PictureTilingService pts = Framework.getLocalService(PictureTilingService.class);
    assertNotNull(pts);
    benchTiler(pts, new MagickTiler());

    // System.out.println("Tiling run 1");
    testMagick2();
    // System.out.println("Tiling run 2");
    testMagick2();
    // System.out.println("Tiling run 3");
    testMagick2();

    long cacheSize = PictureTilingCacheGCManager.getCacheSizeInKBs();
    // System.out.println("CacheSize = " + cacheSize + "KB");
    assertTrue(cacheSize > 0);

    GCTask.setGCIntervalInMinutes(-100);
    PictureTilingComponent.startGC();

    // System.out.println("waiting for GC to run");
    Thread.currentThread().sleep(600);

    int gcRuns2 = PictureTilingCacheGCManager.getGCRuns();
    int gcCalls2 = PictureTilingCacheGCManager.getGCCalls();

    int runs = gcRuns2 - gcRuns;
    int calls = gcCalls2 - gcCalls;
    // System.out.println("GC runs = " + runs);
    // System.out.println("GC calls = " + calls);

    assertTrue(runs > 0);
    assertTrue(calls > 2);

    PictureTilingComponent.endGC();

    long newCacheSize = PictureTilingCacheGCManager.getCacheSizeInKBs();
    // System.out.println("new cacheSize = " + newCacheSize + "KB");
    // System.out.println("effective delta = " + (cacheSize - newCacheSize)
    // + "KB");
    assertTrue(cacheSize - newCacheSize > reduceSize);

    PictureTilingComponent.setEnvValue(
        PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KEY, maxStr);
  }
Exemplo n.º 2
0
  @Before
  public void setUp() throws Exception {
    super.setUp();
    deployContrib("org.nuxeo.ecm.platform.pictures.tiles", "OSGI-INF/pictures-tiles-framework.xml");
    deployBundle("org.nuxeo.ecm.platform.commandline.executor");

    deployContrib(
        "org.nuxeo.ecm.platform.picture.core", "OSGI-INF/commandline-imagemagick-contrib.xml");
    PictureTilingComponent.getCache().clear();
    PictureTilingComponent.setDefaultTiler(new MagickTiler());
    PictureTilingComponent.endGC();
  }
Exemplo n.º 3
0
 @After
 public void setDown() {
   PictureTilingComponent.endGC();
 }