Package org.olat.core.util.cache.n

Examples of org.olat.core.util.cache.n.CacheWrapper


 
  public CacheWrapper getOrCreateChildCacheWrapper(OLATResourceable ores) {
    String childName = OresHelper.createStringRepresenting(ores).replace(":", "_");
    String fullcacheName = cacheName + "@" + childName;
    synchronized(this) {//cluster_ok by definition of this class as used in single vm
      CacheWrapper cwChild = null;
      if (children == null) {
        children = new HashMap<String, CacheWrapper>();
      } else {
        cwChild = children.get(childName);
      }
View Full Code Here


      double inmilis = dur / 1000000;
      double avg = dur / cnt;
      double avgmilis = avg / 1000000;
      getWindowControl().setInfo("sending "+cnt+" messages took "+inmilis+" ms, avg per messages was "+avg+" ns = "+avgmilis+" ms");
    } else if (source == testCachePut) {
      CacheWrapper cw = CoordinatorManager.getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest").
        getOrCreateChildCacheWrapper(ORES_CACHE_TEST);
      // we explicitly use put and not putSilent to show that a put invalidates (and thus removes) this key of this cache in all other cluster nodes.
      cw.update("akey", "hello");
      updateCacheInfo();
    } else if (source == testCachePut2) {
      // we explicitly use put and not putSilent to show that a put invalidates (and thus removes) this key of this cache in all other cluster nodes.
      CacheWrapper cw = CoordinatorManager.getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest").
        getOrCreateChildCacheWrapper(ORES_CACHE_TEST);
      cw.update("akey", "world");
      updateCacheInfo();
    } else if (source == testSFUPerf) {
      // acquire a sync 1000x times (does internally a select-for-update on the database)
      int cnt = 1000;
      long start = System.nanoTime();
View Full Code Here

      // ignore
    }
  }
 
  void updateCacheInfo() {
    CacheWrapper cw = CoordinatorManager.getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest").
    getOrCreateChildCacheWrapper(ORES_CACHE_TEST);
    Object val = cw.get("akey");
    cachetest.contextPut("cacheval", val==null? "-null-": val);
    // org.olat.commons.coordinate.cluster.jms.ClusterAdminController:cachetest::0@subcachetypetest::123
  }
View Full Code Here

   * @param identity the identity
   * @param notify if true, then the
   * @return a Map containing nodeident+"_"+ e.g. PASSED as key, Boolean (for PASSED), Float (for SCORE), or Integer (for ATTEMPTS) as values
   */
  private Map<String, Serializable> getOrLoadScorePassedAttemptsMap(Identity identity, boolean prepareForNewData) {
    CacheWrapper cw = getCacheWrapperFor(identity);
    synchronized(cw) {  // o_clusterOK by:fj : we sync on the cache to protect access within the monitor "one user in a course".
      // a user is only active on one node at the same time.
      Map<String, Serializable> m = (Map<String, Serializable>) cw.get(FULLUSERSET);
      if (m == null) {
        // cache entry (=all data of the given identity in this course) has expired or has never been stored yet into the cache.
        // or has been invalidated (in cluster mode when puts occurred from an other node for the same cache)
        m = new HashMap<String, Serializable>();
        // load data
        List properties = loadPropertiesFor(identity);
        for (Iterator iter = properties.iterator(); iter.hasNext();) {
          Property property = (Property) iter.next();
          addPropertyToCache(m, property);
        }
        // we use a putSilent here (no invalidation notifications to other cluster nodes), since
        // we did not generate new data, but simply asked to reload it.
        if (prepareForNewData) {
          cw.update(FULLUSERSET, (Serializable) m);
        } else {
          cw.put(FULLUSERSET, (Serializable) m);
        }
      } else {
        // still in cache.
        if (prepareForNewData) { // but we need to notify that data has changed: we reput the data into the cache - a little hacky yes
          cw.update(FULLUSERSET, (Serializable) m);
        }
      }
      return m;
    }
  }
View Full Code Here

  }
 
  private CacheWrapper getCacheWrapperFor(Identity identity) {
    // the ores is only for within the cache
    OLATResourceable ores = OresHelper.createOLATResourceableInstanceWithoutCheck("Identity", identity.getKey());
    CacheWrapper cw = courseCache.getOrCreateChildCacheWrapper(ores);
    return cw;
  }
View Full Code Here

TOP

Related Classes of org.olat.core.util.cache.n.CacheWrapper

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.