Package org.olat.core.util.coordinate

Examples of org.olat.core.util.coordinate.SyncerExecutor


  /**
   * Private constructor, use getInstance() instead
   */
  private ContextHelpManager() {
    // Do in sync with other VM's
    CoordinatorManager.getCoordinator().getSyncer().doInSync(contextHelpRatingEventBus,new SyncerExecutor(){
      public void execute() {
      // Load statistics from disk (no database access in core)   
      File systemDir = new File(WebappHelper.getUserDataRoot(), SYSTEM_DIR);
      contextHelpRatingFile = new File(systemDir, CONTEXT_HELP_RATING_XML);
     
View Full Code Here


  @Deprecated
  public void storePageRating(final UserRequest ureq, final Locale locale, final String bundleName, final String page, final float rating) {
    final String key = calculateCombinedKey(locale, bundleName, page);
    final Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    // 1) Update community rating
    CoordinatorManager.getCoordinator().getSyncer().doInSync(contextHelpRatingEventBus,new SyncerExecutor(){
      public void execute() {
        Object[] statsValues = contextHelpRatings.get(key);
        if (statsValues == null) {
          // create new data object for this page
          statsValues = new Object[2];
View Full Code Here

  //FIXME: VFSItem should be capable of returning an identifier, instead of casting to LocalFolderImpl implement a getIdentifier for it!
  @SuppressWarnings("unchecked")
  public ArrayList<GlossaryItem> getGlossaryItemListByVFSItem(final VFSContainer glossaryFolder){   
    final String glossaryKey = ((LocalFolderImpl)glossaryFolder).getBasefile().toString();
    if (glossaryCache == null) {
      CoordinatorManager.getCoordinator().getSyncer().doInSync(glossaryEventBus, new SyncerExecutor() {
        public void  execute() {
          if (glossaryCache == null) {
            glossaryCache = CoordinatorManager.getCoordinator().getCacher().getOrCreateCache(this.getClass(), "glossary");
          }
        }
      });
    }
    //try to load from cache
    ArrayList<GlossaryItem> glossaryItemList = (ArrayList<GlossaryItem>) glossaryCache.get(glossaryKey);
    if (glossaryItemList != null){
      if (isLogDebugEnabled()){
        logDebug("Loading glossary from cache.", null);
      }
      return glossaryItemList;
    }
    // load from filesystem
    CoordinatorManager.getCoordinator().getSyncer().doInSync(glossaryEventBus, new SyncerExecutor() {
      @SuppressWarnings("synthetic-access")
      public void execute() {
        ArrayList<GlossaryItem> glossaryItemListTemp = new ArrayList<GlossaryItem>();
        if (isLogDebugEnabled()){
          logDebug("Loading glossary from filesystem. Glossary folder: " + glossaryFolder, null);
View Full Code Here

     */
  public Wiki getOrLoadWiki(final OLATResourceable ores) {
    final String wikiKey = OresHelper.createStringRepresenting(ores);
    //cluster_OK by guido
    if (wikiCache == null) {
      CoordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
        public void  execute() {
          if (wikiCache == null) {
            wikiCache = CoordinatorManager.getCoordinator().getCacher().getOrCreateCache(this.getClass(), "wiki");
          }
        }
      });
    }
    Wiki wiki = (Wiki) wikiCache.get(wikiKey);
    if (wiki != null) {
      log.debug("loading wiki from cache. Ores: " + ores.getResourceableId());
      return wiki;
    }
    // No wiki in cache => load it form file-system
    CoordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
      public void execute() {

        long start = 0;
        // wiki not in cache load form filesystem
        if (log.isDebug()) {
View Full Code Here

   * That's where caching comes in. We'll store the URL as the key and give it a
   * boolean value whether access has been successfully granted or not.
   */
  public void cache(OLATResourceable ores, final boolean accessible) {
    final String key = getKey();
    CoordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
      public void execute() {
        if (validatedUriCache.get(key) == null) {
          validatedUriCache.put(key, accessible);
        } else {
          validatedUriCache.update(key, accessible);
View Full Code Here

  }

  public void run() {
    //o_clusterOK by guido
    OLATResourceable syncOres = OresHelper.createOLATResourceableInstance("GroupChatJoinTask",ores.getResourceableId());
    CoordinatorManager.getCoordinator().getSyncer().doInSync(syncOres, new SyncerExecutor() {
      public void execute() {
        if (connection != null && connection.isAuthenticated()) {
          try {
            RoomInfo info = MultiUserChat.getRoomInfo(connection, roomJID);
            // throws an exception if the room does not exists
View Full Code Here

  @Override
  protected void event(UserRequest ureq, Component source, Event event) {
    if (source == syncLong) {
      // sync on a olatresourceable and hold the lock for 5 seconds.
      CoordinatorManager.getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor(){
        public void execute() {
          sleep(5000);
        }});
      // the runnable is executed within the same thread->
      getWindowControl().setInfo("done syncing on the test olatresourceable for 5 seconds");
    } else if (source == syncShort) {
      // sync on a olatresourceable and hold the lock for 1 second.
      CoordinatorManager.getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor(){
        public void execute() {
          sleep(1000);
        }});
      // the runnable is executed within the same thread->
      getWindowControl().setInfo("done syncing on the test olatresourceable for 1 second");
    } else if (source == testPerf) {
      // send 1000 (short) messages over the cluster bus
      int cnt = 1000;
      long start = System.nanoTime();
      for (int i = 0; i < cnt; i++) {
        clusBus.fireEventToListenersOf(new MultiUserEvent("jms-perf-test-"+i+" of "+cnt),ORES_TEST);
      }
      long stop = System.nanoTime();
      long dur = stop-start;
      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();
      for (int i = 0; i < cnt; i++) {
        CoordinatorManager.getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor(){
          public void execute() {
            // empty
          }});
      }
      long stop = System.nanoTime();
View Full Code Here

      for (Iterator iter = list.iterator(); iter.hasNext();) {
        final DialogElement element = (DialogElement) iter.next();
        if (element.getForumKey().equals(forumKey)) {         
          //o_clusterOK by:ld
          OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(DialogCourseNode.class, new Long(courseNode.getIdent()));
          CoordinatorManager.getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerExecutor(){
            public void execute() {
            list.remove(element);
            String dialogElementsAsXML = XStreamHelper.toXML(elements);
            Property property = coursePropMgr.findCourseNodeProperty(courseNode, null, null, PROPERTY_NAME);
View Full Code Here

   * @param fileDialogId
   */
  public void addDialogElement(final CoursePropertyManager coursePropMgr, final CourseNode courseNode, final DialogElement element) {
    //o_clusterOK by:ld (it was assumed that the courseNodeId - used for constructing  the olatResourceable - is unique over all courses)
    OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(DialogCourseNode.class, new Long(courseNode.getIdent()));
    CoordinatorManager.getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerExecutor(){
      public void execute() {
        DialogPropertyElements dialogProps = findDialogElements(coursePropMgr, courseNode);

        dialogProps.addElement(element);
        String dialogElementsAsXML = XStreamHelper.toXML(dialogProps);
View Full Code Here

    this.macartneyVC = new VelocityContainer("macartneyVC", VELOCITY_ROOT + "/macartneyPortlet.html", trans, this);

    if (comicStartDate == 0) {
      CoordinatorManager.getCoordinator().getSyncer().doInSync(
          OresHelper.createOLATResourceableType(MacartneyPortletRunController.class.getSimpleName()),
          new SyncerExecutor() {

            @SuppressWarnings("synthetic-access")
            public void execute() {
              if (comicStartDate!=0) {
                // then we shouldn't have gotten here in the first place, but we were
View Full Code Here

TOP

Related Classes of org.olat.core.util.coordinate.SyncerExecutor

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.