コード例 #1
0
  public void testMemoryConsumption() throws InterruptedException {
    DefaultCacheManager cm = new DefaultCacheManager(true);

    Cache<Object, Object> cache = cm.getCache();

    long freeMemBefore = freeMemKb();
    System.out.println("freeMemBefore = " + freeMemBefore);

    for (int i = 0; i < 1024 * 300; i++) {
      cache.put(i, i);
    }
    System.out.println("Free meme after: " + freeMemKb());
    System.out.println("Consumed memory: " + (freeMemBefore - freeMemKb()));
    cm.stop();
    for (int i = 0; i < 10; i++) {
      System.gc();
      if (isOkay(freeMemBefore)) {
        break;
      } else {
        Thread.sleep(1000);
      }
    }
    System.out.println("Free memory at the end:" + freeMemKb());
    assert isOkay(freeMemBefore);
  }
コード例 #2
0
ファイル: TestComposite.java プロジェクト: bleujin/craken
  public void testRun() throws Exception {
    String wsName = "test";
    DefaultCacheManager dcm = new DefaultCacheManager();
    Cache<String, Metadata> metaCache = dcm.getCache("meta");
    Cache<String, byte[]> dataCache = dcm.getCache("data");

    GridFilesystem gfs = new GridFilesystem(dataCache, metaCache);

    BuildContext bcontext =
        DirectoryBuilder.newDirectoryInstance(metaCache, dataCache, metaCache, wsName);
    bcontext.chunkSize(1024 * 1024);
    Directory directory = bcontext.create();
    Central central = CentralConfig.oldFromDir(directory).build();

    central.newIndexer().index(IndexJobs.create("/bleujin", 10));

    central.newSearcher().createRequest("").find().debugPrint();

    OutputStream output = gfs.getOutput("/test.data");
    IOUtil.copyNClose(new StringInputStream("hello bleujin"), output);

    Debug.line(IOUtil.toStringWithClose(gfs.getInput("/test.data")));

    central.newSearcher().createRequest("").find().debugPrint();

    File root = gfs.getFile("/");
    viewFile(root);

    dcm.stop();
  }
コード例 #3
0
 public static void main(String[] args) throws IOException {
   DefaultCacheManager cacheManager =
       new DefaultCacheManager("config-samples/lucene-demo-cache-config.xml");
   cacheManager.start();
   try {
     Cache<?, ?> cache = cacheManager.getCache();
     InfinispanDirectory directory = new InfinispanDirectory(cache);
     DemoDriver driver = new DemoDriver(directory, cache);
     driver.run();
   } finally {
     cacheManager.stop();
   }
 }
  @Override
  public synchronized void deleted(String pid) {
    ServiceRegistration<EmbeddedCacheManager> serviceRegistration =
        managedRegistrations.remove(pid);
    if (serviceRegistration != null) {
      try {
        serviceRegistration.unregister();
      } catch (Exception e) {
      }
    }

    DefaultCacheManager cacheManager = cacheManagers.remove(pid);
    if (cacheManager != null) {
      try {
        cacheManager.stop();
      } catch (Exception e) {
      }
    }
  }
コード例 #5
0
  public static synchronized void releaseServer() {
    --count;
    if (count <= 0) {

      try {
        if (CACHEMANAGER != null) {
          CACHEMANAGER.stop();
        }
      } finally {
        CACHEMANAGER = null;
      }

      try {
        // System.out.println("Stopping HotRot Server at " + hostAddress() + ":" + hostPort());
        if (server != null) {
          server.stop();
        }
      } finally {
        server = null;
      }
    }
  }
コード例 #6
0
 @PreDestroy
 public void cleanUp() {
   manager.stop();
   manager = null;
 }
 @AfterClass
 public static void stopCacheManagers() {
   PRECONFIGURED_DEFAULT_CACHE_MANAGER.stop();
   DEFAULT_CACHE_MANAGER.stop();
 }