MNT-21514  ACS-22:  Added new secondary cache map to avoid performance bottleneck in InMe… (#949)

* Added new secondary cache map to avoid performance bottleneck in InMemoryTicketComponent in clustered environment

* Fixed AuthenticationTest

* Change line separators back
This commit is contained in:
Mykhail DIachenko
2020-04-23 20:39:16 +03:00
parent 50da066416
commit 5b84c2ad11
5 changed files with 26 additions and 1 deletions

View File

@@ -36,7 +36,7 @@
<maven.build.sourceVersion>11</maven.build.sourceVersion> <maven.build.sourceVersion>11</maven.build.sourceVersion>
<dependency.alfresco-data-model.version>8.50.10</dependency.alfresco-data-model.version> <dependency.alfresco-data-model.version>8.50.11</dependency.alfresco-data-model.version>
<dependency.alfresco-core.version>7.31</dependency.alfresco-core.version> <dependency.alfresco-core.version>7.31</dependency.alfresco-core.version>
<dependency.alfresco-legacy-lucene.version>6.2</dependency.alfresco-legacy-lucene.version> <dependency.alfresco-legacy-lucene.version>6.2</dependency.alfresco-legacy-lucene.version>

View File

@@ -598,6 +598,9 @@
<property name="ticketsCache"> <property name="ticketsCache">
<ref bean="ticketsCache" /> <ref bean="ticketsCache" />
</property> </property>
<property name="usernameKey">
<ref bean="usernameKeyCache" />
</property>
<!-- The period for which tickets are valid in XML duration format. --> <!-- The period for which tickets are valid in XML duration format. -->
<!-- The default is PT1H for one hour. --> <!-- The default is PT1H for one hour. -->
<property name="validDuration"> <property name="validDuration">

View File

@@ -281,6 +281,10 @@
<constructor-arg value="cache.ticketsCache"/> <constructor-arg value="cache.ticketsCache"/>
</bean> </bean>
<bean name="usernameKeyCache" factory-bean="cacheFactory" factory-method="createCache">
<constructor-arg value="cache.usernameKeyCache"/>
</bean>
<!-- ===================================== --> <!-- ===================================== -->
<!-- WebServices Query Session Cache --> <!-- WebServices Query Session Cache -->
<!-- ===================================== --> <!-- ===================================== -->

View File

@@ -333,6 +333,15 @@ cache.ticketsCache.eviction-policy=LRU
cache.ticketsCache.merge-policy=com.hazelcast.map.merge.PutIfAbsentMapMergePolicy cache.ticketsCache.merge-policy=com.hazelcast.map.merge.PutIfAbsentMapMergePolicy
cache.ticketsCache.readBackupData=false cache.ticketsCache.readBackupData=false
cache.usernameKeyCache.maxItems=1000
cache.usernameKeyCache.timeToLiveSeconds=0
cache.usernameKeyCache.maxIdleSeconds=0
cache.usernameKeyCache.cluster.type=fully-distributed
cache.usernameKeyCache.backup-count=1
cache.usernameKeyCache.eviction-policy=LRU
cache.usernameKeyCache.merge-policy=com.hazelcast.map.merge.PutIfAbsentMapMergePolicy
cache.usernameKeyCache.readBackupData=false
cache.authorityEntitySharedCache.tx.maxItems=50000 cache.authorityEntitySharedCache.tx.maxItems=50000
cache.authorityEntitySharedCache.tx.statsEnabled=${caches.tx.statsEnabled} cache.authorityEntitySharedCache.tx.statsEnabled=${caches.tx.statsEnabled}

View File

@@ -103,6 +103,7 @@ public class AuthenticationTest extends TestCase
private AuthenticationManager authenticationManager; private AuthenticationManager authenticationManager;
private TicketComponent ticketComponent; private TicketComponent ticketComponent;
private SimpleCache<String, Ticket> ticketsCache; private SimpleCache<String, Ticket> ticketsCache;
private SimpleCache<String, String> usernameKey;
private MutableAuthenticationService authenticationService; private MutableAuthenticationService authenticationService;
private MutableAuthenticationService pubAuthenticationService; private MutableAuthenticationService pubAuthenticationService;
private AuthenticationComponent authenticationComponent; private AuthenticationComponent authenticationComponent;
@@ -173,6 +174,7 @@ public class AuthenticationTest extends TestCase
// permissionServiceSPI = (PermissionServiceSPI) // permissionServiceSPI = (PermissionServiceSPI)
// ctx.getBean("permissionService"); // ctx.getBean("permissionService");
ticketsCache = (SimpleCache<String, Ticket>) ctx.getBean("ticketsCache"); ticketsCache = (SimpleCache<String, Ticket>) ctx.getBean("ticketsCache");
usernameKey = (SimpleCache<String, String>) ctx.getBean("usernameKeyCache");
ChildApplicationContextFactory sysAdminSubsystem = (ChildApplicationContextFactory) ctx.getBean("sysAdmin"); ChildApplicationContextFactory sysAdminSubsystem = (ChildApplicationContextFactory) ctx.getBean("sysAdmin");
assertNotNull("sysAdminSubsystem", sysAdminSubsystem); assertNotNull("sysAdminSubsystem", sysAdminSubsystem);
@@ -845,6 +847,7 @@ public class AuthenticationTest extends TestCase
tc.setTicketsExpire(false); tc.setTicketsExpire(false);
tc.setValidDuration("P0D"); tc.setValidDuration("P0D");
tc.setTicketsCache(ticketsCache); tc.setTicketsCache(ticketsCache);
tc.setUsernameKey(usernameKey);
dao.createUser("Andy", "ticket".toCharArray()); dao.createUser("Andy", "ticket".toCharArray());
@@ -871,6 +874,7 @@ public class AuthenticationTest extends TestCase
tc.setTicketsExpire(false); tc.setTicketsExpire(false);
tc.setValidDuration("P0D"); tc.setValidDuration("P0D");
tc.setTicketsCache(ticketsCache); tc.setTicketsCache(ticketsCache);
tc.setUsernameKey(usernameKey);
dao.createUser("Andy", "ticket".toCharArray()); dao.createUser("Andy", "ticket".toCharArray());
@@ -900,12 +904,14 @@ public class AuthenticationTest extends TestCase
public void testTicketExpiryMode() public void testTicketExpiryMode()
{ {
ticketsCache.clear(); ticketsCache.clear();
usernameKey.clear();
InMemoryTicketComponentImpl tc = new InMemoryTicketComponentImpl(); InMemoryTicketComponentImpl tc = new InMemoryTicketComponentImpl();
tc.setOneOff(false); tc.setOneOff(false);
tc.setTicketsExpire(true); tc.setTicketsExpire(true);
tc.setValidDuration("P5S"); tc.setValidDuration("P5S");
tc.setTicketsCache(ticketsCache); tc.setTicketsCache(ticketsCache);
tc.setUsernameKey(usernameKey);
tc.setExpiryMode(ExpiryMode.AFTER_FIXED_TIME.toString()); tc.setExpiryMode(ExpiryMode.AFTER_FIXED_TIME.toString());
dao.createUser("Andy", "ticket".toCharArray()); dao.createUser("Andy", "ticket".toCharArray());
@@ -1043,11 +1049,13 @@ public class AuthenticationTest extends TestCase
public void testTicketExpires() public void testTicketExpires()
{ {
ticketsCache.clear(); ticketsCache.clear();
usernameKey.clear();
InMemoryTicketComponentImpl tc = new InMemoryTicketComponentImpl(); InMemoryTicketComponentImpl tc = new InMemoryTicketComponentImpl();
tc.setOneOff(false); tc.setOneOff(false);
tc.setTicketsExpire(true); tc.setTicketsExpire(true);
tc.setValidDuration("P5S"); tc.setValidDuration("P5S");
tc.setTicketsCache(ticketsCache); tc.setTicketsCache(ticketsCache);
tc.setUsernameKey(usernameKey);
dao.createUser("Andy", "ticket".toCharArray()); dao.createUser("Andy", "ticket".toCharArray());
@@ -1141,6 +1149,7 @@ public class AuthenticationTest extends TestCase
tc.setTicketsExpire(true); tc.setTicketsExpire(true);
tc.setValidDuration("P1D"); tc.setValidDuration("P1D");
tc.setTicketsCache(ticketsCache); tc.setTicketsCache(ticketsCache);
tc.setUsernameKey(usernameKey);
dao.createUser("Andy", "ticket".toCharArray()); dao.createUser("Andy", "ticket".toCharArray());