usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject usergrid git commit: Fix cache invalidation issues.
Date Fri, 01 Apr 2016 06:03:28 GMT
Repository: usergrid
Updated Branches:
  refs/heads/release-2.1.1 9b56fb2ce -> 492ac59ad


Fix cache invalidation issues.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/492ac59a
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/492ac59a
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/492ac59a

Branch: refs/heads/release-2.1.1
Commit: 492ac59ada40d05b7c1e5c0f8399ff7ec9000bd5
Parents: 9b56fb2
Author: Michael Russo <mrusso@apigee.com>
Authored: Thu Mar 31 23:03:26 2016 -0700
Committer: Michael Russo <mrusso@apigee.com>
Committed: Thu Mar 31 23:03:26 2016 -0700

----------------------------------------------------------------------
 .../org/apache/usergrid/rest/test/resource/AbstractRestIT.java | 3 ---
 .../usergrid/management/cassandra/ManagementServiceImpl.java   | 6 ++++++
 .../java/org/apache/usergrid/services/AbstractService.java     | 3 +++
 .../org/apache/usergrid/services/groups/GroupsService.java     | 4 ++++
 .../java/org/apache/usergrid/services/roles/RolesService.java  | 2 ++
 .../java/org/apache/usergrid/services/users/UsersService.java  | 2 ++
 .../org/apache/usergrid/services/users/roles/RolesService.java | 4 ++++
 7 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/492ac59a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
index d2f572f..6e5e4f9 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
@@ -61,9 +61,6 @@ public class AbstractRestIT extends JerseyTest {
     public static TomcatRuntime tomcatRuntime = TomcatRuntime.getInstance();
 
     @Rule
-    public ClearShiroSubject clearShiroSubject = new ClearShiroSubject();
-
-    @Rule
     public ClientSetup clientSetup = new ClientSetup( this.getBaseURI().toString() );
 
     protected static final Application descriptor = new Application();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/492ac59a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index 56e1de7..b66a0ad 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -64,6 +64,7 @@ import org.apache.usergrid.security.shiro.credentials.ApplicationClientCredentia
 import org.apache.usergrid.security.shiro.credentials.OrganizationClientCredentials;
 import org.apache.usergrid.security.shiro.principals.ApplicationPrincipal;
 import org.apache.usergrid.security.shiro.principals.OrganizationPrincipal;
+import org.apache.usergrid.security.shiro.utils.LocalShiroCache;
 import org.apache.usergrid.security.shiro.utils.SubjectUtils;
 import org.apache.usergrid.security.tokens.TokenCategory;
 import org.apache.usergrid.security.tokens.TokenInfo;
@@ -169,6 +170,8 @@ public class ManagementServiceImpl implements ManagementService {
 
     protected ApplicationService service;
 
+    protected LocalShiroCache localShiroCache;
+
 
 
     /** Must be constructed with a CassandraClientPool. */
@@ -179,6 +182,7 @@ public class ManagementServiceImpl implements ManagementService {
         this.cacheFactory = injector.getInstance( CacheFactory.class );
         this.aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class);
         this.service = injector.getInstance(ApplicationService.class);
+        this.localShiroCache = injector.getInstance(LocalShiroCache.class);
 
     }
 
@@ -1764,6 +1768,7 @@ public class ManagementServiceImpl implements ManagementService {
         ScopedCache scopedCache = cacheFactory.getScopedCache(
             new CacheScope( new SimpleId( CpNamingUtils.MANAGEMENT_APPLICATION_ID, "application"
)));
         scopedCache.invalidate();
+        localShiroCache.invalidateAll();
 
         return new ApplicationInfo( applicationId, appInfo.getName() );
     }
@@ -1825,6 +1830,7 @@ public class ManagementServiceImpl implements ManagementService {
         ScopedCache scopedCache = cacheFactory.getScopedCache(
             new CacheScope( new SimpleId( CpNamingUtils.MANAGEMENT_APPLICATION_ID, "application"
)));
         scopedCache.invalidate();
+        localShiroCache.invalidateAll();
 
         return new ApplicationInfo( applicationId, appInfo.getName() );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/492ac59a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
index 5d818cc..3bbd859 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
@@ -33,6 +33,7 @@ import org.apache.usergrid.corepersistence.rx.impl.ResponseImportTasks;
 import org.apache.usergrid.corepersistence.service.ServiceSchedulerFig;
 import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.metrics.ObservableTimer;
+import org.apache.usergrid.security.shiro.utils.LocalShiroCache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.ApplicationContext;
@@ -112,6 +113,7 @@ public abstract class AbstractService implements Service {
     private Timer invokeTimer;
 
     protected CacheFactory cacheFactory;
+    protected LocalShiroCache localShiroCache;
 
     public AbstractService() {
 
@@ -131,6 +133,7 @@ public abstract class AbstractService implements Service {
         this.invokeTimer = metricsFactory.getTimer( this.getClass(),"service.invoke" );
 
         this.cacheFactory = injector.getInstance( CacheFactory.class );
+        this.localShiroCache = injector.getInstance( LocalShiroCache.class );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/492ac59a/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
b/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
index 01012aa..aa125d4 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
@@ -99,6 +99,7 @@ public class GroupsService extends AbstractPathBasedColllectionService {
         em.addGroupToRole( groupId, roleName );
         ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
         scopedCache.invalidate();
+        localShiroCache.invalidateAll();
         return getGroupRoles( groupId );
     }
 
@@ -107,6 +108,7 @@ public class GroupsService extends AbstractPathBasedColllectionService
{
         em.removeGroupFromRole( groupId, roleName );
         ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
         scopedCache.invalidate();
+        localShiroCache.invalidateAll();
         return getGroupRoles( groupId );
     }
 
@@ -161,6 +163,7 @@ public class GroupsService extends AbstractPathBasedColllectionService
{
             em.grantGroupPermission( entityRef.getUuid(), permission );
             ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
             scopedCache.invalidate();
+            localShiroCache.invalidateAll();
 
             return genericServiceResults().withData( em.getGroupPermissions( entityRef.getUuid()
) );
         }
@@ -230,6 +233,7 @@ public class GroupsService extends AbstractPathBasedColllectionService
{
             }
             ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
             scopedCache.invalidate();
+            localShiroCache.invalidateAll();
 
             return genericServiceResults().withData( em.getGroupPermissions( entityRef.getUuid()
) );
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/492ac59a/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
b/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
index 09209cc..257c513 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
@@ -211,6 +211,7 @@ public class RolesService extends AbstractCollectionService {
         em.grantRolePermission(roleName, permission);
         ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
         scopedCache.invalidate();
+        localShiroCache.invalidateAll();
         return getApplicationRolePermissions( roleName );
     }
 
@@ -219,6 +220,7 @@ public class RolesService extends AbstractCollectionService {
         em.revokeRolePermission( roleName, permission );
         ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
         scopedCache.invalidate();
+        localShiroCache.invalidateAll();
         return getApplicationRolePermissions( roleName );
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/492ac59a/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
b/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
index 3092a0e..0539695 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
@@ -218,6 +218,7 @@ public class UsersService extends AbstractCollectionService {
             em.grantUserPermission( entityRef.getUuid(), permission );
             ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
             scopedCache.invalidate();
+            localShiroCache.invalidateAll();
 
             return genericServiceResults().withData( em.getUserPermissions( entityRef.getUuid()
) );
         }
@@ -288,6 +289,7 @@ public class UsersService extends AbstractCollectionService {
 
             ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
             scopedCache.invalidate();
+            localShiroCache.invalidateAll();
 
             return genericServiceResults().withData( em.getUserPermissions( entityRef.getUuid()
) );
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/492ac59a/stack/services/src/main/java/org/apache/usergrid/services/users/roles/RolesService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/users/roles/RolesService.java
b/stack/services/src/main/java/org/apache/usergrid/services/users/roles/RolesService.java
index 1f7637f..2a6fb5d 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/users/roles/RolesService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/users/roles/RolesService.java
@@ -52,6 +52,7 @@ public class RolesService extends org.apache.usergrid.services.roles.RolesServic
             em.addUserToRole( user.getUuid(), entity.getName() );
             ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
             scopedCache.invalidate();
+            localShiroCache.invalidateAll();
         }
         return new ServiceResults( this, context, Type.COLLECTION, Results.fromRef( entity
), null, null );
     }
@@ -65,6 +66,7 @@ public class RolesService extends org.apache.usergrid.services.roles.RolesServic
             em.addUserToRole( user.getUuid(), entity.getName() );
             ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
             scopedCache.invalidate();
+            localShiroCache.invalidateAll();
         }
         return new ServiceResults( this, context, Type.COLLECTION, Results.fromRef( entity
), null, null );
     }
@@ -78,6 +80,7 @@ public class RolesService extends org.apache.usergrid.services.roles.RolesServic
             em.removeUserFromRole( user.getUuid(), results.getEntity().getName() );
             ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
             scopedCache.invalidate();
+            localShiroCache.invalidateAll();
         }
         return results;
     }
@@ -91,6 +94,7 @@ public class RolesService extends org.apache.usergrid.services.roles.RolesServic
             em.removeUserFromRole( user.getUuid(), results.getEntity().getName() );
             ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId()));
             scopedCache.invalidate();
+            localShiroCache.invalidateAll();
         }
         return results;
     }


Mime
View raw message