From 5b84c2ad11ae9eef8903f925f85a1c5920fc5eab Mon Sep 17 00:00:00 2001 From: Mykhail DIachenko Date: Thu, 23 Apr 2020 20:39:16 +0300 Subject: [PATCH] =?UTF-8?q?MNT-21514=C2=A0=20ACS-22:=C2=A0=20Added=20new?= =?UTF-8?q?=20secondary=20cache=20map=20to=20avoid=20performance=20bottlen?= =?UTF-8?q?eck=20in=20InMe=E2=80=A6=20(#949)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added new secondary cache map to avoid performance bottleneck in InMemoryTicketComponent in clustered environment * Fixed AuthenticationTest * Change line separators back --- pom.xml | 2 +- .../alfresco/authentication-services-context.xml | 3 +++ src/main/resources/alfresco/cache-context.xml | 4 ++++ src/main/resources/alfresco/caches.properties | 9 +++++++++ .../repo/security/authentication/AuthenticationTest.java | 9 +++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8335d551c6..98421083dc 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ 11 - 8.50.10 + 8.50.11 7.31 6.2 diff --git a/src/main/resources/alfresco/authentication-services-context.xml b/src/main/resources/alfresco/authentication-services-context.xml index 6e39b09fe5..6aeaa86987 100644 --- a/src/main/resources/alfresco/authentication-services-context.xml +++ b/src/main/resources/alfresco/authentication-services-context.xml @@ -598,6 +598,9 @@ + + + diff --git a/src/main/resources/alfresco/cache-context.xml b/src/main/resources/alfresco/cache-context.xml index cea342ff55..091fb721c4 100644 --- a/src/main/resources/alfresco/cache-context.xml +++ b/src/main/resources/alfresco/cache-context.xml @@ -280,6 +280,10 @@ + + + + diff --git a/src/main/resources/alfresco/caches.properties b/src/main/resources/alfresco/caches.properties index 6d4a682776..0b68415ccc 100644 --- a/src/main/resources/alfresco/caches.properties +++ b/src/main/resources/alfresco/caches.properties @@ -333,6 +333,15 @@ cache.ticketsCache.eviction-policy=LRU cache.ticketsCache.merge-policy=com.hazelcast.map.merge.PutIfAbsentMapMergePolicy 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.statsEnabled=${caches.tx.statsEnabled} diff --git a/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java b/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java index d082dbf09b..0125ddcd54 100644 --- a/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java +++ b/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java @@ -103,6 +103,7 @@ public class AuthenticationTest extends TestCase private AuthenticationManager authenticationManager; private TicketComponent ticketComponent; private SimpleCache ticketsCache; + private SimpleCache usernameKey; private MutableAuthenticationService authenticationService; private MutableAuthenticationService pubAuthenticationService; private AuthenticationComponent authenticationComponent; @@ -173,6 +174,7 @@ public class AuthenticationTest extends TestCase // permissionServiceSPI = (PermissionServiceSPI) // ctx.getBean("permissionService"); ticketsCache = (SimpleCache) ctx.getBean("ticketsCache"); + usernameKey = (SimpleCache) ctx.getBean("usernameKeyCache"); ChildApplicationContextFactory sysAdminSubsystem = (ChildApplicationContextFactory) ctx.getBean("sysAdmin"); assertNotNull("sysAdminSubsystem", sysAdminSubsystem); @@ -845,6 +847,7 @@ public class AuthenticationTest extends TestCase tc.setTicketsExpire(false); tc.setValidDuration("P0D"); tc.setTicketsCache(ticketsCache); + tc.setUsernameKey(usernameKey); dao.createUser("Andy", "ticket".toCharArray()); @@ -871,6 +874,7 @@ public class AuthenticationTest extends TestCase tc.setTicketsExpire(false); tc.setValidDuration("P0D"); tc.setTicketsCache(ticketsCache); + tc.setUsernameKey(usernameKey); dao.createUser("Andy", "ticket".toCharArray()); @@ -900,12 +904,14 @@ public class AuthenticationTest extends TestCase public void testTicketExpiryMode() { ticketsCache.clear(); + usernameKey.clear(); InMemoryTicketComponentImpl tc = new InMemoryTicketComponentImpl(); tc.setOneOff(false); tc.setTicketsExpire(true); tc.setValidDuration("P5S"); tc.setTicketsCache(ticketsCache); + tc.setUsernameKey(usernameKey); tc.setExpiryMode(ExpiryMode.AFTER_FIXED_TIME.toString()); dao.createUser("Andy", "ticket".toCharArray()); @@ -1043,11 +1049,13 @@ public class AuthenticationTest extends TestCase public void testTicketExpires() { ticketsCache.clear(); + usernameKey.clear(); InMemoryTicketComponentImpl tc = new InMemoryTicketComponentImpl(); tc.setOneOff(false); tc.setTicketsExpire(true); tc.setValidDuration("P5S"); tc.setTicketsCache(ticketsCache); + tc.setUsernameKey(usernameKey); dao.createUser("Andy", "ticket".toCharArray()); @@ -1141,6 +1149,7 @@ public class AuthenticationTest extends TestCase tc.setTicketsExpire(true); tc.setValidDuration("P1D"); tc.setTicketsCache(ticketsCache); + tc.setUsernameKey(usernameKey); dao.createUser("Andy", "ticket".toCharArray());