예제 #1
0
  private void doTest(boolean strict) {
    EmbeddedCacheManager cm1 = null, cm2 = null;
    try {
      Configuration c = new Configuration();
      c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
      GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
      gc.setStrictPeerToPeer(strict);

      cm1 = TestCacheManagerFactory.createCacheManager(gc, c);
      cm2 = TestCacheManagerFactory.createCacheManager(gc, c);

      cm1.getCache();
      cm2.getCache();

      cm1.getCache().put("k", "v");
      assert "v".equals(cm1.getCache().get("k"));
      assert "v".equals(cm2.getCache().get("k"));

      cm1.defineConfiguration("newCache", c);

      if (strict) {
        try {
          cm1.getCache("newCache").put("k", "v");
          assert false : "Should have failed!";
        } catch (CacheException e) {
          assert e.getCause() instanceof NamedCacheNotFoundException;
        }
      } else {
        cm1.getCache("newCache").put("k", "v");
        assert "v".equals(cm1.getCache("newCache").get("k"));
      }
    } finally {
      TestingUtil.killCacheManagers(cm1, cm2);
    }
  }
예제 #2
0
 private static EmbeddedCacheManager createCacheManagerProgramatically() {
   return new DefaultCacheManager(
       GlobalConfiguration.getClusteredDefault()
           .fluent()
           .transport()
           .addProperty("configurationFile", "jgroups.xml")
           .build(),
       new Configuration().fluent().clustering().mode(REPL_SYNC).build());
 }
 @Override
 protected EmbeddedCacheManager createCacheManager() throws Exception {
   Configuration cfg = new Configuration();
   cfg.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
   cfg.setUseReplQueue(true);
   cfg.setReplQueueClass(TestReplQueueClass.class.getName());
   EmbeddedCacheManager ecm =
       TestCacheManagerFactory.createCacheManager(GlobalConfiguration.getClusteredDefault(), cfg);
   return ecm;
 }
 @Override
 protected EmbeddedCacheManager addClusterEnabledCacheManager(Configuration deConfiguration) {
   int index = cacheManagers.size();
   String rack;
   String machine;
   switch (index) {
     case 0:
       {
         rack = "r0";
         machine = "m0";
         break;
       }
     case 1:
       {
         rack = "r0";
         machine = "m1";
         break;
       }
     case 2:
       {
         rack = "r1";
         machine = "m0";
         break;
       }
     case 3:
       {
         rack = "r2";
         machine = "m0";
         break;
       }
     case 4:
       {
         rack = "r2";
         machine = "m0";
         break;
       }
     default:
       {
         throw new RuntimeException("Bad!");
       }
   }
   GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
   gc.setRackId(rack);
   gc.setMachineId(machine);
   EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(gc, deConfiguration);
   cacheManagers.add(cm);
   return cm;
 }
예제 #5
0
  protected EmbeddedCacheManager createCacheManager() throws Exception {
    GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
    gc.setAsyncTransportExecutorFactoryClass(WTE.class.getName());
    cacheManager = TestCacheManagerFactory.createCacheManager(gc);

    cacheManager.defineConfiguration(LOCAL_CACHE_NAME, getBaseCfg());

    cacheManager.defineConfiguration(REPL_SYNC_CACHE_NAME, getClusteredCfg(REPL_SYNC, false));
    cacheManager.defineConfiguration(REPL_ASYNC_CACHE_NAME, getClusteredCfg(REPL_ASYNC, false));
    cacheManager.defineConfiguration(DIST_SYNC_CACHE_NAME, getClusteredCfg(DIST_SYNC, false));
    cacheManager.defineConfiguration(DIST_ASYNC_CACHE_NAME, getClusteredCfg(DIST_ASYNC, false));
    cacheManager.defineConfiguration(DIST_SYNC_L1_CACHE_NAME, getClusteredCfg(DIST_SYNC, true));
    cacheManager.defineConfiguration(DIST_ASYNC_L1_CACHE_NAME, getClusteredCfg(DIST_ASYNC, true));

    return cacheManager;
  }