From 4d5ab6f46bf3755b5e59eb32dd0375fc5b19d017 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Tue, 18 Dec 2012 16:31:19 +0100 Subject: [PATCH] OO-449: move from ehcache to infinispan to have access to a distributed cache in a cluster environment, fix some issues with a cluster environment --- pom.xml | 100 ++++---- .../olat/admin/cache/AllCachesController.java | 175 +++++++------- .../cache/_i18n/LocalStrings_de.properties | 1 + .../org/olat/admin/jmx/CacheInitMBean.java | 48 ---- .../JBossTreeCacheJmxRegistrationManager.java | 77 ------ .../org/olat/basesecurity/AuthHelper.java | 2 +- .../org/olat/bookmark/BookmarkImpl.hbm.xml | 2 +- .../org/olat/catalog/CatalogEntryImpl.hbm.xml | 2 +- .../jms/ClusterAdminControllerCluster.java | 9 +- .../coordinate/cluster/lock/LockImpl.hbm.xml | 3 +- .../info/model/InfoMessageImpl.hbm.xml | 2 +- .../commons/servlets/WebDAVManagerImpl.java | 3 +- .../org/olat/core/CoreSpringInitializer.java | 5 + .../JpaInfinispanRegionFactory.java | 47 ++++ .../_spring/databaseCorecontext.xml | 39 ++- .../impl/UserCommentImpl.hbm.xml | 2 +- .../impl/UserRatingImpl.hbm.xml | 2 +- .../services/mark/impl/MarkImpl.hbm.xml | 2 +- .../services/tagging/model/TagImpl.hbm.xml | 2 +- .../mapper/manager/MapperServiceImpl.java | 4 +- .../mapper/model/PersistedMapper.hbm.xml | 2 +- src/main/java/org/olat/core/gui/Windows.java | 12 +- .../java/org/olat/core/helpers/Settings.java | 4 + .../java/org/olat/core/util/SessionInfo.java | 11 +- .../java/org/olat/core/util/UserSession.java | 14 +- .../olat/core/util/cache/n/CacheConfig.java | 29 +-- .../olat/core/util/cache/n/CacheWrapper.java | 23 +- .../util/cache/n/InfinispanCacheManager.java | 82 +++++++ ...rImpl.java => InfinispanCacheWrapper.java} | 118 ++++----- ...gleVMCacher.java => InfinispanCacher.java} | 24 +- .../cluster/ClusterCacheWrapperEvent.java | 70 ------ .../impl/cluster/ClusterCacheWrapperImpl.java | 103 -------- .../cache/n/impl/cluster/ClusterCacher.java | 160 ------------ .../cache/n/impl/cluster/ClusterConfig.java | 2 + .../org/olat/core/util/coordinate/Cacher.java | 4 +- .../org/olat/core/util/prefs/db/DbPrefs.java | 7 +- .../core/util/session/UserSessionManager.java | 17 +- .../_spring/threadlogCorecontext.xml | 8 +- .../NewCachePersistingAssessmentManager.java | 2 + .../model/UserCourseInfosImpl.hbm.xml | 2 +- .../model/UserEfficiencyStatementImpl.hbm.xml | 2 +- .../org/olat/group/BusinessGroupImpl.hbm.xml | 4 +- .../org/olat/group/area/BGAreaImpl.hbm.xml | 2 +- .../group/area/BGtoAreaRelationImpl.hbm.xml | 2 +- .../group/context/BGContext2Resource.hbm.xml | 2 - .../olat/group/context/BGContextImpl.hbm.xml | 2 - .../group/model/BGResourceRelation.hbm.xml | 2 +- .../BusinessGroupMembershipViewImpl.hbm.xml | 2 +- .../group/model/BusinessGroupViewImpl.hbm.xml | 2 +- .../modules/webFeed/managers/FeedManager.java | 6 +- .../webFeed/managers/FeedManagerImpl.java | 26 +- .../modules/webFeed/ui/ItemsController.java | 6 +- .../olat/repository/MetaDataElement.hbm.xml | 2 +- .../olat/repository/RepositoryEntry.hbm.xml | 4 +- .../olat/resource/OLATResourceImpl.hbm.xml | 2 +- .../lock/pessimistic/PLockImpl.hbm.xml | 2 - .../resource/references/ReferenceImpl.hbm.xml | 2 +- src/main/java/org/olat/user/UserImpl.hbm.xml | 2 +- .../database/mysql/setupDatabase.sql | 38 +++ src/main/resources/ehcache.xml | 129 ---------- src/main/resources/infinispan-config.xml | 87 +++++++ .../resources/serviceconfig/olat.properties | 8 + .../org/olat/_spring/olatextconfig.xml | 13 +- .../org/olat/core/_spring/olatcoreconfig.xml | 116 +++------ src/main/resources/treecache.xml | 228 ------------------ .../WEB-INF/jboss-deployment-structure.xml | 5 + src/main/webapp-jbossas7/WEB-INF/web.xml | 2 +- .../dispatcher/mapper/MapperServiceTest.java | 3 +- .../course/nodes/feed/FunctionalBlogTest.java | 11 +- .../modules/webFeed/FeedManagerImplTest.java | 2 +- 70 files changed, 689 insertions(+), 1246 deletions(-) delete mode 100644 src/main/java/org/olat/admin/jmx/CacheInitMBean.java delete mode 100644 src/main/java/org/olat/admin/jmx/JBossTreeCacheJmxRegistrationManager.java create mode 100644 src/main/java/org/olat/core/commons/persistence/JpaInfinispanRegionFactory.java create mode 100644 src/main/java/org/olat/core/util/cache/n/InfinispanCacheManager.java rename src/main/java/org/olat/core/util/cache/n/{impl/svm/CacheWrapperImpl.java => InfinispanCacheWrapper.java} (57%) rename src/main/java/org/olat/core/util/cache/n/{impl/svm/SingleVMCacher.java => InfinispanCacher.java} (75%) delete mode 100644 src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacheWrapperEvent.java delete mode 100644 src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacheWrapperImpl.java delete mode 100644 src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacher.java delete mode 100644 src/main/resources/ehcache.xml create mode 100644 src/main/resources/infinispan-config.xml delete mode 100644 src/main/resources/treecache.xml diff --git a/pom.xml b/pom.xml index 19646505c6b..79043bcd8b7 100644 --- a/pom.xml +++ b/pom.xml @@ -70,6 +70,7 @@ <jackson.version>1.9.2</jackson.version> <org.mysql.version>5.1.21</org.mysql.version> <org.postgresql.version>9.1-901.jdbc4</org.postgresql.version> + <org.infinispan.version>5.1.6.FINAL</org.infinispan.version> <!-- properties for testing and Q&A --> <!-- by default no tests are executed so far (April 2011). Use appropriate profiles and properties on the command line --> @@ -190,7 +191,7 @@ </dependency> <dependency> <groupId>org.hibernate</groupId> - <artifactId>hibernate-ehcache</artifactId> + <artifactId>hibernate-infinispan</artifactId> <version>${org.hibernate.version}</version> </dependency> <dependency> @@ -205,6 +206,34 @@ </exclusion> </exclusions> </dependency> + + <dependency> + <groupId>org.infinispan</groupId> + <artifactId>infinispan-core</artifactId> + <version>${org.infinispan.version}</version> + <exclusions> + <exclusion> + <groupId>org.jboss.spec.javax.transaction</groupId> + <artifactId>jboss-transaction-api_1.1_spec</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>woodstox-core-asl</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>stax2-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.rhq.helpers</groupId> + <artifactId>rhq-pluginAnnotations</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>mysql</groupId> @@ -333,7 +362,7 @@ </dependency> <dependency> <groupId>org.hibernate</groupId> - <artifactId>hibernate-ehcache</artifactId> + <artifactId>hibernate-infinispan</artifactId> <version>${org.hibernate.version}</version> </dependency> <dependency> @@ -898,41 +927,7 @@ </dependency> </dependencies> </profile> - - <!-- Retain the dependency for cluster --> - <profile> - <id>cluster</id> - <activation> - <property> - <name>cluster</name> - </property> - </activation> - <dependencies> - <dependency> - <groupId>org.jboss</groupId> - <artifactId>jboss-common-core</artifactId> - <version>2.2.8.GA</version> - </dependency> - <dependency> - <groupId>org.jboss.logging</groupId> - <artifactId>jboss-logging-spi</artifactId> - <version>2.0.5.GA</version> - </dependency> - <dependency> - <groupId>org.jboss.cache</groupId> - <artifactId>jbosscache-core</artifactId> - <version>3.2.2.GA</version> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-jbosscache2</artifactId> - <version>3.3.2.GA</version> - <scope>runtime</scope> - </dependency> - </dependencies> - </profile> - <profile> <id>arquillian</id> <properties> @@ -1006,7 +1001,7 @@ <repository> <id>jboss-public-repository-group</id> <name>JBoss Public Maven Repository Group</name> - <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url> + <url>https://repository.jboss.org/nexus/content/groups/public/</url> <layout>default</layout> <releases> <enabled>true</enabled> @@ -1743,9 +1738,32 @@ <version>1.0.3</version> </dependency> <dependency> - <groupId>net.sf.ehcache</groupId> - <artifactId>ehcache-core</artifactId> - <version>2.4.3</version> + <groupId>org.infinispan</groupId> + <artifactId>infinispan-core</artifactId> + <version>${org.infinispan.version}</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.jboss.spec.javax.transaction</groupId> + <artifactId>jboss-transaction-api_1.1_spec</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>woodstox-core-asl</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>stax2-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.rhq.helpers</groupId> + <artifactId>rhq-pluginAnnotations</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> @@ -1767,7 +1785,7 @@ </dependency> <dependency> <groupId>org.hibernate</groupId> - <artifactId>hibernate-ehcache</artifactId> + <artifactId>hibernate-infinispan</artifactId> <version>${org.hibernate.version}</version> <scope>test</scope> </dependency> diff --git a/src/main/java/org/olat/admin/cache/AllCachesController.java b/src/main/java/org/olat/admin/cache/AllCachesController.java index 7e63fc8ee00..4d9904ae5da 100644 --- a/src/main/java/org/olat/admin/cache/AllCachesController.java +++ b/src/main/java/org/olat/admin/cache/AllCachesController.java @@ -26,11 +26,12 @@ package org.olat.admin.cache; import java.util.List; +import java.util.Set; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; - +import org.infinispan.Cache; +import org.infinispan.manager.EmbeddedCacheManager; +import org.infinispan.stats.Stats; +import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.Component; import org.olat.core.gui.components.table.DefaultColumnDescriptor; @@ -47,9 +48,10 @@ import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.core.gui.control.generic.modal.DialogBoxController; import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory; -import org.olat.core.logging.AssertException; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; +import org.olat.core.util.coordinate.Cacher; +import org.olat.core.util.coordinate.CoordinatorManager; /** * Description:<BR/> @@ -67,12 +69,9 @@ public class AllCachesController extends BasicController { private VelocityContainer myContent; private TableController tableCtr; private TableDataModel<String> tdm; - private CacheManager cm; - private final String[] cnames; + private EmbeddedCacheManager cm; private DialogBoxController dc; - - /** * @param ureq * @param wControl @@ -87,35 +86,41 @@ public class AllCachesController extends BasicController { tableConfig.setDownloadOffered(true); tableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator()); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.name", 0, null, ureq.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.disk", 1, null, ureq.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.hitcnt", 2, null, ureq.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcexp", 3, null, ureq.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcnotfound", 4, null, ureq.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.quickcount", 5, null, ureq.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.tti", 6, null, ureq.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.ttl", 7, null, ureq.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.maxElements", 8, null, ureq.getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.name", 0, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.disk", 1, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.hitcnt", 2, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcexp", 3, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcnotfound", 4, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.quickcount", 5, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.tti", 6, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.ttl", 7, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.maxElements", 8, null, getLocale())); + tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.clustered", 9, null, getLocale())); tableCtr.addColumnDescriptor(new StaticColumnDescriptor("empty", "cache.empty", translate("action.choose"))); listenTo(tableCtr); myContent.contextPut("title", translate("caches.title")); // eh cache + String[] cnames; try { - cm = CacheManager.getInstance(); - } catch (CacheException e) { - throw new AssertException("could not get cache", e); + CoordinatorManager coordinator = CoreSpringFactory.getImpl(CoordinatorManager.class); + Cacher cacher = coordinator.getCoordinator().getCacher(); + + cm = cacher.getCacheContainer(); + Set<String> cacheNameSet = cm.getCacheNames(); + cnames = cacheNameSet.toArray(new String[cacheNameSet.size()]); + } catch (Exception e) { + log.error("", e); + cnames = new String[0]; } - cnames = cm.getCacheNames(); - tdm = new AllCachesTableDataModel(cnames); + + tdm = new AllCachesTableDataModel(cnames, cm); tableCtr.setTableDataModel(tdm); myContent.put("cachetable", tableCtr.getInitialComponent()); //returned panel is not needed here, because this controller only shows content with the index.html velocity page putInitialPanel(myContent); - } - /** * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event) @@ -130,34 +135,24 @@ public class AllCachesController extends BasicController { TableEvent te = (TableEvent) event; String actionid = te.getActionId(); if (actionid.equals("empty")) { - int rowid = te.getRowId(); - String cname = cnames[rowid]; - Cache toEmpty = cm.getCache(cname); - - //provide dc as argument, this ensures that dc is disposed before newly created + Object cname = tableCtr.getTableDataModel().getObject(te.getRowId()); dc = activateYesNoDialog(ureq, null, translate("confirm.emptycache"), dc); - //remember Cache to be emptied if yes is chosen - dc.setUserObject(toEmpty); - //activateYesNoDialog means that this controller listens to it, and dialog is shown on screen. - //nothing further to do here! - return; + dc.setUserObject(cname); } } - } - else if (source == dc) { + } else if (source == dc) { //the dialogbox is already removed from the gui stack - do not use getWindowControl().pop(); to remove dialogbox if (DialogBoxUIFactory.isYesEvent(event)) { // ok String cacheName = null; try { // delete cache - Cache c = (Cache)dc.getUserObject(); - cacheName = c.getName(); - c.removeAll(); + cacheName = (String)dc.getUserObject(); + cm.getCache(cacheName).clear(); } catch (IllegalStateException e) { // ignore log.error("Cannot remove Cache:"+cacheName, e); } - // update tablemodel + }//else no was clicked or dialog box was cancelled (close icon clicked) } } @@ -166,58 +161,58 @@ public class AllCachesController extends BasicController { * @see org.olat.core.gui.control.DefaultController#doDispose(boolean) */ protected void doDispose() { - //tableCtr is registerd with listenTo and gets disposed in BasicController - //dialogbox dc gets disposed by BasicController + // } -} - -class AllCachesTableDataModel implements TableDataModel<String> { - private String[] cnames; - private CacheManager cacheManager; - - protected AllCachesTableDataModel(String[] cnames) { - this.cnames = cnames; - this.cacheManager = CacheManager.getInstance(); - } + private static class AllCachesTableDataModel implements TableDataModel<String> { + private String[] cnames; + private EmbeddedCacheManager cacheManager; + + protected AllCachesTableDataModel(String[] cnames, EmbeddedCacheManager cacheManager) { + this.cnames = cnames; + this.cacheManager = cacheManager; + } + + @Override + public String getObject(int row) { + return cnames[row]; + } - @Override - public String getObject(int row) { - return cnames[row]; - } - - @Override - public void setObjects(List<String> objects) { - cnames = objects.toArray(cnames); - } - - @Override - public AllCachesTableDataModel createCopyWithEmptyList() { - return new AllCachesTableDataModel(new String[0]); - } - - public int getColumnCount() { - return 9; - } - - public int getRowCount() { - return cnames.length; - } - - public Object getValueAt(int row, int col) { - String cname = cnames[row]; - Cache c = cacheManager.getCache(cname); - switch(col) { - case 0: return cname; - case 1: return c.getCacheConfiguration().isDiskPersistent()? Boolean.TRUE:Boolean.FALSE; - case 2: return new Long(c.getLiveCacheStatistics().getCacheHitCount()); - case 3: return new Long(c.getLiveCacheStatistics().getCacheMissCountExpired()); - case 4: return new Long(c.getLiveCacheStatistics().getCacheMissCount()); - case 5: return new Long(c.getKeysNoDuplicateCheck().size()); - case 6: return new Long(c.getCacheConfiguration().getTimeToIdleSeconds()); - case 7: return new Long(c.getCacheConfiguration().getTimeToLiveSeconds()); - case 8: return new Long(c.getCacheConfiguration().getMaxElementsInMemory()); - default: throw new AssertException("nonexisting column:"+col); + @Override + public void setObjects(List<String> objects) { + cnames = objects.toArray(cnames); + } + + @Override + public AllCachesTableDataModel createCopyWithEmptyList() { + return new AllCachesTableDataModel(new String[0], cacheManager); + } + + public int getColumnCount() { + return 9; + } + + public int getRowCount() { + return cnames.length; + } + + public Object getValueAt(int row, int col) { + String cname = cnames[row]; + Cache<?,?> c = cacheManager.getCache(cname); + Stats stats = c.getAdvancedCache().getStats(); + switch(col) { + case 0: return cname; + case 1: return c.getCacheConfiguration().storeAsBinary().enabled() ? Boolean.TRUE:Boolean.FALSE; + case 2: return new Long(stats.getHits()); + case 3: return new Long(stats.getMisses()); + case 4: return "???"; + case 5: return new Long(stats.getTotalNumberOfEntries()); + case 6: return new Long(c.getCacheConfiguration().expiration().maxIdle()); + case 7: return new Long(c.getCacheConfiguration().expiration().lifespan()); + case 8: return new Integer(c.getCacheConfiguration().eviction().maxEntries()); + case 9: return c.getCacheConfiguration().clustering().cacheModeString(); + default: return ""; + } } } } \ No newline at end of file diff --git a/src/main/java/org/olat/admin/cache/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/admin/cache/_i18n/LocalStrings_de.properties index 8a428c81ecd..4e38aae4242 100644 --- a/src/main/java/org/olat/admin/cache/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/admin/cache/_i18n/LocalStrings_de.properties @@ -10,5 +10,6 @@ cache.name=Name cache.quickcount=~ Elemente cache.tti=Time to idle (sec) cache.ttl=Time to live (sec) +cache.clustered=Clustered caches.title=\u00DCbersicht der EHCaches (easy hibernate Caches) confirm.emptycache=Wollen Sie alle Eintr\u00E4ge dieses Cache l\u00F6schen? diff --git a/src/main/java/org/olat/admin/jmx/CacheInitMBean.java b/src/main/java/org/olat/admin/jmx/CacheInitMBean.java deleted file mode 100644 index 272c3eea9c1..00000000000 --- a/src/main/java/org/olat/admin/jmx/CacheInitMBean.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.admin.jmx; - -import javax.management.MBeanServer; - -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.management.ManagementService; - -/** - * @author Christian Guretzki - */ -public class CacheInitMBean { - private MBeanServer server; - - public void setServer(MBeanServer server) { - this.server = server; - register(); - } - - private void register() { - // register ehcache as MBean - ManagementService.registerMBeans(CacheManager.getInstance(), server, true, true, true, true); - } - -} diff --git a/src/main/java/org/olat/admin/jmx/JBossTreeCacheJmxRegistrationManager.java b/src/main/java/org/olat/admin/jmx/JBossTreeCacheJmxRegistrationManager.java deleted file mode 100644 index 43d8e7cf3f9..00000000000 --- a/src/main/java/org/olat/admin/jmx/JBossTreeCacheJmxRegistrationManager.java +++ /dev/null @@ -1,77 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -* <p> -*/ - -package org.olat.admin.jmx; - -import javax.management.MBeanServer; - -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; - -/** - * Helper class to register all JBoss Tree Cache MBeans at JMX Server. - * - * @author Christian Guretzki - */ -public class JBossTreeCacheJmxRegistrationManager { - OLog log = Tracing.createLoggerFor(this.getClass()); - - private MBeanServer server; - - public JBossTreeCacheJmxRegistrationManager() { - // - } - /** - * Register StatisticsService as MBean for JMX support. - * @param <Cache> - * @param mySessionFactory - */ - private <Cache> void registerAllJBossTreeCacheMBeans() { - /* fxdiff: FXOLAT-243 - try { - log.info("start to register all JBoss Treecache MBeans..."); - CacheFactory factory = new DefaultCacheFactory(); - Cache cache = factory.createCache("treecache.xml"); - ObjectName cacheObjectName = new ObjectName("jboss.cache:service=Cache"); - JmxRegistrationManager jmxRegistrationManager = new JmxRegistrationManager(server, cache, cacheObjectName ); - jmxRegistrationManager.registerAllMBeans(); - log.info("registered all JBoss Treecache MBeans"); - } catch (MalformedObjectNameException e) { - log.warn("JMX-Error : Can not register as MBean, MalformedObjectNameException=", e); - } catch (NoSuchBeanDefinitionException e) { - log.warn("JMX-Error : Can not register as MBean, NoSuchBeanDefinitionException=", e); - } - */ - } - - - public void setServer(MBeanServer server) { - this.server = server; - registerAllJBossTreeCacheMBeans(); - } - - -} diff --git a/src/main/java/org/olat/basesecurity/AuthHelper.java b/src/main/java/org/olat/basesecurity/AuthHelper.java index 83cf66bcd7f..2c56eae6c06 100644 --- a/src/main/java/org/olat/basesecurity/AuthHelper.java +++ b/src/main/java/org/olat/basesecurity/AuthHelper.java @@ -494,7 +494,7 @@ public class AuthHelper { */ public static void setSessionInfoFor(Identity identity, String authProvider, UserRequest ureq, boolean rest) { HttpSession session = ureq.getHttpReq().getSession(); - SessionInfo sinfo = new SessionInfo(identity.getName(), session); + SessionInfo sinfo = new SessionInfo(identity.getKey(), identity.getName(), session); sinfo.setFirstname(identity.getUser().getProperty(UserConstants.FIRSTNAME, ureq.getLocale())); sinfo.setLastname(identity.getUser().getProperty(UserConstants.LASTNAME, ureq.getLocale())); sinfo.setFromIP(ureq.getHttpReq().getRemoteAddr()); diff --git a/src/main/java/org/olat/bookmark/BookmarkImpl.hbm.xml b/src/main/java/org/olat/bookmark/BookmarkImpl.hbm.xml index 94670c26fcd..ef8646876de 100644 --- a/src/main/java/org/olat/bookmark/BookmarkImpl.hbm.xml +++ b/src/main/java/org/olat/bookmark/BookmarkImpl.hbm.xml @@ -6,7 +6,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.bookmark.BookmarkImpl" table="o_bookmark"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" column="bookmark_id" type="long" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/catalog/CatalogEntryImpl.hbm.xml b/src/main/java/org/olat/catalog/CatalogEntryImpl.hbm.xml index 339de1044bc..ad9eb53638e 100644 --- a/src/main/java/org/olat/catalog/CatalogEntryImpl.hbm.xml +++ b/src/main/java/org/olat/catalog/CatalogEntryImpl.hbm.xml @@ -7,7 +7,7 @@ <class name="org.olat.catalog.CatalogEntryImpl" table="o_catentry"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" column="id" type="long" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/commons/coordinate/cluster/jms/ClusterAdminControllerCluster.java b/src/main/java/org/olat/commons/coordinate/cluster/jms/ClusterAdminControllerCluster.java index 64959180833..64f724845ac 100644 --- a/src/main/java/org/olat/commons/coordinate/cluster/jms/ClusterAdminControllerCluster.java +++ b/src/main/java/org/olat/commons/coordinate/cluster/jms/ClusterAdminControllerCluster.java @@ -255,15 +255,13 @@ public class ClusterAdminControllerCluster extends BasicController { 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.getInstance().getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest"). - getOrCreateChildCacheWrapper(ORES_CACHE_TEST); + CacheWrapper cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest"); // 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.getInstance().getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest"). - getOrCreateChildCacheWrapper(ORES_CACHE_TEST); + CacheWrapper cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest"); cw.update("akey", "world"); updateCacheInfo(); } else if (source == testSFUPerf) { @@ -357,8 +355,7 @@ public class ClusterAdminControllerCluster extends BasicController { } void updateCacheInfo() { - CacheWrapper cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest"). - getOrCreateChildCacheWrapper(ORES_CACHE_TEST); + CacheWrapper cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getOrCreateCache(this.getClass(), "cachetest"); Object val = cw.get("akey"); cachetest.contextPut("cacheval", val==null? "-null-": val); // org.olat.commons.coordinate.cluster.jms.ClusterAdminController:cachetest::0@subcachetypetest::123 diff --git a/src/main/java/org/olat/commons/coordinate/cluster/lock/LockImpl.hbm.xml b/src/main/java/org/olat/commons/coordinate/cluster/lock/LockImpl.hbm.xml index d6f29756f17..ff18104e42a 100644 --- a/src/main/java/org/olat/commons/coordinate/cluster/lock/LockImpl.hbm.xml +++ b/src/main/java/org/olat/commons/coordinate/cluster/lock/LockImpl.hbm.xml @@ -4,8 +4,7 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-lazy="false"> <class name="org.olat.commons.coordinate.cluster.lock.LockImpl" table="oc_lock"> - - <!-- <cache usage="read-write" />--> + <id name="key" type="long" column="lock_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/commons/info/model/InfoMessageImpl.hbm.xml b/src/main/java/org/olat/commons/info/model/InfoMessageImpl.hbm.xml index 9647d60616d..d9bf54d6503 100644 --- a/src/main/java/org/olat/commons/info/model/InfoMessageImpl.hbm.xml +++ b/src/main/java/org/olat/commons/info/model/InfoMessageImpl.hbm.xml @@ -4,7 +4,7 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-lazy="false"> <class name="org.olat.commons.info.model.InfoMessageImpl" table="o_info_message"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="info_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/commons/servlets/WebDAVManagerImpl.java b/src/main/java/org/olat/commons/servlets/WebDAVManagerImpl.java index b209d96d635..ec62b54bd4a 100644 --- a/src/main/java/org/olat/commons/servlets/WebDAVManagerImpl.java +++ b/src/main/java/org/olat/commons/servlets/WebDAVManagerImpl.java @@ -35,7 +35,6 @@ import javax.servlet.http.HttpServletResponse; import org.olat.admin.user.delete.service.UserDeletionManager; import org.olat.basesecurity.BaseSecurityManager; import org.olat.basesecurity.BaseSecurityModule; -import org.olat.core.CoreSpringFactory; import org.olat.core.id.Identity; import org.olat.core.id.Roles; import org.olat.core.id.User; @@ -191,7 +190,7 @@ public class WebDAVManagerImpl extends WebDAVManager { //usess.getIdentityEnvironment().setAuthProvider(OLATAuthenticationController.PROVIDER_OLAT); // set session info - SessionInfo sinfo = new SessionInfo(identity.getName(), request.getSession()); + SessionInfo sinfo = new SessionInfo(identity.getKey(), identity.getName(), request.getSession()); User usr = identity.getUser(); sinfo.setFirstname(usr.getProperty(UserConstants.FIRSTNAME, null)); sinfo.setLastname(usr.getProperty(UserConstants.LASTNAME, null)); diff --git a/src/main/java/org/olat/core/CoreSpringInitializer.java b/src/main/java/org/olat/core/CoreSpringInitializer.java index 5514f547a0f..c352d062954 100644 --- a/src/main/java/org/olat/core/CoreSpringInitializer.java +++ b/src/main/java/org/olat/core/CoreSpringInitializer.java @@ -19,6 +19,8 @@ */ package org.olat.core; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.springframework.context.ApplicationContextInitializer; import org.springframework.core.env.PropertySource; import org.springframework.web.context.ConfigurableWebApplicationContext; @@ -32,6 +34,8 @@ import org.springframework.web.context.ConfigurableWebApplicationContext; * */ public class CoreSpringInitializer implements ApplicationContextInitializer<ConfigurableWebApplicationContext> { + + private static final OLog log = Tracing.createLoggerFor(CoreSpringInitializer.class); public void initialize(ConfigurableWebApplicationContext ctx) { //detect activemq @@ -42,6 +46,7 @@ public class CoreSpringInitializer implements ApplicationContextInitializer<Conf } catch (ClassNotFoundException e) { jmsProvider = "jndi"; } + log.info("Bootstrapping spring startup"); PropertySource<String> ps = new OpenOLATProperties(jmsProvider); ctx.getEnvironment().getPropertySources().addFirst(ps); } diff --git a/src/main/java/org/olat/core/commons/persistence/JpaInfinispanRegionFactory.java b/src/main/java/org/olat/core/commons/persistence/JpaInfinispanRegionFactory.java new file mode 100644 index 00000000000..0f7f812bccc --- /dev/null +++ b/src/main/java/org/olat/core/commons/persistence/JpaInfinispanRegionFactory.java @@ -0,0 +1,47 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.core.commons.persistence; + +import java.util.Properties; + +import org.hibernate.cache.infinispan.InfinispanRegionFactory; +import org.hibernate.cfg.Settings; +import org.infinispan.transaction.lookup.DummyTransactionManagerLookup; + +/** + * In single VM mode, start Infinispan for Hibernate with a dummy transaction + * manager + * + * Initial date: 14.12.2012<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class JpaInfinispanRegionFactory extends InfinispanRegionFactory { + + private static final long serialVersionUID = -6314447275230674708L; + + @Override + protected org.infinispan.transaction.lookup.TransactionManagerLookup createTransactionManagerLookup( + Settings settings, Properties properties) { + return new DummyTransactionManagerLookup(); + } + + +} diff --git a/src/main/java/org/olat/core/commons/persistence/_spring/databaseCorecontext.xml b/src/main/java/org/olat/core/commons/persistence/_spring/databaseCorecontext.xml index bd4f79ba31d..d6e9394add4 100644 --- a/src/main/java/org/olat/core/commons/persistence/_spring/databaseCorecontext.xml +++ b/src/main/java/org/olat/core/commons/persistence/_spring/databaseCorecontext.xml @@ -130,8 +130,11 @@ <prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop> <!-- for development phase only: --> <!-- end for development phase only --> - + <!-- --> <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop> + <!-- + <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</prop> + --> <prop key="hibernate.jdbc.batch_size">0</prop> <prop key="hibernate.jdbc.use_streams_for_binary">true</prop> <prop key="hibernate.use_outer_join">true</prop> @@ -147,23 +150,37 @@ <prop key="javax.persistence.lock.timeout">30000</prop> </props> </constructor-arg> - <property name="addMoreProperties" ref="hibernateCacheProps_${hibernate.cache}" /> + <property name="addMoreProperties" ref="hibernateCacheProps_${hibernate.cache}_${cluster.mode}" /> </bean> - <bean id="hibernateCacheProps_enabled" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification"> + <bean id="hibernateCacheProps_enabled_SingleVM" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification"> <constructor-arg> - <props> - <prop key="hibernate.cache.provider_class">${hibernate.caching.singlevm.class}</prop> - <prop key="hibernate.cache.use_query_cache">${hibernate.caching.use.query.cache}</prop> - <prop key="hibernate.cache.use_second_level_cache">${hibernate.use.second.level.cache}</prop> - <prop key="hibernate.cache.region.factory_class">${hibernate.caching.cluster.class}</prop> + <props> + <prop key="hibernate.cache.use_query_cache">true</prop> + <prop key="hibernate.cache.use_second_level_cache">true</prop> + <prop key="hibernate.cache.region.factory_class">org.olat.core.commons.persistence.JpaInfinispanRegionFactory</prop> + <prop key="hibernate.cache.infinispan.cfg">infinispan-SingleVM.xml</prop> <prop key="hibernate.cache.region.jbc2.query.localonly">true</prop> - <prop key="hibernate.cache.region_prefix">olat</prop> - </props> + <prop key="hibernate.cache.region_prefix">openolat</prop> + </props> + </constructor-arg> + </bean> + + <bean id="hibernateCacheProps_enabled_Cluster" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification"> + <constructor-arg> + <props> + <prop key="hibernate.cache.use_query_cache">true</prop> + <prop key="hibernate.cache.use_second_level_cache">true</prop> + <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.infinispan.JndiInfinispanRegionFactory</prop> + <prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</prop> + <prop key="hibernate.cache.infinispan.use_synchronization">false</prop> + <prop key="hibernate.cache.infinispan.cachemanager">java:jboss/infinispan/hibernate</prop> + </props> </constructor-arg> </bean> - <bean id="hibernateCacheProps_disabled" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification"> + <alias name="hibernateCacheProps_disabled_SingleVM" alias="hibernateCacheProps_disabled_Cluster"/> + <bean id="hibernateCacheProps_disabled_SingleVM" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification"> <constructor-arg> <props> <prop key="hibernate.cache.use_query_cache">false</prop> diff --git a/src/main/java/org/olat/core/commons/services/commentAndRating/impl/UserCommentImpl.hbm.xml b/src/main/java/org/olat/core/commons/services/commentAndRating/impl/UserCommentImpl.hbm.xml index 09a2ca0dfb4..b9943ca181f 100644 --- a/src/main/java/org/olat/core/commons/services/commentAndRating/impl/UserCommentImpl.hbm.xml +++ b/src/main/java/org/olat/core/commons/services/commentAndRating/impl/UserCommentImpl.hbm.xml @@ -5,7 +5,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.core.commons.services.commentAndRating.impl.UserCommentImpl" table="o_usercomment"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="comment_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/core/commons/services/commentAndRating/impl/UserRatingImpl.hbm.xml b/src/main/java/org/olat/core/commons/services/commentAndRating/impl/UserRatingImpl.hbm.xml index 4373b40ee83..43ff0bd4889 100644 --- a/src/main/java/org/olat/core/commons/services/commentAndRating/impl/UserRatingImpl.hbm.xml +++ b/src/main/java/org/olat/core/commons/services/commentAndRating/impl/UserRatingImpl.hbm.xml @@ -5,7 +5,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.core.commons.services.commentAndRating.impl.UserRatingImpl" table="o_userrating"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="rating_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/core/commons/services/mark/impl/MarkImpl.hbm.xml b/src/main/java/org/olat/core/commons/services/mark/impl/MarkImpl.hbm.xml index 89830f06f48..966c5728951 100644 --- a/src/main/java/org/olat/core/commons/services/mark/impl/MarkImpl.hbm.xml +++ b/src/main/java/org/olat/core/commons/services/mark/impl/MarkImpl.hbm.xml @@ -4,7 +4,7 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-lazy="false"> <class name="org.olat.core.commons.services.mark.impl.MarkImpl" table="o_mark"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="mark_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/core/commons/services/tagging/model/TagImpl.hbm.xml b/src/main/java/org/olat/core/commons/services/tagging/model/TagImpl.hbm.xml index 3e17aef314f..89253344330 100644 --- a/src/main/java/org/olat/core/commons/services/tagging/model/TagImpl.hbm.xml +++ b/src/main/java/org/olat/core/commons/services/tagging/model/TagImpl.hbm.xml @@ -4,7 +4,7 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-lazy="false"> <class name="org.olat.core.commons.services.tagging.model.TagImpl" table="o_tag"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="tag_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/core/dispatcher/mapper/manager/MapperServiceImpl.java b/src/main/java/org/olat/core/dispatcher/mapper/manager/MapperServiceImpl.java index 1de2c879587..4d745dab909 100644 --- a/src/main/java/org/olat/core/dispatcher/mapper/manager/MapperServiceImpl.java +++ b/src/main/java/org/olat/core/dispatcher/mapper/manager/MapperServiceImpl.java @@ -131,7 +131,9 @@ public class MapperServiceImpl implements MapperService { mapper = (Mapper)getMapperCache().get(id); if(mapper == null) { mapper = mapperDao.retrieveMapperById(id); - getMapperCache().put(id, (Serializable)mapper); + if(mapper != null) { + getMapperCache().put(id, (Serializable)mapper); + } } } return mapper; diff --git a/src/main/java/org/olat/core/dispatcher/mapper/model/PersistedMapper.hbm.xml b/src/main/java/org/olat/core/dispatcher/mapper/model/PersistedMapper.hbm.xml index 1dcda7f6316..6adc1fb9d1b 100644 --- a/src/main/java/org/olat/core/dispatcher/mapper/model/PersistedMapper.hbm.xml +++ b/src/main/java/org/olat/core/dispatcher/mapper/model/PersistedMapper.hbm.xml @@ -5,7 +5,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.core.dispatcher.mapper.model.PersistedMapper" table="o_mapper"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" column="id" type="long" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/core/gui/Windows.java b/src/main/java/org/olat/core/gui/Windows.java index bc88533c8da..fa0853a2778 100644 --- a/src/main/java/org/olat/core/gui/Windows.java +++ b/src/main/java/org/olat/core/gui/Windows.java @@ -26,6 +26,7 @@ package org.olat.core.gui; +import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -42,18 +43,19 @@ import org.olat.core.util.UserSession; * @author Felix Jost */ -public class Windows implements Disposable { +public class Windows implements Disposable, Serializable { + private static final long serialVersionUID = -106724331637750672L; private static final String SESSIONID_NAME_FOR_WINDOWS = Windows.class.getName(); - private FIFOMap<UriPrefixIdPair,Window> windows = new FIFOMap<UriPrefixIdPair,Window>(100); // one user may at most save 100 + private transient FIFOMap<UriPrefixIdPair,Window> windows = new FIFOMap<UriPrefixIdPair,Window>(100); // one user may at most save 100 // windows in a session private int windowId = 1; - private WindowManager windowManagerImpl; + private transient WindowManager windowManagerImpl; - private Map<String, Object> attributes = new HashMap<String, Object>(); + private transient Map<String, Object> attributes = new HashMap<String, Object>(); - private SlowBandWidthSimulator sbws; + private transient SlowBandWidthSimulator sbws; private Windows() { // private constructor diff --git a/src/main/java/org/olat/core/helpers/Settings.java b/src/main/java/org/olat/core/helpers/Settings.java index 66a1bf3b367..ebef2b90dfa 100644 --- a/src/main/java/org/olat/core/helpers/Settings.java +++ b/src/main/java/org/olat/core/helpers/Settings.java @@ -475,6 +475,10 @@ public class Settings implements Initializable, Destroyable, GenericEventListene Settings.applicationName = applicationName; } + public static int getNodeId() { + return nodeId; + } + public void setNodeId(int nodeId) { Settings.nodeId = nodeId; } diff --git a/src/main/java/org/olat/core/util/SessionInfo.java b/src/main/java/org/olat/core/util/SessionInfo.java index f3886a55d9d..1836053e892 100644 --- a/src/main/java/org/olat/core/util/SessionInfo.java +++ b/src/main/java/org/olat/core/util/SessionInfo.java @@ -38,6 +38,7 @@ import org.olat.core.gui.Windows; */ public class SessionInfo { + private Long identityKey; private String login; private HttpSession session; private String firstname; @@ -58,7 +59,8 @@ public class SessionInfo { * @param login * @param session */ - public SessionInfo(String login, HttpSession session) { + public SessionInfo(Long identityKey, String login, HttpSession session) { + this.identityKey = identityKey; setLogin(login); setSession(session); secure = false; @@ -86,6 +88,13 @@ public class SessionInfo { return secure; } + /** + * @return The primary key of the identity object + */ + public Long getIdentityKey() { + return identityKey; + } + /** * @return firstname of logged-in user */ diff --git a/src/main/java/org/olat/core/util/UserSession.java b/src/main/java/org/olat/core/util/UserSession.java index ee5a6f0b914..f6f9ca25ca7 100644 --- a/src/main/java/org/olat/core/util/UserSession.java +++ b/src/main/java/org/olat/core/util/UserSession.java @@ -74,18 +74,18 @@ public class UserSession implements HttpSessionBindingListener, GenericEventList private static final long serialVersionUID = 1975177605776990868L; // the environment (identity, locale, ..) of the identity - private IdentityEnvironment identityEnvironment; - private SessionInfo sessionInfo; - private Map<String,Object> store; + private transient IdentityEnvironment identityEnvironment; + private transient SessionInfo sessionInfo; + private transient Map<String,Object> store; /** * things to put into that should not be clear when signing on (e.g. remember url for a direct jump) */ - private Map<String,Object> nonClearedStore = new HashMap<String,Object>(); + private transient Map<String,Object> nonClearedStore = new HashMap<String,Object>(); private boolean authenticated = false; - private Preferences guiPreferences; - private EventBus singleUserSystemBus; + private transient Preferences guiPreferences; + private transient EventBus singleUserSystemBus; private List<String> chats; - private Stack<HistoryPoint> history = new Stack<HistoryPoint>(); + private transient Stack<HistoryPoint> history = new Stack<HistoryPoint>(); public UserSession() { init(); diff --git a/src/main/java/org/olat/core/util/cache/n/CacheConfig.java b/src/main/java/org/olat/core/util/cache/n/CacheConfig.java index 0917f08d99d..28f265bc5aa 100644 --- a/src/main/java/org/olat/core/util/cache/n/CacheConfig.java +++ b/src/main/java/org/olat/core/util/cache/n/CacheConfig.java @@ -27,9 +27,6 @@ package org.olat.core.util.cache.n; import java.util.Map; -import net.sf.ehcache.Cache; -import net.sf.ehcache.store.MemoryStoreEvictionPolicy; - import org.olat.core.id.OLATResourceable; import org.olat.core.util.resource.OresHelper; @@ -48,7 +45,7 @@ import org.olat.core.util.resource.OresHelper; public class CacheConfig { private int maxElementsInMemory = 10000; - private MemoryStoreEvictionPolicy memoryStoreEvictionPolicy = MemoryStoreEvictionPolicy.LRU; + //private MemoryStoreEvictionPolicy memoryStoreEvictionPolicy = MemoryStoreEvictionPolicy.LRU; private boolean overflowToDisk = false; private boolean diskPersistent = false; private String diskStorePath; @@ -68,7 +65,7 @@ public class CacheConfig { */ private CacheConfig(CacheConfig config) { this.maxElementsInMemory = config.maxElementsInMemory; - this.memoryStoreEvictionPolicy = config.memoryStoreEvictionPolicy; + //this.memoryStoreEvictionPolicy = config.memoryStoreEvictionPolicy; this.overflowToDisk = config.overflowToDisk; this.diskPersistent = config.diskPersistent; this.diskStorePath = config.diskStorePath; @@ -95,9 +92,9 @@ public class CacheConfig { * constants defined in EHCache's MemoryStoreEvictionPolicy class. * Default is "LRU". */ - public void setMemoryStoreEvictionPolicy(MemoryStoreEvictionPolicy memoryStoreEvictionPolicy) { + /*public void setMemoryStoreEvictionPolicy(MemoryStoreEvictionPolicy memoryStoreEvictionPolicy) { this.memoryStoreEvictionPolicy = memoryStoreEvictionPolicy; - } + }*/ /** * Set whether elements can overflow to disk when the in-memory cache @@ -164,13 +161,6 @@ public class CacheConfig { public void setChildrenConfig(Map<String, CacheConfig> childrenConfig) { this.childrenConfig = childrenConfig; } - - private Cache doCreateCache(String cacheName) { - return new Cache( - cacheName, this.maxElementsInMemory, this.memoryStoreEvictionPolicy, - this.overflowToDisk, this.diskStorePath, this.eternal, this.timeToLive, this.timeToIdle, - this.diskPersistent, this.diskExpiryThreadIntervalSeconds, null); - } public CacheConfig createConfigFor(OLATResourceable ores) { // we will first try to use the type together with the key for the lookup. if that fails, we lookup the config for the type. @@ -192,15 +182,6 @@ public class CacheConfig { // clone the config, so that it is independent. return new CacheConfig(cc); } - - /** - * creates a cache with this cache config (does not register it with the ehcache cachemanager). changing the config later does not affect already created caches, only cache created afterwards. - * @param cacheName - * @return - */ - public Cache createCache(String cacheName) { - return doCreateCache(cacheName); - } /** * Return Cache-name for given class and name @@ -208,7 +189,7 @@ public class CacheConfig { * @param name Cache-name * @return */ - public static String getCacheName(Class ownerClass, String name) { + public static String getCacheName(Class<?> ownerClass, String name) { String cacheName = ownerClass.getName(); if (name != null) { cacheName = cacheName +"_"+name; diff --git a/src/main/java/org/olat/core/util/cache/n/CacheWrapper.java b/src/main/java/org/olat/core/util/cache/n/CacheWrapper.java index 756aa8bbc40..30769b12863 100644 --- a/src/main/java/org/olat/core/util/cache/n/CacheWrapper.java +++ b/src/main/java/org/olat/core/util/cache/n/CacheWrapper.java @@ -40,7 +40,10 @@ import org.olat.core.id.OLATResourceable; * Initial Date: 03.10.2007 <br> * @author Felix Jost, http://www.goodsolutions.ch */ -public interface CacheWrapper { +public interface CacheWrapper<U> { + + + public boolean containsKey(U key); /** * @@ -48,7 +51,7 @@ public interface CacheWrapper { * @return the cache entry or null when the element has expired, never been put into yet, or removed due to max-size, * or a put in a different cluster node which led to an invalidate message */ - public Serializable get(String key); + public Serializable get(U key); /** * o_clusterREVIEW :pb review references @@ -61,7 +64,7 @@ public interface CacheWrapper { * @param key * @param value */ - public void update(String key, Serializable value); + public void update(U key, Serializable value); /** * use this put whenever you just fill up a cache from data which is already on the db or the filesystem. e.g. use it when you simply load some properties again into cache. @@ -85,21 +88,15 @@ public interface CacheWrapper { * @param value * */ - public void put(String key, Serializable value); - - /** - * puts several values at once into the cache. same as repeatably - * calling put(key, value), but more efficient. please use in favor of put if applicable. - * @param keys the array of keys - * @param values the array of values - */ - public void updateMulti(String[] keys, Serializable[] values); + public void put(U key, Serializable value); /** * removes a value from the cache. this method is thread-safe * @param key */ - public void remove(String key); + public void remove(U key); + + public int size(); /** * this method is thread safe. diff --git a/src/main/java/org/olat/core/util/cache/n/InfinispanCacheManager.java b/src/main/java/org/olat/core/util/cache/n/InfinispanCacheManager.java new file mode 100644 index 00000000000..acd16a2a604 --- /dev/null +++ b/src/main/java/org/olat/core/util/cache/n/InfinispanCacheManager.java @@ -0,0 +1,82 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.core.util.cache.n; + +import javax.naming.InitialContext; + +import org.infinispan.manager.DefaultCacheManager; +import org.infinispan.manager.EmbeddedCacheManager; +import org.olat.core.util.StringHelper; +import org.springframework.beans.factory.FactoryBean; + +/** + * The embbeded cache manager of infinispan + * + * + * Initial date: 17.12.2012<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class InfinispanCacheManager implements FactoryBean<EmbeddedCacheManager> { + + private String configuration; + private String jndiName; + private EmbeddedCacheManager cacheManager; + + + /** + * [used by Spring] + * @param configuration + */ + public void setConfiguration(String configuration) { + this.configuration = configuration; + } + + public void setJndiName(String jndiName) { + this.jndiName = jndiName; + } + + @Override + public EmbeddedCacheManager getObject() throws Exception { + if(cacheManager == null) { + if(StringHelper.containsNonWhitespace(jndiName)) { + InitialContext ctx = new InitialContext(); + cacheManager = (EmbeddedCacheManager)ctx.lookup(jndiName); + } else { + if(!StringHelper.containsNonWhitespace(configuration)) { + configuration = "infinispan-config.xml"; + } + cacheManager = new DefaultCacheManager(configuration); + cacheManager.start(); + } + } + return cacheManager; + } + + @Override + public Class<?> getObjectType() { + return EmbeddedCacheManager.class; + } + + @Override + public boolean isSingleton() { + return true; + } +} diff --git a/src/main/java/org/olat/core/util/cache/n/impl/svm/CacheWrapperImpl.java b/src/main/java/org/olat/core/util/cache/n/InfinispanCacheWrapper.java similarity index 57% rename from src/main/java/org/olat/core/util/cache/n/impl/svm/CacheWrapperImpl.java rename to src/main/java/org/olat/core/util/cache/n/InfinispanCacheWrapper.java index 684435d0b52..9560e1f1771 100644 --- a/src/main/java/org/olat/core/util/cache/n/impl/svm/CacheWrapperImpl.java +++ b/src/main/java/org/olat/core/util/cache/n/InfinispanCacheWrapper.java @@ -23,23 +23,23 @@ * under the Apache 2.0 license as the original file. * <p> */ -package org.olat.core.util.cache.n.impl.svm; +package org.olat.core.util.cache.n; import java.io.Serializable; import java.util.HashMap; import java.util.Map; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; - +import org.infinispan.Cache; +import org.infinispan.CacheException; +import org.infinispan.configuration.cache.Configuration; +import org.infinispan.configuration.cache.ConfigurationBuilder; +import org.infinispan.eviction.EvictionStrategy; +import org.infinispan.manager.EmbeddedCacheManager; +import org.infinispan.transaction.TransactionMode; import org.olat.core.id.OLATResourceable; import org.olat.core.logging.OLATRuntimeException; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; -import org.olat.core.util.cache.n.CacheConfig; -import org.olat.core.util.cache.n.CacheWrapper; import org.olat.core.util.resource.OresHelper; /** @@ -50,37 +50,43 @@ import org.olat.core.util.resource.OresHelper; * Initial Date: 03.10.2007 <br> * @author Felix Jost, http://www.goodsolutions.ch */ -public class CacheWrapperImpl implements CacheWrapper { - private static final OLog log = Tracing.createLoggerFor(CacheWrapperImpl.class); +public class InfinispanCacheWrapper implements CacheWrapper<Object> { + private static final OLog log = Tracing.createLoggerFor(InfinispanCacheWrapper.class); private final String cacheName; // the fully qualified name of the cache private final CacheConfig config; - private final CacheManager cachemanager; + private final EmbeddedCacheManager cachemanager; - private Cache cache; - private Map<String, CacheWrapper> children = null; + private Cache<Object,Serializable> cache; + private Map<String, CacheWrapper<Object>> children = null; /** * @param cache */ - protected CacheWrapperImpl(String cacheName, CacheConfig config) { + protected InfinispanCacheWrapper(String cacheName, CacheConfig config, EmbeddedCacheManager cachemanager) { + this.cachemanager = cachemanager; this.cacheName = cacheName; this.config = config; - this.cachemanager = CacheManager.getInstance(); - // now we need a cache which has appropriate (by configuration) values for cache configs such as ttl, tti, max elements and so on. - // next line needed since cache can also be initialized through ehcache.xml - if (cachemanager.cacheExists(cacheName)) { - this.cache = cachemanager.getCache(cacheName); - log.warn("using cache parameters from ehcache.xml for cache named '"+cacheName+"'"); - } else { - this.cache = config.createCache(cacheName); - try { - cachemanager.addCache(this.cache); - } - catch (CacheException e) { - throw new OLATRuntimeException("Problem when initializing the caches", e); + try { + // now we need a cache which has appropriate (by configuration) values for cache configs such as ttl, tti, max elements and so on. + // next line needed since cache can also be initialized through ehcache.xml + if(!cachemanager.cacheExists(cacheName)) { + Configuration conf = cachemanager.getCacheConfiguration(cacheName); + if(conf == null) { + ConfigurationBuilder builder = new ConfigurationBuilder(); + builder.eviction().strategy(EvictionStrategy.LRU); + builder.eviction().maxEntries(10000); + builder.expiration().maxIdle(900000); + builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); + builder.dataContainer().storeAsBinary().storeValuesAsBinary(false); + Configuration configurationOverride = builder.build(); + cachemanager.defineConfiguration(cacheName, configurationOverride); + } } + cache = cachemanager.getCache(cacheName); + } catch (Exception e) { + log.error("", e); } } @@ -90,15 +96,15 @@ public class CacheWrapperImpl implements CacheWrapper { * @param config * @return */ - protected CacheWrapper createChildCacheWrapper(String childName, CacheConfig aconfig) { - return new CacheWrapperImpl(childName, aconfig); + protected CacheWrapper<Object> createChildCacheWrapper(String childName, CacheConfig aconfig) { + return new InfinispanCacheWrapper(childName, aconfig, cachemanager); } /** * * @return the map with the children or null */ - protected Map<String, CacheWrapper> getChildren() { + protected Map<String, CacheWrapper<Object>> getChildren() { return children; } @@ -108,7 +114,7 @@ public class CacheWrapperImpl implements CacheWrapper { 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>(); + children = new HashMap<String, CacheWrapper<Object>>(); } else { cwChild = children.get(childName); } @@ -121,53 +127,55 @@ public class CacheWrapperImpl implements CacheWrapper { } } + @Override + public int size() { + return cache.size(); + } + + @Override + public boolean containsKey(Object key) { + return cache.containsKey(key); + } + // ---- cache get, set, remove - public Serializable get(String key) { - Element elem; + public Serializable get(Object key) { + Object elem; try { synchronized (cache) {//cluster_ok by definition of this class as used in single vm elem = cache.get(key); } } catch (IllegalStateException e) { - throw new OLATRuntimeException("cache state error for cache "+cache.getName(), e); + throw new OLATRuntimeException("cache state error for cache "+cacheName, e); } catch (CacheException e) { - throw new OLATRuntimeException("cache error for cache "+cache.getName(), e); + throw new OLATRuntimeException("cache error for cache "+cacheName, e); } - return elem == null? null : elem.getValue(); + return (Serializable)elem; } - public void remove(String key) { + public void remove(Object key) { synchronized (cache) {//cluster_ok by definition of this class as used in single vm cache.remove(key); } } - public void update(String key, Serializable value) { + public void update(Object key, Serializable value) { // update is the same as put for the singlevm mode - doPut(key, value); - } - - private void doPut(String key, Serializable value) { - Element element = new Element(key, value); synchronized (cache) {//cluster_ok by definition of this class as used in single vm - cache.put(element); - } + if(cache.containsKey(key)) { + cache.replace(key, value); + } else { + cache.put(key, value); + } + } } - public void put(String key, Serializable value) { + public void put(Object key, Serializable value) { // put is the same as update for the singlevm mode - doPut(key, value); - } - - public void updateMulti(String[] keys, Serializable[] values) { - int len = keys.length; synchronized (cache) {//cluster_ok by definition of this class as used in single vm - for (int i = 0; i < len; i++) { - Element element = new Element(keys[i], values[i]); - cache.put(element); - } + cache.put(key, value); } } + protected String getCacheName() { return cacheName; diff --git a/src/main/java/org/olat/core/util/cache/n/impl/svm/SingleVMCacher.java b/src/main/java/org/olat/core/util/cache/n/InfinispanCacher.java similarity index 75% rename from src/main/java/org/olat/core/util/cache/n/impl/svm/SingleVMCacher.java rename to src/main/java/org/olat/core/util/cache/n/InfinispanCacher.java index 7372f7519ea..e797ad57a5f 100644 --- a/src/main/java/org/olat/core/util/cache/n/impl/svm/SingleVMCacher.java +++ b/src/main/java/org/olat/core/util/cache/n/InfinispanCacher.java @@ -23,12 +23,11 @@ * under the Apache 2.0 license as the original file. * <p> */ -package org.olat.core.util.cache.n.impl.svm; +package org.olat.core.util.cache.n; +import org.infinispan.manager.EmbeddedCacheManager; import org.olat.core.id.OLATResourceable; import org.olat.core.logging.AssertException; -import org.olat.core.util.cache.n.CacheConfig; -import org.olat.core.util.cache.n.CacheWrapper; import org.olat.core.util.coordinate.Cacher; import org.olat.core.util.resource.OresHelper; @@ -40,22 +39,29 @@ import org.olat.core.util.resource.OresHelper; * Initial Date: 16.10.2007 <br> * @author Felix Jost, http://www.goodsolutions.ch */ -public class SingleVMCacher implements Cacher { - private CacheWrapperImpl rootCacheWrapperImpl; +public class InfinispanCacher implements Cacher { + + private InfinispanCacheWrapper rootCacheWrapperImpl; + private EmbeddedCacheManager cacheManager; private CacheConfig rootConfig; - public SingleVMCacher() { - // needed for spring + public InfinispanCacher(EmbeddedCacheManager cacheManager) { + this.cacheManager = cacheManager; } public void init() { if (rootConfig == null) { throw new AssertException("rootConfig property must not be null!"); } - rootCacheWrapperImpl = new CacheWrapperImpl(this.getClass().getName(), rootConfig); + rootCacheWrapperImpl = new InfinispanCacheWrapper(this.getClass().getSimpleName(), rootConfig, cacheManager); } - public CacheWrapper getOrCreateCache(Class ownerClass, String name) { + @Override + public EmbeddedCacheManager getCacheContainer() { + return cacheManager; + } + + public CacheWrapper getOrCreateCache(Class<?> ownerClass, String name) { OLATResourceable ores = OresHelper.createOLATResourceableInstanceWithoutCheck(CacheConfig.getCacheName(ownerClass, name), new Long(0)); return rootCacheWrapperImpl.getOrCreateChildCacheWrapper(ores); } diff --git a/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacheWrapperEvent.java b/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacheWrapperEvent.java deleted file mode 100644 index 0b491285a67..00000000000 --- a/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacheWrapperEvent.java +++ /dev/null @@ -1,70 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -* <p> -*/ -package org.olat.core.util.cache.n.impl.cluster; - -import org.olat.core.util.event.MultiUserEvent; - -/** - * Description:<br> - * represents a cache event. - * the cache event denotes which keys of a certain cache were invalidated. - * - * <P> - * Initial Date: 23.10.2007 <br> - * @author Felix Jost, http://www.goodsolutions.ch - */ -public class ClusterCacheWrapperEvent extends MultiUserEvent { - private String[] keys; - private final String cacheName; - private final Integer sendingNodeId; - - /** - * @param command - */ - ClusterCacheWrapperEvent(Integer sendingNodeId, String cacheName, String[] keys) { - super("clustercachewrapperevent"); - this.sendingNodeId = sendingNodeId; - this.cacheName = cacheName; - this.keys = keys; - } - - public String[] getKeys() { - return keys; - } - - public String getCacheName() { - return cacheName; - } - - public Integer getSendingNodeId() { - return sendingNodeId; - } - - public String toString() { - return super.toString()+",{#keys: "+keys.length+", cachename: "+cacheName; - } - -} diff --git a/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacheWrapperImpl.java b/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacheWrapperImpl.java deleted file mode 100644 index 9808781eb5b..00000000000 --- a/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacheWrapperImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -* <p> -*/ -package org.olat.core.util.cache.n.impl.cluster; - -import java.io.Serializable; -import java.util.Map; - -import org.olat.core.util.cache.n.CacheConfig; -import org.olat.core.util.cache.n.CacheWrapper; -import org.olat.core.util.cache.n.impl.svm.CacheWrapperImpl; - -/** - * Description:<br> - * cluster implementation of the cache wrapper. - * after put or delete, it notifies the other caches which represent the - * same cache on the other olat cluster nodes by sending an invalidating event. - * those other caches will then remove the invalidated key/value pairs from its cache, - * so that an access to it forces a refetching from the primary sources. - * - * <P> - * Initial Date: 23.10.2007 <br> - * @author Felix Jost, http://www.goodsolutions.ch - */ -public class ClusterCacheWrapperImpl extends CacheWrapperImpl { - private final ClusterCacher clusterCacher; - - /** - * @param cacheName - * @param config - */ - ClusterCacheWrapperImpl(ClusterCacher cacher, String cacheName, CacheConfig config) { - super(cacheName, config); - this.clusterCacher = cacher; - } - - @Override - protected CacheWrapper createChildCacheWrapper(String childName, CacheConfig config) { - return new ClusterCacheWrapperImpl(clusterCacher, childName, config); - } - - private void afterChanged(String[] keys) { - clusterCacher.sendChangedKeys(getCacheName(), keys); - } - - @Override - public void update(String key, Serializable value) { - super.update(key, value); - afterChanged(new String[]{key}); - } - - // no need to override putSilent - since no notifications are sent - - @Override - public void updateMulti(String[] keys, Serializable[] values) { - super.updateMulti(keys, values); - afterChanged(keys); - } - - @Override - public void remove(String key) { - super.remove(key); - // always notify the other nodes, even if the key was not there - we cannot know (we would have to introduce flags per key) why it was not there (expired or invalidated) - afterChanged(new String[]{key}); - } - - ClusterCacheWrapperImpl getChildWithName(String childName) { - Map<String, CacheWrapper> children = getChildren(); - return children == null? null : (ClusterCacheWrapperImpl) children.get(childName); - } - - void invalidateKeys(String[] keys) { - // we simply delete the entries with the keys, so that the client of the cache - // will receive a null value upon new request and refill the cache if needed - for (String key : keys) { - // call the super implementation, because no further notification is needed (the key was removed due to a message from an other cache) - super.remove(key); - } - } - -} diff --git a/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacher.java b/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacher.java deleted file mode 100644 index c741f5e658b..00000000000 --- a/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterCacher.java +++ /dev/null @@ -1,160 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -* <p> -*/ -package org.olat.core.util.cache.n.impl.cluster; - -import java.util.regex.Pattern; - -import org.olat.core.configuration.Initializable; -import org.olat.core.gui.control.Event; -import org.olat.core.id.OLATResourceable; -import org.olat.core.logging.AssertException; -import org.olat.core.util.cache.n.CacheConfig; -import org.olat.core.util.cache.n.CacheWrapper; -import org.olat.core.util.coordinate.Cacher; -import org.olat.core.util.event.EventBus; -import org.olat.core.util.event.GenericEventListener; -import org.olat.core.util.resource.OresHelper; -import org.olat.testutils.codepoints.server.Codepoint; - -/** - * Description:<br> - * cluster implementation of the cacher interface. - * it uses the event bus to asychronously send invalidating messages to the same caches - * in the other olat cluster nodes. - * - * - * <P> - * Initial Date: 16.10.2007 <br> - * @author Felix Jost, http://www.goodsolutions.ch - */ -public class ClusterCacher implements Cacher, GenericEventListener, Initializable { - private static final OLATResourceable ORES_THIS = OresHelper.createOLATResourceableTypeWithoutCheck(ClusterCacher.class.getName()); - private static final Pattern PAT_DELIM_CACHENAME = Pattern.compile("@"); - - private ClusterConfig clusterConfig; - - private EventBus eventBus; - private ClusterCacheWrapperImpl rootCacheWrapperImpl; - private CacheConfig rootConfig; - - /** - * [used by spring] - * - */ - public ClusterCacher() { - // - } - - /** - * [used by spring] - * - */ - public void init() { - if (rootConfig == null) { - throw new AssertException("rootConfig property must not be null!"); - } - rootCacheWrapperImpl = new ClusterCacheWrapperImpl(this, this.getClass().getName(), rootConfig); - eventBus.registerFor(this, null, ORES_THIS); - } - - - public CacheWrapper getOrCreateCache(Class ownerClass, String name) { - OLATResourceable ores = OresHelper.createOLATResourceableInstanceWithoutCheck(CacheConfig.getCacheName(ownerClass, name), new Long(0)); - return rootCacheWrapperImpl.getOrCreateChildCacheWrapper(ores); - } - - - - /* (non-Javadoc) - * @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event) - */ - public void event(Event event) { - Codepoint.codepoint(ClusterCacher.class, "event"); - // we only receive one type of events: - ClusterCacheWrapperEvent ccwe = (ClusterCacheWrapperEvent)event; - - // important: ignore messages which stem from our cache (messages are broadcasted to all cluster nodes, that is also our own. - // without that, a put (key) would result in that key being invalidated shortly after: - // a put into a cache is to invalidate this key in all other cache instances - if (ccwe.getSendingNodeId().equals(clusterConfig.getNodeId())) { - return; - } - - // cacheName is "fully qualified name" such as - // "org.olat.core.util.cache.n.impl.svm.SingleVMCacher@org.olat.login.LoginModule_blockafterfailedattempts__0" - String cacheName = ccwe.getCacheName(); - - // find the matching child cache by traversing down the cache tree starting from the root. - ClusterCacheWrapperImpl current = rootCacheWrapperImpl; - String[] childCacheNames = PAT_DELIM_CACHENAME.split(cacheName); - int childCnt = childCacheNames.length; - - int i = 1; // skip first entry since this is ourselves (rootCacheWrapperImpl) and doesn't need to be resolved - while (i < childCnt && current != null) { - String childName = childCacheNames[i]; - current = current.getChildWithName(childName); - i++; - } - // if a matching cache was found -> invalidate those keys since their values have changed in the "same" cache in another vm and are thus dirty. - if (current != null) { - Codepoint.codepoint(ClusterCacher.class, "invalidateKeys"); - current.invalidateKeys(ccwe.getKeys()); - } // else no matching child cache found - } - - /** - * @param cacheName - * @param keys - */ - public void sendChangedKeys(String cacheName, String[] keys) { - Codepoint.codepoint(ClusterCacher.class, "sendChangedKeys"); - eventBus.fireEventToListenersOf(new ClusterCacheWrapperEvent(clusterConfig.getNodeId(), cacheName, keys), ORES_THIS); - } - - - /** - * [used by spring] - * @param eventBus - */ - public void setEventBus(EventBus eventBus) { - this.eventBus = eventBus; - } - - /** - * [used by spring] - * @param rootConfig - */ - public void setRootConfig(CacheConfig rootConfig) { - this.rootConfig = rootConfig; - } - - /** - * [used by spring] - */ - public void setClusterConfig(ClusterConfig clusterConfig) { - this.clusterConfig = clusterConfig; - } -} diff --git a/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterConfig.java b/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterConfig.java index 5206a295e8e..5bd6f58dd9e 100644 --- a/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterConfig.java +++ b/src/main/java/org/olat/core/util/cache/n/impl/cluster/ClusterConfig.java @@ -38,6 +38,8 @@ import java.io.Serializable; * @author Felix Jost, http://www.goodsolutions.ch */ public class ClusterConfig implements Serializable { + + private static final long serialVersionUID = 2413005126081334743L; private Integer nodeId; private long startupTime; diff --git a/src/main/java/org/olat/core/util/coordinate/Cacher.java b/src/main/java/org/olat/core/util/coordinate/Cacher.java index 02c55399ab3..b5d2ba96ab4 100644 --- a/src/main/java/org/olat/core/util/coordinate/Cacher.java +++ b/src/main/java/org/olat/core/util/coordinate/Cacher.java @@ -25,6 +25,7 @@ */ package org.olat.core.util.coordinate; +import org.infinispan.manager.EmbeddedCacheManager; import org.olat.core.util.cache.n.CacheWrapper; /** @@ -62,7 +63,8 @@ public interface Cacher { * @param name an optional name to be able to create more than one cache for the same coOwnerClass * @return the CacheWrapper to use for caching and/or for creating subcaches */ - public CacheWrapper getOrCreateCache(Class coOwnerClass, String name); + public CacheWrapper getOrCreateCache(Class<?> coOwnerClass, String name); + public EmbeddedCacheManager getCacheContainer(); } diff --git a/src/main/java/org/olat/core/util/prefs/db/DbPrefs.java b/src/main/java/org/olat/core/util/prefs/db/DbPrefs.java index 4601972cdca..fab9fcb67f1 100644 --- a/src/main/java/org/olat/core/util/prefs/db/DbPrefs.java +++ b/src/main/java/org/olat/core/util/prefs/db/DbPrefs.java @@ -28,6 +28,7 @@ */ package org.olat.core.util.prefs.db; +import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -46,8 +47,10 @@ import org.olat.core.util.prefs.PreferencesStorage; * * @author Felix Jost */ -public class DbPrefs implements Preferences { - +public class DbPrefs implements Preferences, Serializable { + + private static final long serialVersionUID = 3828851618949061953L; + // keys: prefs-keys; values: any Prefs-Objects private Map<String,Object> prefstore = new HashMap<String,Object>(); diff --git a/src/main/java/org/olat/core/util/session/UserSessionManager.java b/src/main/java/org/olat/core/util/session/UserSessionManager.java index 74647193dbb..03fc0d122b6 100644 --- a/src/main/java/org/olat/core/util/session/UserSessionManager.java +++ b/src/main/java/org/olat/core/util/session/UserSessionManager.java @@ -35,6 +35,7 @@ import javax.servlet.http.HttpSession; import org.olat.core.gui.control.Disposable; import org.olat.core.gui.control.Event; +import org.olat.core.helpers.Settings; import org.olat.core.id.Identity; import org.olat.core.id.IdentityEnvironment; import org.olat.core.id.OLATResourceable; @@ -51,6 +52,7 @@ import org.olat.core.logging.activity.UserActivityLoggerImpl; import org.olat.core.util.SessionInfo; import org.olat.core.util.SignOnOffEvent; import org.olat.core.util.UserSession; +import org.olat.core.util.cache.n.CacheWrapper; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.event.GenericEventListener; import org.olat.core.util.prefs.Preferences; @@ -89,9 +91,12 @@ public class UserSessionManager implements GenericEventListener { @Autowired private HistoryManager historyManager; + private CacheWrapper<Long> userSessionCache; + @PostConstruct public void initBean() { coordinator.getCoordinator().getEventBus().registerFor(this, null, ORES_USERSESSION); + userSessionCache = coordinator.getCoordinator().getCacher().getOrCreateCache(UserSessionManager.class, "usersession"); } /** @@ -204,7 +209,7 @@ public class UserSessionManager implements GenericEventListener { */ public int getUserSessionWebCounter() { // clusterNOK ?? return only number of locale sessions ? - return sessionCountWeb.get(); + return userSessionCache.size(); } /** @@ -267,12 +272,14 @@ public class UserSessionManager implements GenericEventListener { log.audit("Logged on [via webdav]: " + sessionInfo.toString()); } else { - if(isDebug) log.debug("signOn() authUsersNamesOtherNodes.contains "+identity.getName()+": "+authUsersNamesOtherNodes.contains(identity.getKey())); + if(isDebug) { + log.debug("signOn() authUsersNamesOtherNodes.contains "+identity.getName() + ": " + authUsersNamesOtherNodes.contains(identity.getKey())); + } UserSession invalidatedSession = null; synchronized (authUserSessions) { //o_clusterOK by:fj // check if already a session exist for this user - if ( (userNameToIdentity.contains(identity.getKey()) || authUsersNamesOtherNodes.contains(identity.getKey()) ) + if ( (userNameToIdentity.contains(identity.getKey()) || userSessionCache.containsKey(identity.getKey()) ) && !sessionInfo.isWebDAV() && !sessionInfo.isREST() && !usess.getRoles().isGuestOnly()) { log.info("Loggin-process II: User has already a session => signOffAndClear existing session"); @@ -290,6 +297,7 @@ public class UserSessionManager implements GenericEventListener { // characters -> map stores values as such if(isDebug) log.debug("signOn() adding to userNameToIdentity: "+identity.getName().toLowerCase()); userNameToIdentity.add(identity.getKey()); + userSessionCache.put(identity.getKey(), new Integer(Settings.getNodeId())); } //reload user prefs @@ -436,6 +444,7 @@ public class UserSessionManager implements GenericEventListener { if (previousSignedOn != null) { if(isDebug) log.debug("signOffAndClearWithout() removing from userNameToIdentity: "+previousSignedOn.getName().toLowerCase()); userNameToIdentity.remove(previousSignedOn.getKey()); + userSessionCache.remove(previousSignedOn.getKey()); } } else if (isDebug) { log.info("UserSession already removed! for ["+ident+"]"); @@ -482,7 +491,7 @@ public class UserSessionManager implements GenericEventListener { if(debug) log.debug("event() adding to authUsersNamesOtherNodes: "+se.getIdentityKey()); authUsersNamesOtherNodes.add(se.getIdentityKey()); UserSession usess = getUserSessionForGui(se.getIdentityKey()); - if (usess.getSessionInfo() != null && se.getIdentityKey().equals(usess.getSessionInfo().getLogin()) + if (usess != null && usess.getSessionInfo() != null && se.getIdentityKey().equals(usess.getSessionInfo().getIdentityKey()) && !usess.getSessionInfo().isWebDAV() && !usess.getRoles().isGuestOnly()) { // if this listening UserSession instance is from the same user diff --git a/src/main/java/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml b/src/main/java/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml index 5ee597fbd45..2fff927309d 100644 --- a/src/main/java/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml +++ b/src/main/java/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml @@ -4,12 +4,12 @@ xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + http://www.springframework.org/schema/context/spring-context-3.1.xsd"> -<context:property-placeholder location="classpath:serviceconfig/olat.properties, classpath:olat.local.properties" /> -<context:annotation-config /> + <context:property-placeholder location="classpath:serviceconfig/olat.properties, classpath:olat.local.properties" system-properties-mode="OVERRIDE"/> + <context:annotation-config /> <!-- Configuration note: Make sure this Spring file is loaded at the earliest point possible to be sure to catch as many Loggers as possible. diff --git a/src/main/java/org/olat/course/assessment/NewCachePersistingAssessmentManager.java b/src/main/java/org/olat/course/assessment/NewCachePersistingAssessmentManager.java index f81899e959f..e9cf3d01a35 100644 --- a/src/main/java/org/olat/course/assessment/NewCachePersistingAssessmentManager.java +++ b/src/main/java/org/olat/course/assessment/NewCachePersistingAssessmentManager.java @@ -156,6 +156,8 @@ public class NewCachePersistingAssessmentManager extends BasicManager implements * @return */ private List<Property> loadPropertiesFor(List<Identity> identities) { + if(identities == null || identities.isEmpty()) return Collections.emptyList(); + ICourse course = CourseFactory.loadCourse(ores); StringBuilder sb = new StringBuilder(); sb.append("from org.olat.properties.Property as p") diff --git a/src/main/java/org/olat/course/assessment/model/UserCourseInfosImpl.hbm.xml b/src/main/java/org/olat/course/assessment/model/UserCourseInfosImpl.hbm.xml index f9ec0fe3dfc..b34c9dfc065 100644 --- a/src/main/java/org/olat/course/assessment/model/UserCourseInfosImpl.hbm.xml +++ b/src/main/java/org/olat/course/assessment/model/UserCourseInfosImpl.hbm.xml @@ -5,7 +5,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.course.assessment.model.UserCourseInfosImpl" table="o_as_user_course_infos"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/course/assessment/model/UserEfficiencyStatementImpl.hbm.xml b/src/main/java/org/olat/course/assessment/model/UserEfficiencyStatementImpl.hbm.xml index 099f3e2ebc4..b769269a674 100644 --- a/src/main/java/org/olat/course/assessment/model/UserEfficiencyStatementImpl.hbm.xml +++ b/src/main/java/org/olat/course/assessment/model/UserEfficiencyStatementImpl.hbm.xml @@ -5,7 +5,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.course.assessment.model.UserEfficiencyStatementImpl" table="o_as_eff_statement"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/group/BusinessGroupImpl.hbm.xml b/src/main/java/org/olat/group/BusinessGroupImpl.hbm.xml index 8ce8b460371..b7075cd4213 100644 --- a/src/main/java/org/olat/group/BusinessGroupImpl.hbm.xml +++ b/src/main/java/org/olat/group/BusinessGroupImpl.hbm.xml @@ -6,7 +6,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.group.BusinessGroupImpl" table="o_gp_business"> - <cache usage="read-write" /> + <cache usage="transactional" /> <!-- key (see Interface org.olat.core.commons.persistence.Persistable), lastModified (see Interface org.olat.core.commons.persistence.Auditable) @@ -95,7 +95,7 @@ <class name="org.olat.group.model.BusinessGroupShortImpl" table="o_gp_business" mutable="false"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="group_id" unsaved-value="null"> <generator class="hilo"/> </id> diff --git a/src/main/java/org/olat/group/area/BGAreaImpl.hbm.xml b/src/main/java/org/olat/group/area/BGAreaImpl.hbm.xml index 668df7e66b6..95acdb4899b 100644 --- a/src/main/java/org/olat/group/area/BGAreaImpl.hbm.xml +++ b/src/main/java/org/olat/group/area/BGAreaImpl.hbm.xml @@ -6,7 +6,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.group.area.BGAreaImpl" table="o_gp_bgarea"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" diff --git a/src/main/java/org/olat/group/area/BGtoAreaRelationImpl.hbm.xml b/src/main/java/org/olat/group/area/BGtoAreaRelationImpl.hbm.xml index fa53731e6c2..d929c9e915f 100644 --- a/src/main/java/org/olat/group/area/BGtoAreaRelationImpl.hbm.xml +++ b/src/main/java/org/olat/group/area/BGtoAreaRelationImpl.hbm.xml @@ -4,7 +4,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.group.area.BGtoAreaRelationImpl" table="o_gp_bgtoarea_rel"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" diff --git a/src/main/java/org/olat/group/context/BGContext2Resource.hbm.xml b/src/main/java/org/olat/group/context/BGContext2Resource.hbm.xml index 7eb31b55e75..60a33b539ec 100644 --- a/src/main/java/org/olat/group/context/BGContext2Resource.hbm.xml +++ b/src/main/java/org/olat/group/context/BGContext2Resource.hbm.xml @@ -5,8 +5,6 @@ <hibernate-mapping> <class name="org.olat.group.context.BGContext2Resource" table="o_gp_bgcontextresource_rel" lazy="false"> - - <cache usage="read-write" /> <id name="key" type="long" diff --git a/src/main/java/org/olat/group/context/BGContextImpl.hbm.xml b/src/main/java/org/olat/group/context/BGContextImpl.hbm.xml index 1e05d6cc8b7..d3e879d85f5 100644 --- a/src/main/java/org/olat/group/context/BGContextImpl.hbm.xml +++ b/src/main/java/org/olat/group/context/BGContextImpl.hbm.xml @@ -6,8 +6,6 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.group.context.BGContextImpl" table="o_gp_bgcontext"> - <cache usage="read-write" /> - <id name="key" type="long" column="groupcontext_id" diff --git a/src/main/java/org/olat/group/model/BGResourceRelation.hbm.xml b/src/main/java/org/olat/group/model/BGResourceRelation.hbm.xml index c8bfcb72908..5a87d04ccab 100644 --- a/src/main/java/org/olat/group/model/BGResourceRelation.hbm.xml +++ b/src/main/java/org/olat/group/model/BGResourceRelation.hbm.xml @@ -5,7 +5,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.group.model.BGResourceRelation" table="o_gp_business_to_resource"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="g_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/group/model/BusinessGroupMembershipViewImpl.hbm.xml b/src/main/java/org/olat/group/model/BusinessGroupMembershipViewImpl.hbm.xml index f6d9bec15ac..86e739b4904 100644 --- a/src/main/java/org/olat/group/model/BusinessGroupMembershipViewImpl.hbm.xml +++ b/src/main/java/org/olat/group/model/BusinessGroupMembershipViewImpl.hbm.xml @@ -4,7 +4,7 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-lazy="false"> <class name="org.olat.group.model.BusinessGroupMembershipViewImpl" table="o_bs_gp_membership_v" mutable="false"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="membership_id" diff --git a/src/main/java/org/olat/group/model/BusinessGroupViewImpl.hbm.xml b/src/main/java/org/olat/group/model/BusinessGroupViewImpl.hbm.xml index 2e4a5391350..a8a3287f287 100644 --- a/src/main/java/org/olat/group/model/BusinessGroupViewImpl.hbm.xml +++ b/src/main/java/org/olat/group/model/BusinessGroupViewImpl.hbm.xml @@ -5,7 +5,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.group.model.BusinessGroupViewImpl" table="o_gp_business_v" mutable="false"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="group_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/modules/webFeed/managers/FeedManager.java b/src/main/java/org/olat/modules/webFeed/managers/FeedManager.java index 2b382424670..d55a0470339 100644 --- a/src/main/java/org/olat/modules/webFeed/managers/FeedManager.java +++ b/src/main/java/org/olat/modules/webFeed/managers/FeedManager.java @@ -110,7 +110,7 @@ public abstract class FeedManager extends BasicManager { * @param item * @param feed */ - public abstract void addItem(Item item, FileElement file, Feed feed); + public abstract Feed addItem(Item item, FileElement file, Feed feed); /** * Removes the given <code>Item</code> from the <code>Feed</code>. Its content @@ -119,13 +119,13 @@ public abstract class FeedManager extends BasicManager { * @param item * @param feed */ - public abstract void remove(Item item, Feed feed); + public abstract Feed remove(Item item, Feed feed); /** * @param modifiedItem * @param feed */ - public abstract void updateItem(Item modifiedItem, FileElement file, Feed feed); + public abstract Feed updateItem(Item modifiedItem, FileElement file, Feed feed); /** * Update the feed source mode diff --git a/src/main/java/org/olat/modules/webFeed/managers/FeedManagerImpl.java b/src/main/java/org/olat/modules/webFeed/managers/FeedManagerImpl.java index 0be7c4a419a..2d74ed78901 100644 --- a/src/main/java/org/olat/modules/webFeed/managers/FeedManagerImpl.java +++ b/src/main/java/org/olat/modules/webFeed/managers/FeedManagerImpl.java @@ -578,12 +578,12 @@ public class FeedManagerImpl extends FeedManager { * org.olat.modules.webFeed.models.Feed) */ @Override - public void remove(final Item item, final Feed feed) { + public Feed remove(final Item item, final Feed feed) { // synchronize all feed item CUD operations on this feed to prevend // overwriting of changes // o_clusterOK by:fg - coordinator.getSyncer().doInSync(feed, new SyncerCallback<Object>() { - public VFSLeaf execute() { + return coordinator.getSyncer().doInSync(feed, new SyncerCallback<Feed>() { + public Feed execute() { // reload feed to prevent stale feed overwriting @SuppressWarnings("synthetic-access") Feed reloadedFeed = getFeed(feed, false); @@ -613,7 +613,7 @@ public class FeedManagerImpl extends FeedManager { commentAndRatingService.deleteAll(); } // - return null; + return reloadedFeed; } }); } @@ -624,14 +624,14 @@ public class FeedManagerImpl extends FeedManager { * org.olat.modules.webFeed.models.Feed) */ @Override - public void addItem(final Item item, final FileElement file, final Feed feed) { + public Feed addItem(final Item item, final FileElement file, final Feed feed) { if (feed.isInternal()) { // synchronize all feed item CUD operations on this feed to prevent // overwriting of changes // o_clusterOK by:fg - coordinator.getSyncer().doInSync(feed, new SyncerCallback<Object>() { + return coordinator.getSyncer().doInSync(feed, new SyncerCallback<Feed>() { @SuppressWarnings("synthetic-access") - public VFSLeaf execute() { + public Feed execute() { // reload feed to prevent stale feed overwriting Feed reloadedFeed = getFeed(feed, false); // Set the current date as published date. @@ -651,10 +651,11 @@ public class FeedManagerImpl extends FeedManager { // Save the feed (needed because of itemIds list) update(reloadedFeed, false); - return null; + return reloadedFeed; } }); } + return null; } /** @@ -919,14 +920,14 @@ public class FeedManagerImpl extends FeedManager { * org.olat.modules.webFeed.models.Feed) */ @Override - public void updateItem(final Item item, final FileElement file, final Feed feed) { + public Feed updateItem(final Item item, final FileElement file, final Feed feed) { if (feed.isInternal()) { // synchronize all feed item CUD operations on this feed to prevent // overwriting of changes // o_clusterOK by:fg - coordinator.getSyncer().doInSync(feed, new SyncerCallback<Object>() { + return coordinator.getSyncer().doInSync(feed, new SyncerCallback<Feed>() { @SuppressWarnings("synthetic-access") - public VFSLeaf execute() { + public Feed execute() { // reload feed to prevent stale feed overwriting Feed reloadedFeed = getFeed(feed, false); if (reloadedFeed.getItemIds().contains(item.getGuid())) { @@ -938,10 +939,11 @@ public class FeedManagerImpl extends FeedManager { } else { // do nothing, item was deleted by someone in the meantime } - return null; + return reloadedFeed; } }); } + return null; } /** diff --git a/src/main/java/org/olat/modules/webFeed/ui/ItemsController.java b/src/main/java/org/olat/modules/webFeed/ui/ItemsController.java index baec2be0292..a8ce5a80ecd 100644 --- a/src/main/java/org/olat/modules/webFeed/ui/ItemsController.java +++ b/src/main/java/org/olat/modules/webFeed/ui/ItemsController.java @@ -560,7 +560,7 @@ public class ItemsController extends BasicController implements Activateable2 { // remove the item also from the helper (cached selection) helper.removeItem(item); // permanently remove item - feedManager.remove(item, feed); + feed = feedManager.remove(item, feed); // remove delete and edit buttons of this item deleteButtons.remove(source); for (Link editButton : editButtons) { @@ -606,7 +606,7 @@ public class ItemsController extends BasicController implements Activateable2 { } else { if (!feed.getItems().contains(currentItem)) { // Add the modified item if it is not part of the feed - feedManager.addItem(currentItem, mediaFile, feed); + feed = feedManager.addItem(currentItem, mediaFile, feed); createButtonsForItem(ureq, currentItem); createItemLink(currentItem); // Add date component @@ -631,7 +631,7 @@ public class ItemsController extends BasicController implements Activateable2 { ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_CREATE, getClass(), LoggingResourceable.wrap(currentItem)); } else { // Write item file - feedManager.updateItem(currentItem, mediaFile, feed); + feed = feedManager.updateItem(currentItem, mediaFile, feed); // Update current item in the users view, replace in helper cache of // current selected items. helper.updateItem(currentItem); diff --git a/src/main/java/org/olat/repository/MetaDataElement.hbm.xml b/src/main/java/org/olat/repository/MetaDataElement.hbm.xml index be8e3e1476f..db1e9223536 100644 --- a/src/main/java/org/olat/repository/MetaDataElement.hbm.xml +++ b/src/main/java/org/olat/repository/MetaDataElement.hbm.xml @@ -3,7 +3,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.repository.MetaDataElement" table="o_repositorymetadata"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" column="metadataelement_id" type="long" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/repository/RepositoryEntry.hbm.xml b/src/main/java/org/olat/repository/RepositoryEntry.hbm.xml index 12204d93dd4..4e7fa2974ee 100644 --- a/src/main/java/org/olat/repository/RepositoryEntry.hbm.xml +++ b/src/main/java/org/olat/repository/RepositoryEntry.hbm.xml @@ -3,7 +3,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.repository.RepositoryEntry" table="o_repositoryentry"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" column="repositoryentry_id" type="long" unsaved-value="null"> <generator class="hilo"/> @@ -115,7 +115,7 @@ </class> <class name="org.olat.repository.model.RepositoryEntryShortImpl" table="o_repositoryentry" mutable="false"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" column="repositoryentry_id" type="long" unsaved-value="null"> <generator class="hilo"/> </id> diff --git a/src/main/java/org/olat/resource/OLATResourceImpl.hbm.xml b/src/main/java/org/olat/resource/OLATResourceImpl.hbm.xml index 31d8f0a3897..ef7532c5535 100644 --- a/src/main/java/org/olat/resource/OLATResourceImpl.hbm.xml +++ b/src/main/java/org/olat/resource/OLATResourceImpl.hbm.xml @@ -5,7 +5,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.resource.OLATResourceImpl" table="o_olatresource"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="resource_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/resource/lock/pessimistic/PLockImpl.hbm.xml b/src/main/java/org/olat/resource/lock/pessimistic/PLockImpl.hbm.xml index dacf5745f57..4112c57cc87 100644 --- a/src/main/java/org/olat/resource/lock/pessimistic/PLockImpl.hbm.xml +++ b/src/main/java/org/olat/resource/lock/pessimistic/PLockImpl.hbm.xml @@ -4,8 +4,6 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-lazy="false"> <class name="org.olat.resource.lock.pessimistic.PLockImpl" table="o_plock"> - - <!-- <cache usage="read-write" />--> <id name="key" type="long" column="plock_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/resource/references/ReferenceImpl.hbm.xml b/src/main/java/org/olat/resource/references/ReferenceImpl.hbm.xml index a828613f43a..98c8663512d 100644 --- a/src/main/java/org/olat/resource/references/ReferenceImpl.hbm.xml +++ b/src/main/java/org/olat/resource/references/ReferenceImpl.hbm.xml @@ -6,7 +6,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.resource.references.ReferenceImpl" table="o_references"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" type="long" column="reference_id" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/java/org/olat/user/UserImpl.hbm.xml b/src/main/java/org/olat/user/UserImpl.hbm.xml index 1f71d3f50ed..1e0d46953c3 100644 --- a/src/main/java/org/olat/user/UserImpl.hbm.xml +++ b/src/main/java/org/olat/user/UserImpl.hbm.xml @@ -6,7 +6,7 @@ <hibernate-mapping default-lazy="false"> <class name="org.olat.user.UserImpl" table="o_user"> - <cache usage="read-write" /> + <cache usage="transactional" /> <id name="key" column="user_id" type="long" unsaved-value="null"> <generator class="hilo"/> diff --git a/src/main/resources/database/mysql/setupDatabase.sql b/src/main/resources/database/mysql/setupDatabase.sql index 412240268be..fd516e7681e 100644 --- a/src/main/resources/database/mysql/setupDatabase.sql +++ b/src/main/resources/database/mysql/setupDatabase.sql @@ -1027,6 +1027,38 @@ create table o_as_user_course_infos ( primary key (id) ); +-- instant messaging +create table if not exists o_im_message ( + id bigint not null, + creationdate datetime, + msg_resname varchar(50) not null, + msg_resid bigint not null, + msg_anonym bit default 0, + msg_from varchar(255) not null, + msg_body longtext, + fk_from_identity_id bigint not null, + primary key (id) +); + +create table if not exists o_im_notification ( + id bigint not null, + creationdate datetime, + chat_resname varchar(50) not null, + chat_resid bigint not null, + fk_to_identity_id bigint not null, + fk_from_identity_id bigint not null, + primary key (id) +); + +create table if not exists o_im_preferences ( + id bigint not null, + creationdate datetime, + visible_to_others bit default 0, + roster_def_status varchar(12), + fk_from_identity_id bigint not null, + primary key (id) +); + -- add mapper table create table o_mapper ( id int8 not null, @@ -1531,6 +1563,12 @@ create index paypal_pay_key_idx on o_ac_paypal_transaction (pay_key); create index paypal_pay_trx_id_idx on o_ac_paypal_transaction (ipn_transaction_id); create index paypal_pay_s_trx_id_idx on o_ac_paypal_transaction (ipn_sender_transaction_id); +alter table o_im_message add constraint idx_im_msg_to_fromid foreign key (fk_from_identity_id) references o_bs_identity (id); +create index idx_im_msg_res_idx on o_im_message (msg_resid,msg_resname); +alter table o_im_notification add constraint idx_im_not_to_toid foreign key (fk_to_identity_id) references o_bs_identity (id); +alter table o_im_notification add constraint idx_im_not_to_fromid foreign key (fk_from_identity_id) references o_bs_identity (id); +create index idx_im_chat_res_idx on o_im_notification (chat_resid,chat_resname); +alter table o_im_preferences add constraint idx_im_prfs_to_id foreign key (fk_from_identity_id) references o_bs_identity (id); alter table o_tag add constraint FK6491FCA5A4FA5DC foreign key (fk_author_id) references o_bs_identity (id); diff --git a/src/main/resources/ehcache.xml b/src/main/resources/ehcache.xml deleted file mode 100644 index 7f7cf307dce..00000000000 --- a/src/main/resources/ehcache.xml +++ /dev/null @@ -1,129 +0,0 @@ -<ehcache updateCheck="false"> - - <!-- OLAT uses ehcache as following: - - hibernate second level cache - - hibernate query cache - - hibernate timestamp cache - - OLAT assessment property cache (PersistingAssessmentManager) - --> - - <!-- Sets the path to the directory where cache .data files are created. - - If the path is a Java System Property it is replaced by - its value in the running VM. - - The following properties are translated: - user.home - User's home directory - user.dir - User's current working directory - java.io.tmpdir - Default temp file path --> - <diskStore path="java.io.tmpdir"/> - - <!--Default Cache configuration. These will applied to caches programmatically created through - the CacheManager. - - The following attributes are required: - - maxElementsInMemory - Sets the maximum number of objects that will be created in memory - eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the - element is never expired. - overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache - has reached the maxInMemory limit. - - The following attributes are optional: - timeToIdleSeconds - Sets the time to idle for an element before it expires. - i.e. The maximum amount of time between accesses before an element expires - Is only used if the element is not eternal. - Optional attribute. A value of 0 means that an Element can idle for infinity. - The default value is 0. - timeToLiveSeconds - Sets the time to live for an element before it expires. - i.e. The maximum time between creation time and when an element expires. - Is only used if the element is not eternal. - Optional attribute. A value of 0 means that and Element can live for infinity. - The default value is 0. - diskPersistent - Whether the disk store persists between restarts of the Virtual Machine. - The default value is false. - diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value - is 120 seconds. - --> - - <defaultCache - maxElementsInMemory="10000" - eternal="false" - timeToIdleSeconds="1800" - timeToLiveSeconds="3600" - overflowToDisk="false" - /> - - <cache name="net.sf.hibernate.cache.UpdateTimestampsCache" - maxElementsInMemory="10000" - eternal="true" - overflowToDisk="false" - /> - - <cache name="net.sf.hibernate.cache.StandardQueryCache" - maxElementsInMemory="1000" - eternal="false" - timeToIdleSeconds="1800" - timeToLiveSeconds="3600" - overflowToDisk="false" - /> - - <cache name="org.olat.core.util.cache.n.impl.svm.SingleVMCacher@org.olat.core.dispatcher.mapper.MapperService_mapper__0" - maxElementsInMemory="10000" - eternal="false" - timeToIdleSeconds="300" - timeToLiveSeconds="300" - overflowToDisk="false" - /> - - <cache name="org.olat.core.util.cache.n.impl.svm.SingleVMCacher@org.olat.modules.openmeetings.manager.OpenMeetingsManager_session__0" - maxElementsInMemory="10000" - eternal="false" - timeToIdleSeconds="900" - timeToLiveSeconds="900" - overflowToDisk="false" - /> - - <!-- - specific OLAT caches - --> - - <!-- cache RSS documents for three minutes (there is at most one per user) --> - <cache name="org.olat.commons.servlets.RSSServlet_rssdocs" - maxElementsInMemory="200" - eternal="false" - timeToIdleSeconds="0" - timeToLiveSeconds="180" - overflowToDisk="false" - /> - - - - - <!-- Sample cache named sampleCache1 - This cache contains a maximum in memory of 10000 elements, and will expire - an element if it is idle for more than 5 minutes and lives for more than - 10 minutes. - - If there are more than 10000 elements it will overflow to the - disk cache, which in this configuration will go to wherever java.io.tmp is - defined on your system. On a standard Linux system this will be /tmp" - --> - <!--cache name="my.package.Class" - maxElementsInMemory="10000" - eternal="false" - timeToIdleSeconds="300" - timeToLiveSeconds="600" - overflowToDisk="true" - /--> - - <!-- Sample cache named sampleCache2 - This cache contains 1000 elements. Elements will always be held in memory. - They are not expired. --> - <!--cache name="my.package.Class.collection" - maxElementsInMemory="1000" - eternal="true" - overflowToDisk="false" - /--> - -</ehcache> diff --git a/src/main/resources/infinispan-config.xml b/src/main/resources/infinispan-config.xml new file mode 100644 index 00000000000..442a6ecdf2e --- /dev/null +++ b/src/main/resources/infinispan-config.xml @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="urn:infinispan:config:5.1" + xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"> + <global> + <globalJmxStatistics allowDuplicateDomains="true" /> + </global> + + <default> + <!-- Used to register JMX statistics in any available MBean server --> + <jmxStatistics enabled="true"/> + + </default> + + <namedCache name="InfinispanCacher@org.olat.core.dispatcher.mapper.MapperService_mapper__0"> + <eviction maxEntries="1000" strategy="LRU"/> + <expiration maxIdle="300000" wakeUpInterval="5000"/> + <transaction transactionMode="NON_TRANSACTIONAL" /> + </namedCache> + + <namedCache name="InfinispanCacher@org.olat.modules.openmeetings.manager.OpenMeetingsManager_session__0"> + <eviction maxEntries="1000" strategy="LRU"/> + <expiration maxIdle="900000" wakeUpInterval="5000"/> + <transaction transactionMode="NON_TRANSACTIONAL" /> + </namedCache> + + <namedCache name="InfinispanCacher@org.olat.commons.servlets.RSSServlet_rssdocs__0"> + <eviction maxEntries="1000" strategy="LRU"/> + <expiration maxIdle="900000" wakeUpInterval="5000"/> + <transaction transactionMode="NON_TRANSACTIONAL" /> + </namedCache> + + <namedCache name="InfinispanCacher@org.olat.core.util.session.UserSessionManager_usersession__0"> + <eviction strategy="NONE"/> + <expiration lifespan="-1" maxIdle="-1"/> + <transaction transactionMode="TRANSACTIONAL" /> + </namedCache> + + <!-- + Hibernate cache + --> + + <!-- Default configuration is appropriate for entity/collection caching. --> + <namedCache name="entity"> + <locking isolationLevel="READ_COMMITTED" concurrencyLevel="1000" lockAcquisitionTimeout="15000" useLockStriping="false"/> + <!-- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. + 0 means the eviction thread will never run. A separate executor is used for eviction in each cache. --> + <eviction maxEntries="10000" strategy="LRU"/> + <expiration maxIdle="100000" wakeUpInterval="5000"/> + <transaction transactionMode="NON_TRANSACTIONAL" /> + </namedCache> + + <!-- Default configuration is appropriate for entity/collection caching. --> + <namedCache name="entity-repeatable"> + <locking isolationLevel="REPEATABLE_READ" concurrencyLevel="1000" lockAcquisitionTimeout="15000" useLockStriping="false"/> + <!-- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. + 0 means the eviction thread will never run. A separate executor is used for eviction in each cache. --> + <eviction maxEntries="10000" strategy="LRU"/> + <expiration maxIdle="100000" wakeUpInterval="5000"/> + <transaction transactionMode="NON_TRANSACTIONAL"/> + </namedCache> + + <!-- A config appropriate for query caching. Does not replicate queries. --> + <namedCache name="local-query"> + <locking isolationLevel="READ_COMMITTED" concurrencyLevel="1000" + lockAcquisitionTimeout="15000" useLockStriping="false"/> + <!--Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means + the eviction thread will never run. A separate executor is used for eviction in each cache. --> + <eviction maxEntries="10000" strategy="LRU"/> + <expiration maxIdle="100000" wakeUpInterval="5000"/> + <transaction transactionMode="NON_TRANSACTIONAL" /> + </namedCache> + + <!-- Optimized for timestamp caching. A clustered timestamp cache + is required if query caching is used, even if the query cache + itself is configured with CacheMode=LOCAL. --> + <namedCache name="timestamps"> + <locking isolationLevel="READ_COMMITTED" concurrencyLevel="1000" lockAcquisitionTimeout="15000" useLockStriping="false"/> + <lazyDeserialization enabled="true"/> + <!-- Don't ever evict modification timestamps --> + <eviction strategy="NONE"/> + <expiration wakeUpInterval="0"/> + <!-- Explicitly non transactional --> + <transaction transactionMode="NON_TRANSACTIONAL"/> + </namedCache> + +</infinispan> \ No newline at end of file diff --git a/src/main/resources/serviceconfig/olat.properties b/src/main/resources/serviceconfig/olat.properties index 65eb5c1a7f8..0b6556d62ff 100644 --- a/src/main/resources/serviceconfig/olat.properties +++ b/src/main/resources/serviceconfig/olat.properties @@ -441,6 +441,14 @@ db.show_sql=false db.hibernate.c3p0.minsize=20 db.hibernate.c3p0.maxsize=50 +######################################################################## +# Infinispan +######################################################################## + +#Use the jndi name if you want to retrieve the cache manager from JBoss AS +infinispan.jndi= +infinispan.jndi.values=,java:jboss/infinispan/openolatha + ######################################################################## # Fonts for jsMath Formula Editor (part of html editor and wiki) ######################################################################## diff --git a/src/main/resources/serviceconfig/org/olat/_spring/olatextconfig.xml b/src/main/resources/serviceconfig/org/olat/_spring/olatextconfig.xml index 959f3d55984..34e9fd0181c 100644 --- a/src/main/resources/serviceconfig/org/olat/_spring/olatextconfig.xml +++ b/src/main/resources/serviceconfig/org/olat/_spring/olatextconfig.xml @@ -114,18 +114,7 @@ </property> <property name="server" ref="org.springframework.jmx.support.MBeanServerFactoryBean"/> </bean> - <!-- CacheInitMBean register ehcache jmx components at mbean-server --> - <!--<bean class="org.olat.admin.jmx.CacheInitMBean"> - <property name="server" ref="org.springframework.jmx.support.MBeanServerFactoryBean"/> - </bean> - --> - <bean id="org.olat.core.commons.modules.bc.FilesInfoMBean" class="org.olat.core.commons.modules.bc.FilesInfoMBean" /> - <!-- JBossTreeCacheJmxRegistrationManager register JBoss Tree Cache jmx components at mbean-server --> -<!-- DISABLE JBoss Tree Cache JMX Registration, already done by starting tree cache ??? - <bean id="org.olat.admin.jmx.JBossTreeCacheJmxRegistrationManager" class="org.olat.admin.jmx.JBossTreeCacheJmxRegistrationManager" > - <property name="server" ref="org.springframework.jmx.support.MBeanServerFactoryBean"/> - </bean> ---> + <bean id="org.olat.core.commons.modules.bc.FilesInfoMBean" class="org.olat.core.commons.modules.bc.FilesInfoMBean" /> </beans> diff --git a/src/main/resources/serviceconfig/org/olat/core/_spring/olatcoreconfig.xml b/src/main/resources/serviceconfig/org/olat/core/_spring/olatcoreconfig.xml index 60a9112ed87..c48a04b9e18 100644 --- a/src/main/resources/serviceconfig/org/olat/core/_spring/olatcoreconfig.xml +++ b/src/main/resources/serviceconfig/org/olat/core/_spring/olatcoreconfig.xml @@ -33,94 +33,46 @@ <lookup-method name="getPersistentLockManager" bean="persistentLockManager"/> </bean> </property> - <property name="clusterConfig" ref="org.olat.commons.coordinate.cluster.ClusterConfig" /> <property name="syncer" ref="org.olat.commons.coordinate.cluster.ClusterSyncer" /> <property name="eventBus" ref="org.olat.commons.coordinate.cluster.jms.ClusterEventBus" /> - - <property name="cacher"> - <!-- cache config, please note that settings can also stem from the file ehcache.xml (deprecated) --> - <bean class="org.olat.core.util.cache.n.impl.cluster.ClusterCacher" init-method="init"> - <property name="clusterConfig" ref="org.olat.commons.coordinate.cluster.ClusterConfig" /> - <property name="eventBus" ref="org.olat.commons.coordinate.cluster.jms.ClusterEventBus" /> - <property name="rootConfig"> - <bean class="org.olat.core.util.cache.n.CacheConfig"> - <property name="childrenConfig"> - <map> - <entry key="org.olat.login.LoginModule_blockafterfailedattempts" value-ref="org.olat.login.LoginModule_blockafterfailedattempts" /> - <entry key="org.olat.commons.servlets.RSSServlet_rssdocs" value-ref="org.olat.commons.servlets.RSSServlet_rssdocs"/> - <entry key="org.olat.ims.qti.process.QTIHelper_QTI_xml_Documents" value-ref="org.olat.ims.qti.process.QTIHelper_QTI_xml_Documents"/> - <entry key="org.olat.modules.wiki.WikiManager_wiki" value-ref="org.olat.modules.wiki.WikiManager_wiki"/> - <entry key="org.olat.commons.calendar.ICalFileCalendarManager_calendar" value-ref="org.olat.commons.calendar.ICalFileCalendarManager_calendar" /> - <entry key="org.olat.course.CourseFactory_courses" value-ref="org.olat.course.CourseFactory_courses" /> - <entry key="org.olat.collaboration.CollaborationToolsFactory_tools" value-ref="org.olat.collaboration.CollaborationToolsFactory_tools" /> - <entry key="org.olat.course.assessment.NewCachePersistingAssessmentManager" value-ref="org.olat.course.assessment.NewCachePersistingAssessmentManager" /> - <entry key="org.olat.core.util.UserSession" value-ref="org.olat.core.util.UserSession" /> - <entry key="org.olat.core.modules.glossary.GlossaryItemManager_glossary" value-ref="org.olat.core.modules.glossary.GlossaryItemManager_glossary"/> - <entry key="org.olat.course.nodes.projectbroker.service.ProjectBrokerManagerImpl_pb" value-ref="org.olat.course.nodes.projectbroker.service.ProjectBrokerManagerImpl_pb"/> - <entry key="org.olat.commons.servlets.WebDAVManagerImpl_webdav" value-ref="org.olat.commons.servlets.WebDAVManagerImpl_webdav" /> - - - <!-- - for the cache-test of the cluster admin controller . - this is also a sample how cache parameters can be assigned to a specific resource only. - // org.olat.commons.coordinate.cluster.jms.ClusterAdminController:cachetest::0@subcachetypetest::123 - --> - <entry key="org.olat.commons.coordinate.cluster.jms.ClusterAdminController_cachetest"> - <bean class="org.olat.core.util.cache.n.CacheConfig"> - <!-- no cache needed on this level here, but configure children --> - <property name="childrenConfig"> - <map> - <entry key="subcachetypetest::123"> - <bean class="org.olat.core.util.cache.n.CacheConfig"> - <!-- for demo reason, let the values expire after 30 seconds --> - <property name="timeToLive" value="30" /> - <property name="timeToIdle" value="0" /> - <property name="maxElementsInMemory" value="1" /> - </bean> - </entry> - </map> - </property> - </bean> - </entry> - </map> - </property> - </bean> - </property> - </bean> - </property> + <property name="cacher" ref="infinispanCacher"/> </bean> <bean id="org.olat.core.util.coordinate.SingleVMCoordinator" class="org.olat.commons.coordinate.singlevm.SingleVMCoordinator" lazy-init="true"> - <property name="syncer" ref="org.olat.commons.coordinate.cluster.ClusterSyncer"/> - <property name="eventBus" ref="org.olat.commons.coordinate.singlevm.SingleVMEventBus"/> - <property name="locker" ref="org.olat.commons.coordinate.singlevm.SingleVMLocker"/> - - <property name="cacher"> - <!-- cache config, please note that settings can also stem from the file ehcache.xml (deprecated) --> - <bean class="org.olat.core.util.cache.n.impl.svm.SingleVMCacher" init-method="init"> - <property name="rootConfig"> - <bean class="org.olat.core.util.cache.n.CacheConfig"> - <property name="childrenConfig"> - <map> - <entry key="org.olat.login.LoginModule_blockafterfailedattempts" value-ref="org.olat.login.LoginModule_blockafterfailedattempts" /> - <entry key="org.olat.commons.servlets.RSSServlet_rssdocs" value-ref="org.olat.commons.servlets.RSSServlet_rssdocs"/> - <entry key="org.olat.ims.qti.process.QTIHelper_QTI_xml_Documents" value-ref="org.olat.ims.qti.process.QTIHelper_QTI_xml_Documents"/> - <entry key="org.olat.modules.wiki.WikiManager_wiki" value-ref="org.olat.modules.wiki.WikiManager_wiki"/> - <entry key="org.olat.commons.calendar.ICalFileCalendarManager_calendar" value-ref="org.olat.commons.calendar.ICalFileCalendarManager_calendar" /> - <entry key="org.olat.course.CourseFactory_courses" value-ref="org.olat.course.CourseFactory_courses" /> - <entry key="org.olat.collaboration.CollaborationToolsFactory_tools" value-ref="org.olat.collaboration.CollaborationToolsFactory_tools" /> - <entry key="org.olat.course.assessment.NewCachePersistingAssessmentManager" value-ref="org.olat.course.assessment.NewCachePersistingAssessmentManager" /> - <entry key="org.olat.core.util.UserSession" value-ref="org.olat.core.util.UserSession" /> - <entry key="org.olat.core.modules.glossary.GlossaryItemManager_glossary" value-ref="org.olat.core.modules.glossary.GlossaryItemManager_glossary"/> - <entry key="org.olat.course.nodes.projectbroker.service.ProjectBrokerManagerImpl_pb" value-ref="org.olat.course.nodes.projectbroker.service.ProjectBrokerManagerImpl_pb"/> - <entry key="org.olat.commons.servlets.WebDAVManagerImpl_webdav" value-ref="org.olat.commons.servlets.WebDAVManagerImpl_webdav" /> - </map> - </property> - </bean> - </property> - </bean> - </property> + <property name="syncer" ref="org.olat.commons.coordinate.cluster.ClusterSyncer"/> + <property name="eventBus" ref="org.olat.commons.coordinate.singlevm.SingleVMEventBus"/> + <property name="locker" ref="org.olat.commons.coordinate.singlevm.SingleVMLocker"/> + <property name="cacher" ref="infinispanCacher"/> +</bean> + +<bean id="infinispanCacheManager" class="org.olat.core.util.cache.n.InfinispanCacheManager"> + <property name="configuration" value="infinispan-config.xml"/> + <property name="jndiName" value="${infinispan.jndi}"/> +</bean> + +<bean id="infinispanCacher" class="org.olat.core.util.cache.n.InfinispanCacher" init-method="init"> + <constructor-arg index="0" ref="infinispanCacheManager"/> + <property name="rootConfig"> + <bean class="org.olat.core.util.cache.n.CacheConfig"> + <property name="childrenConfig"> + <map> + <entry key="org.olat.login.LoginModule_blockafterfailedattempts" value-ref="org.olat.login.LoginModule_blockafterfailedattempts" /> + <entry key="org.olat.commons.servlets.RSSServlet_rssdocs" value-ref="org.olat.commons.servlets.RSSServlet_rssdocs"/> + <entry key="org.olat.ims.qti.process.QTIHelper_QTI_xml_Documents" value-ref="org.olat.ims.qti.process.QTIHelper_QTI_xml_Documents"/> + <entry key="org.olat.modules.wiki.WikiManager_wiki" value-ref="org.olat.modules.wiki.WikiManager_wiki"/> + <entry key="org.olat.commons.calendar.ICalFileCalendarManager_calendar" value-ref="org.olat.commons.calendar.ICalFileCalendarManager_calendar" /> + <entry key="org.olat.course.CourseFactory_courses" value-ref="org.olat.course.CourseFactory_courses" /> + <entry key="org.olat.collaboration.CollaborationToolsFactory_tools" value-ref="org.olat.collaboration.CollaborationToolsFactory_tools" /> + <entry key="org.olat.course.assessment.NewCachePersistingAssessmentManager" value-ref="org.olat.course.assessment.NewCachePersistingAssessmentManager" /> + <entry key="org.olat.core.util.UserSession" value-ref="org.olat.core.util.UserSession" /> + <entry key="org.olat.core.modules.glossary.GlossaryItemManager_glossary" value-ref="org.olat.core.modules.glossary.GlossaryItemManager_glossary"/> + <entry key="org.olat.course.nodes.projectbroker.service.ProjectBrokerManagerImpl_pb" value-ref="org.olat.course.nodes.projectbroker.service.ProjectBrokerManagerImpl_pb"/> + <entry key="org.olat.commons.servlets.WebDAVManagerImpl_webdav" value-ref="org.olat.commons.servlets.WebDAVManagerImpl_webdav" /> + </map> + </property> + </bean> + </property> </bean> diff --git a/src/main/resources/treecache.xml b/src/main/resources/treecache.xml deleted file mode 100644 index 193ad4092e9..00000000000 --- a/src/main/resources/treecache.xml +++ /dev/null @@ -1,228 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0"> - - - <!-- - isolation levels supported: READ_COMMITTED and REPEATABLE_READ - nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated) - --> - <locking - isolationLevel="READ_COMMITTED" - lockParentForChildInsertRemove="false" - lockAcquisitionTimeout="20000" - nodeLockingScheme="mvcc" - writeSkewCheck="false" - concurrencyLevel="500"/> - - <!-- - Used to register a transaction manager and participate in ongoing transactions. - - <transaction - transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" - syncRollbackPhase="false" - syncCommitPhase="false"/> - --> - - <!-- - Used to register JMX statistics in any available MBean server - --> - <jmxStatistics - enabled="true"/> - - <!-- - If region based marshalling is used, defines whether new regions are inactive on startup. - --> - <startup - regionsInactiveOnStartup="true"/> - - <!-- - Used to register JVM shutdown hooks. - hookBehavior: DEFAULT, REGISTER, DONT_REGISTER - --> - <shutdown - hookBehavior="DEFAULT"/> - - <!-- - Used to define async listener notification thread pool size - --> - <listeners - asyncPoolSize="1" - asyncQueueSize="1000000"/> - - <!-- - Used to enable invocation batching and allow the use of Cache.startBatch()/endBatch() methods. - --> - <invocationBatching - enabled="false"/> - - <!-- - serialization related configuration, used for replication and cache loading - --> -<!-- <serialization - objectInputStreamPoolSize="12" - objectOutputStreamPoolSize="14" - version="3.0.0" - marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller" - useLazyDeserialization="false" - useRegionBasedMarshalling="false"/> ---> - - <!-- - This element specifies that the cache is clustered. - modes supported: replication (r) or invalidation (i). - --> - <clustering mode="replication" clusterName="JBossCache-cluster"> - - <!-- - Defines whether to retrieve state on startup - --> - <stateRetrieval timeout="20000" fetchInMemoryState="false"/> - - <!-- - Network calls are synchronous. - --> - <sync replTimeout="20000"/> - <!-- - Uncomment this for async replication. - --> - <!--<async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20" serializationExecutorQueueSize="5000000"/>--> - - <!-- Uncomment to use Buddy Replication --> - <!-- - <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000"> - <dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/> - <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator"> - <properties> - numBuddies = 1 - ignoreColocatedBuddies = true - </properties> - </locator> - </buddy> - --> - - <!-- - Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml - ships with jgroups.jar and will be picked up by the class loader. - --> - <jgroupsConfig> - - <UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2" - loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10" - mcast_port="@multicast.port@" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000" - oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4" - oob_thread_pool.min_threads="1" oob_thread_pool.queue_enabled="true" oob_thread_pool.queue_max_size="10" - oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true" - thread_pool.keep_alive_time="30000" thread_pool.max_threads="25" thread_pool.min_threads="1" - thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run" - tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true" - use_incoming_packet_handler="true"/> - <PING num_initial_members="3" timeout="2000"/> - <MERGE2 max_interval="30000" min_interval="10000"/> - <FD_SOCK/> - <FD max_tries="5" shun="true" timeout="10000"/> - <VERIFY_SUSPECT timeout="1500"/> - <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800" - use_mcast_xmit="false"/> - <UNICAST timeout="300,600,1200,2400,3600"/> - <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/> - <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000" - view_bundling="true"/> - <FRAG2 frag_size="60000"/> - <pbcast.STREAMING_STATE_TRANSFER/> - <pbcast.FLUSH timeout="0"/> - - </jgroupsConfig> - </clustering> - - <!-- - Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means - the eviction thread will never run. - --> - <eviction wakeUpInterval="500"> - <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000"> - <property name="maxNodes" value="5000"/> - <property name="timeToLive" value="1000"/> - </default> - <!-- Example - <region name="/org/jboss/data1"> - <property name="timeToLive" value="2000"/> - </region> - --> - <!-- TIMESTAMP-CACHE FOR QUERY CACHE --> - <region name="/TS" algorithmClass="org.jboss.cache.eviction.NullEvictionAlgorithm" /> - </eviction> - - <!-- - Cache loaders. - - If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state - is accessed again, it is removed from the cache loader and loaded into memory. - - Otherwise, state is always maintained in the cache loader as well as in memory. - - Set 'shared' to true if all instances in the cluster use the same cache loader instance, e.g., are talking to the - same database. - --> - <loaders passivation="false" shared="false"> - <preload> - <node fqn="/org/jboss"/> - <node fqn="/org/tempdata"/> - </preload> - - <!-- - we can have multiple cache loaders, which get chained - --> - <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" - ignoreModifications="true" purgeOnStartup="true"> - - <properties> - cache.jdbc.table.name=jbosscache - cache.jdbc.table.create=true - cache.jdbc.table.drop=true - cache.jdbc.table.primarykey=jbosscache_pk - cache.jdbc.fqn.column=fqn - cache.jdbc.fqn.type=varchar(255) - cache.jdbc.node.column=node - cache.jdbc.node.type=blob - cache.jdbc.parent.column=parent - cache.jdbc.sql-concat=1 || 2 - cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver - cache.jdbc.url=jdbc:derby:jbossdb;create=true - cache.jdbc.user=user1 - cache.jdbc.password=user1 - </properties> - <!-- alternatively use a connection from a datasorce, as per the code sample below--> - <!--<properties>--> - <!--cache.jdbc.datasource=AllSampleDS--> - <!--cache.jdbc.table.name=jbosscache--> - <!--cache.jdbc.table.create=true--> - <!--cache.jdbc.table.drop=true--> - <!--</properties>--> - <singletonStore enabled="true" class="org.jboss.cache.loader.SingletonStoreCacheLoader"> - <properties> - pushStateWhenCoordinator=true - pushStateWhenCoordinatorTimeout=20000 - </properties> - </singletonStore> - </loader> - </loaders> - - <!-- - Define custom interceptors. All custom interceptors need to extend org.jboss.cache.interceptors.base.CommandInterceptor - --> - <!-- - <customInterceptors> - <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"> - <property name="attrOne" value="value1" /> - <property name="attrTwo" value="value2" /> - </interceptor> - <interceptor position="last" class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> - <interceptor index="3" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> - <interceptor before="org.jboss.cache.interceptors.CallInterceptor" - class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> - <interceptor after="org.jboss.cache.interceptors.CallInterceptor" - class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> - </customInterceptors> - --> -</jbosscache> diff --git a/src/main/webapp-jbossas7/WEB-INF/jboss-deployment-structure.xml b/src/main/webapp-jbossas7/WEB-INF/jboss-deployment-structure.xml index 9f841caf9d1..138fbc9850d 100644 --- a/src/main/webapp-jbossas7/WEB-INF/jboss-deployment-structure.xml +++ b/src/main/webapp-jbossas7/WEB-INF/jboss-deployment-structure.xml @@ -9,5 +9,10 @@ <module name="org.codehaus.jackson.jackson-core-asl" /> <module name="org.codehaus.jackson.jackson-mapper-asl" /> </dependencies> + <exclusions> + <module name="org.apache.log4j" /> + <module name="org.slf4j" /> + <module name="org.apache.commons.logging" /> + </exclusions> </deployment> </jboss-deployment-structure> diff --git a/src/main/webapp-jbossas7/WEB-INF/web.xml b/src/main/webapp-jbossas7/WEB-INF/web.xml index 28e771dc555..d19be54471a 100644 --- a/src/main/webapp-jbossas7/WEB-INF/web.xml +++ b/src/main/webapp-jbossas7/WEB-INF/web.xml @@ -9,7 +9,7 @@ <!-- IMPORTANT : DO NOT CHANGE SEQUENCE OF XML TYPES BECAUSE VALIDATION MAY FAIL --> <!-- Please check before checkin http://www.xmlvalidation.com/index.php --> <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> - + <distributable/> <display-name>OLAT Online Learning and Training</display-name> <description> Online Learning and Training Application (OLAT) is a Learning Management Platform. diff --git a/src/test/java/org/olat/core/dispatcher/mapper/MapperServiceTest.java b/src/test/java/org/olat/core/dispatcher/mapper/MapperServiceTest.java index 1d465b9cb0b..3f484f2745c 100644 --- a/src/test/java/org/olat/core/dispatcher/mapper/MapperServiceTest.java +++ b/src/test/java/org/olat/core/dispatcher/mapper/MapperServiceTest.java @@ -31,6 +31,7 @@ import org.junit.Test; import org.olat.core.commons.persistence.DB; import org.olat.core.dispatcher.mapper.manager.MapperDAO; import org.olat.core.gui.media.MediaResource; +import org.olat.core.util.CodeHelper; import org.olat.core.util.SessionInfo; import org.olat.core.util.UserSession; import org.olat.core.util.session.UserSessionManager; @@ -183,7 +184,7 @@ public class MapperServiceTest extends OlatTestCase { private UserSession createUserSession() { HttpSession httpSession = new MockHttpSession(); UserSession userSession = sessionManager.getUserSession(httpSession); - SessionInfo infos = new SessionInfo(UUID.randomUUID().toString(), httpSession); + SessionInfo infos = new SessionInfo(CodeHelper.getRAMUniqueID(), UUID.randomUUID().toString(), httpSession); userSession.setSessionInfo(infos); //check if our mocked HTTP session makes what we want Assert.assertNotNull(userSession.getSessionInfo()); diff --git a/src/test/java/org/olat/course/nodes/feed/FunctionalBlogTest.java b/src/test/java/org/olat/course/nodes/feed/FunctionalBlogTest.java index fc86ae4c2b3..d224d8d65ca 100644 --- a/src/test/java/org/olat/course/nodes/feed/FunctionalBlogTest.java +++ b/src/test/java/org/olat/course/nodes/feed/FunctionalBlogTest.java @@ -22,9 +22,7 @@ package org.olat.course.nodes.feed; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; @@ -47,14 +45,11 @@ import org.olat.user.restapi.UserVO; import org.olat.util.FunctionalAdministrationSiteUtil; import org.olat.util.FunctionalCourseUtil; import org.olat.util.FunctionalCourseUtil.BlogEdit; +import org.olat.util.FunctionalCourseUtil.CourseNodeAlias; import org.olat.util.FunctionalRepositorySiteUtil; import org.olat.util.FunctionalUtil; -import org.olat.util.FunctionalUtil.OlatSite; import org.olat.util.FunctionalUtil.WaitLimitAttribute; import org.olat.util.FunctionalVOUtil; -import org.olat.util.FunctionalCourseUtil.CourseNodeAlias; -import org.olat.util.browser.Browser1; -import org.olat.util.browser.Browser2; import org.olat.util.browser.Student1; import org.olat.util.browser.Student2; import org.olat.util.browser.Tutor1; @@ -215,8 +210,8 @@ public class FunctionalBlogTest { Assert.assertTrue(functionalUtil.login(browser, functionalUtil.getUsername(), functionalUtil.getPassword(), true)); Assert.assertTrue(functionalAdministrationSiteUtil.clearCache(browser, new String[]{ - "org.olat.core.util.cache.n.impl.svm.SingleVMCacher@org.olat.modules.webFeed.dispatching.Path_feed__0", - "org.olat.core.util.cache.n.impl.svm.SingleVMCacher@org.olat.modules.webFeed.managers.FeedManagerImpl_feed__0" + "SingleVMCacher@org.olat.modules.webFeed.dispatching.Path_feed__0", + "SingleVMCacher@org.olat.modules.webFeed.managers.FeedManagerImpl_feed__0" } )); diff --git a/src/test/java/org/olat/modules/webFeed/FeedManagerImplTest.java b/src/test/java/org/olat/modules/webFeed/FeedManagerImplTest.java index dd0f2cb1718..99c4a5dc5fb 100644 --- a/src/test/java/org/olat/modules/webFeed/FeedManagerImplTest.java +++ b/src/test/java/org/olat/modules/webFeed/FeedManagerImplTest.java @@ -75,7 +75,7 @@ public class FeedManagerImplTest extends OlatTestCase { Item item = new Item(); item.setTitle("My Test Item"); feed = feedManager.updateFeedMode(Boolean.FALSE, feed); - feedManager.addItem(item, null, feed); + feed = feedManager.addItem(item, null, feed); } /** -- GitLab