Package com.tangosol.net

Examples of com.tangosol.net.NamedCache


  }

  private Object getCacheElement(int keyAndModelIndex) throws Exception {
    KeyAndModel keyAndModel = getKeyAndModel(keyAndModelIndex);
    CoherenceCachingModel model = (CoherenceCachingModel) keyAndModel.model;
    NamedCache cache = TangosolUtils.getNamedCache(model.getCacheName());
    return cache.get(keyAndModel.key);
  }
View Full Code Here


  /**
   * @see AbstractCacheProviderFacade#onGetFromCache(Serializable,CachingModel)
   */
  protected Object onGetFromCache(Serializable key, CachingModel model)
      throws CacheException {
    NamedCache cache = getCache(model);
    return cache.get(key);
  }
View Full Code Here

   */
  protected void onPutInCache(Serializable key, CachingModel model, Object obj)
      throws CacheException {
    CoherenceCachingModel coherenceCachingModel = (CoherenceCachingModel) model;
    String name = coherenceCachingModel.getCacheName();
    NamedCache cache = getCache(name);

    Long timeToLive = coherenceCachingModel.getTimeToLive();
    if (timeToLive != null) {
      cache.put(key, obj, timeToLive.longValue());
    } else {
      cache.put(key, obj);
    }
  }
View Full Code Here

   * @see AbstractCacheProviderFacade#onRemoveFromCache(Serializable,
   *CachingModel)
   */
  protected void onRemoveFromCache(Serializable key, CachingModel model)
      throws CacheException {
    NamedCache cache = getCache(model);
    cache.remove(key);
  }
View Full Code Here

     * Create a new cache.
     *
     * @param name a name for the cache, which should be unique per vm.
     */
    protected ClusteredCache(String name) {
        NamedCache cache = com.tangosol.net.CacheFactory.getCache(name);
        init(name, cache);
    }
View Full Code Here

            }
            map.put(env.mark.getExecutionID(), env.mark);
          }
         
          for(Map.Entry<String, Map<Long, CommandExecutionMark>> entry: buf.entrySet()) {
            NamedCache cache = CacheFactory.getCache(entry.getKey());
            cache.putAll(entry.getValue());
          }
        }
      } catch (InterruptedException e) {
        e.printStackTrace();
        System.exit(1);
View Full Code Here

    long rangeStart;
    long rangeFinish;
   
        @Override
        public void run() {
            final NamedCache cache = CacheFactory.getCache(cacheName);
            final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator();
           
            println("Loading " + (rangeFinish - rangeStart) + " objects ...");
            for(long i = rangeStart;  i < rangeFinish; i += 100) {
                if (i % 100000 == 0) {
                    println("Done " + (i - rangeStart));
                }
                long j = Math.min(rangeFinish, i + 100);
                cache.putAll(generator.generate(i, j));
            }          
           
        }
View Full Code Here

//      System.setProperty("benchmark-default-scheme", "partitioned-true-external-distributed-scheme");
      System.setProperty("benchmark-default-scheme", "partitioned-false-external-distributed-scheme");
//      System.setProperty("benchmark-default-scheme", "simple-replicated-scheme");
     
    try {
      final NamedCache cache = CacheFactory.getCache("objects");
      final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator();
   
//      cache.addIndex(new ReflectionExtractor("getA0"), false, null);
//      cache.addIndex(new ReflectionExtractor("getAs"), false, null);     
     
//      System.out.println(CacheFactory.getClusterConfig().toString());
     
      long objectCount = 1000000;
//      long objectCount = 100000;
     
      long rangeStart = 1000000;
      long rangeFinish = 1000000 + objectCount;
     
      println("Loading " + objectCount + " objects ...");
      for(long i = rangeStart;  i < rangeFinish; i += 100) {
          if (i % 100000 == 0) {
              println("Done " + (i - rangeStart));
          }
          long j = Math.min(rangeFinish, i + 100);
          cache.putAll(generator.generate(i, j));
      }     
     
      println("Loaded " + cache.size() + " objects");
      System.gc();
      println("Mem. usage " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage());

//      checkAccess(cache, new EqualsFilter("getA0", new DomainObjAttrib("?")));
//      checkAccess(cache, new EqualsFilter("getAs", Collections.EMPTY_LIST));
View Full Code Here

//      System.setProperty("benchmark-default-scheme", "replicated-near-scheme");
     
      //ExecutorService executor = Executors.newCachedThreadPool();
     
    try {
      final NamedCache cache = CacheFactory.getCache("objects");
//      final Map map = cache;
//      final Map map = new ContinuousQueryCache(cache, new ClassFilter(DomainObject.class), true);
//      final Map map = new ConcurrentHashMap();
//      final Map map = new HashMap();
      final Map map = new ConcurrentSkipListMap();
//      final Map map = Collections.synchronizedMap(new HashMap());
      final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator();
   
//      cache.addIndex(new ReflectionExtractor("getA0"), false, null);
//      cache.addIndex(new ReflectionExtractor("getAs"), false, null);     
     
//      long objectCount = 1000000;
      long objectCount = 100000;
     
      long rangeStart = 0;
      long rangeFinish = objectCount;
     
      println("Loading " + objectCount + " objects ...");
      for(long i = rangeStart;  i < rangeFinish; i += 100) {
          if (i % 100000 == 0) {
              println("Done " + (i - rangeStart));
          }
          long j = Math.min(rangeFinish, i + 100);
          map.putAll(generator.generate(i, j));
      }     
     
      println("Loaded " + cache.size() + " objects");
      System.gc();
      println("Mem. usage " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage());

//      checkAccess(cache, new EqualsFilter("getA0", new DomainObjAttrib("?")));
//      checkAccess(cache, new EqualsFilter("getAs", Collections.EMPTY_LIST));
View Full Code Here

        System.setProperty("tangosol.coherence.distributed.localstorage", "true");
       
        System.setProperty("benchmark-default-scheme", "read-through-distributed-scheme");
       
        try {
            final NamedCache cache = CacheFactory.getCache("objects");
           
            Object[] keys = {"A", "B", "C"};           
            getKeys(cache, Arrays.asList(keys));
           
            List list = new ArrayList();
            for(int i = 0; i != 100; ++i) {
                list.add(String.valueOf(i));
            }
           
            cache.clear();
            getKeys(cache, list);    
            cache.clear();
            preloadKeys(cache, list);
           
           
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of com.tangosol.net.NamedCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.