@SuppressWarnings("unchecked") @Test public void testExecute() { final List<UserActionRequest> requests = new ArrayList<UserActionRequest>(); final int maxCacheListSize = 10000; final String shortName = "shortname"; final DeleteGroupResponse deleteGroupResponse = new DeleteGroupResponse(groupId, shortName, 3L); sut = new DeleteGroupFromDBExecution(deleteGroupActivityDAO, removeGroupFollowersDAO, deleteGroupDAO, deleteGroupSubscriptionsDAO, maxCacheListSize); context.checking(new Expectations() { { allowing(taskHandlerConext).getActionContext(); will(returnValue(actionContext)); allowing(actionContext).getParams(); will(returnValue(groupId)); allowing(deleteGroupActivityDAO).execute(groupId); allowing(removeGroupFollowersDAO).execute(groupId); allowing(deleteGroupSubscriptionsDAO).execute( with(any(DeleteAllFeedSubscriberByEntityTypeAndIdRequest.class))); allowing(deleteGroupDAO).execute(groupId); will(returnValue(deleteGroupResponse)); allowing(taskHandlerConext).getUserActionRequests(); will(returnValue(requests)); } }); sut.execute(taskHandlerConext); Set<String> keysToDelete = (Set<String>) (requests.get(0)).getParams(); Assert.assertEquals(7, keysToDelete.size()); Assert.assertTrue(keysToDelete.contains(CacheKeys.GROUP_BY_SHORT_NAME + shortName)); Assert.assertTrue(keysToDelete.contains(CacheKeys.FOLLOWERS_BY_GROUP + groupId)); Assert.assertTrue(keysToDelete.contains(CacheKeys.COORDINATOR_PERSON_IDS_BY_GROUP_ID + groupId)); Assert.assertTrue(keysToDelete.contains(CacheKeys.GROUP_BY_ID + groupId)); Assert.assertTrue(keysToDelete.contains(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + 3)); Assert.assertTrue(keysToDelete.contains(CacheKeys.STREAM_SCOPE_ID_BY_GROUP_SHORT_NAME + shortName)); Assert.assertTrue(keysToDelete.contains(CacheKeys.POPULAR_HASH_TAGS_BY_STREAM_TYPE_AND_SHORT_NAME + ScopeType.GROUP + "-" + shortName)); context.assertIsSatisfied(); }
@Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long groupId = (Long) inActionContext.getActionContext().getParams(); Long startDB = null; if (log.isInfoEnabled()) { startDB = System.currentTimeMillis(); } Long startTime = null; Long endTime = null; if (log.isDebugEnabled()) { log.debug("Deleting activities for groupid:" + groupId); startTime = System.currentTimeMillis(); } BulkActivityDeleteResponse deleteActivityResponse = deleteGroupActivityDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to delete activities/comments: " + (endTime - startTime)); log.debug("Removing followers for groupid:" + groupId); startTime = endTime; } List<Long> followerIds = removeGroupFollowersDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove followers from group: " + (endTime - startTime)); log.debug("Removing group subscriptions for groupid:" + groupId); startTime = endTime; } deleteGroupFeedSubscriptions.execute(new DeleteAllFeedSubscriberByEntityTypeAndIdRequest(groupId, EntityType.GROUP)); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group subscriptions: " + (endTime - startTime)); log.debug("Removing group and associated objects for groupid:" + groupId); startTime = endTime; } DeleteGroupResponse deleteGroupResponse = deleteGroupDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group and associated objects: " + (endTime - startTime)); } Long endDB = null; if (log.isInfoEnabled()) { endDB = System.currentTimeMillis(); } Long startAsync = null; if (log.isInfoEnabled()) { startAsync = System.currentTimeMillis(); } int startSize = 0; int endSize = 0; if (log.isDebugEnabled()) { startSize = inActionContext.getUserActionRequests().size(); } generateSingleDeleteKeyFromCacheTask(getKeysToPurgeFromCache(deleteGroupResponse), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge fixed set of cache keys: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromListTasks(createKeys(CacheKeys.GROUPS_FOLLOWED_BY_PERSON, followerIds), Collections .singletonList(deleteGroupResponse.getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove group id from GROUPS_FOLLOWED_BY_PERSON lists: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromStarredActivityListTasks(deleteActivityResponse, inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove groups activity ids from starred activity lists: " + (endSize - startSize)); } List<Long> cachedActivityIds = deleteActivityResponse.getActivityIds().size() > maxCacheListSize ? deleteActivityResponse.getActivityIds().subList(0, maxCacheListSize - 1) : deleteActivityResponse.getActivityIds(); startSize = endSize; if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove activity ids from parent orgs of the deleted group: " + (endSize - startSize)); } generateRemoveIdsFromListTasks(Collections.singletonList(CacheKeys.EVERYONE_ACTIVITY_IDS), cachedActivityIds, inActionContext); startSize = endSize; generateDeleteFromSearchIndexTasks(DomainGroup.class, Collections.singletonList(deleteGroupResponse .getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge group from search index: " + (endSize - startSize)); } startSize = endSize; generateDeleteFromSearchIndexTasks(Activity.class, deleteActivityResponse.getActivityIds(), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge ALL activities from search index: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.ACTIVITY_BY_ID, deleteActivityResponse.getActivityIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL activities from cache: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.COMMENT_BY_ID, deleteActivityResponse.getCommentIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL comments from cache: " + (endSize - startSize)); log.debug("Total async tasks for delete: " + endSize); } if (log.isInfoEnabled()) { long now = System.currentTimeMillis(); String logMessage = "GroupId: " + groupId + " DB delete: " + (endDB - startDB) + " Async task generation: " + (now - startAsync) + " Total time: " + (now - startDB); log.info(logMessage); } return Boolean.TRUE; }
DeleteGroupFromDBExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long groupId = (Long) inActionContext.getActionContext().getParams(); Long startDB = null; if (log.isInfoEnabled()) { startDB = System.currentTimeMillis(); } Long startTime = null; Long endTime = null; if (log.isDebugEnabled()) { log.debug("Deleting activities for groupid:" + groupId); startTime = System.currentTimeMillis(); } BulkActivityDeleteResponse deleteActivityResponse = deleteGroupActivityDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to delete activities/comments: " + (endTime - startTime)); log.debug("Removing followers for groupid:" + groupId); startTime = endTime; } List<Long> followerIds = removeGroupFollowersDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove followers from group: " + (endTime - startTime)); log.debug("Removing group subscriptions for groupid:" + groupId); startTime = endTime; } deleteGroupFeedSubscriptions.execute(new DeleteAllFeedSubscriberByEntityTypeAndIdRequest(groupId, EntityType.GROUP)); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group subscriptions: " + (endTime - startTime)); log.debug("Removing group and associated objects for groupid:" + groupId); startTime = endTime; } DeleteGroupResponse deleteGroupResponse = deleteGroupDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group and associated objects: " + (endTime - startTime)); } Long endDB = null; if (log.isInfoEnabled()) { endDB = System.currentTimeMillis(); } Long startAsync = null; if (log.isInfoEnabled()) { startAsync = System.currentTimeMillis(); } int startSize = 0; int endSize = 0; if (log.isDebugEnabled()) { startSize = inActionContext.getUserActionRequests().size(); } generateSingleDeleteKeyFromCacheTask(getKeysToPurgeFromCache(deleteGroupResponse), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge fixed set of cache keys: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromListTasks(createKeys(CacheKeys.GROUPS_FOLLOWED_BY_PERSON, followerIds), Collections .singletonList(deleteGroupResponse.getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove group id from GROUPS_FOLLOWED_BY_PERSON lists: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromStarredActivityListTasks(deleteActivityResponse, inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove groups activity ids from starred activity lists: " + (endSize - startSize)); } List<Long> cachedActivityIds = deleteActivityResponse.getActivityIds().size() > maxCacheListSize ? deleteActivityResponse.getActivityIds().subList(0, maxCacheListSize - 1) : deleteActivityResponse.getActivityIds(); startSize = endSize; if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove activity ids from parent orgs of the deleted group: " + (endSize - startSize)); } generateRemoveIdsFromListTasks(Collections.singletonList(CacheKeys.EVERYONE_ACTIVITY_IDS), cachedActivityIds, inActionContext); startSize = endSize; generateDeleteFromSearchIndexTasks(DomainGroup.class, Collections.singletonList(deleteGroupResponse .getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge group from search index: " + (endSize - startSize)); } startSize = endSize; generateDeleteFromSearchIndexTasks(Activity.class, deleteActivityResponse.getActivityIds(), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge ALL activities from search index: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.ACTIVITY_BY_ID, deleteActivityResponse.getActivityIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL activities from cache: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.COMMENT_BY_ID, deleteActivityResponse.getCommentIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL comments from cache: " + (endSize - startSize)); log.debug("Total async tasks for delete: " + endSize); } if (log.isInfoEnabled()) { long now = System.currentTimeMillis(); String logMessage = "GroupId: " + groupId + " DB delete: " + (endDB - startDB) + " Async task generation: " + (now - startAsync) + " Total time: " + (now - startDB); log.info(logMessage); } return Boolean.TRUE; } }
DeleteGroupFromDBExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long groupId = (Long) inActionContext.getActionContext().getParams(); Long startDB = null; if (log.isInfoEnabled()) { startDB = System.currentTimeMillis(); } Long startTime = null; Long endTime = null; if (log.isDebugEnabled()) { log.debug("Deleting activities for groupid:" + groupId); startTime = System.currentTimeMillis(); } BulkActivityDeleteResponse deleteActivityResponse = deleteGroupActivityDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to delete activities/comments: " + (endTime - startTime)); log.debug("Removing followers for groupid:" + groupId); startTime = endTime; } List<Long> followerIds = removeGroupFollowersDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove followers from group: " + (endTime - startTime)); log.debug("Removing group subscriptions for groupid:" + groupId); startTime = endTime; } deleteGroupFeedSubscriptions.execute(new DeleteAllFeedSubscriberByEntityTypeAndIdRequest(groupId, EntityType.GROUP)); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group subscriptions: " + (endTime - startTime)); log.debug("Removing group and associated objects for groupid:" + groupId); startTime = endTime; } DeleteGroupResponse deleteGroupResponse = deleteGroupDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group and associated objects: " + (endTime - startTime)); } Long endDB = null; if (log.isInfoEnabled()) { endDB = System.currentTimeMillis(); } Long startAsync = null; if (log.isInfoEnabled()) { startAsync = System.currentTimeMillis(); } int startSize = 0; int endSize = 0; if (log.isDebugEnabled()) { startSize = inActionContext.getUserActionRequests().size(); } generateSingleDeleteKeyFromCacheTask(getKeysToPurgeFromCache(deleteGroupResponse), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge fixed set of cache keys: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromListTasks(createKeys(CacheKeys.GROUPS_FOLLOWED_BY_PERSON, followerIds), Collections .singletonList(deleteGroupResponse.getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove group id from GROUPS_FOLLOWED_BY_PERSON lists: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromStarredActivityListTasks(deleteActivityResponse, inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove groups activity ids from starred activity lists: " + (endSize - startSize)); } List<Long> cachedActivityIds = deleteActivityResponse.getActivityIds().size() > maxCacheListSize ? deleteActivityResponse.getActivityIds().subList(0, maxCacheListSize - 1) : deleteActivityResponse.getActivityIds(); startSize = endSize; if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove activity ids from parent orgs of the deleted group: " + (endSize - startSize)); } generateRemoveIdsFromListTasks(Collections.singletonList(CacheKeys.EVERYONE_ACTIVITY_IDS), cachedActivityIds, inActionContext); startSize = endSize; generateDeleteFromSearchIndexTasks(DomainGroup.class, Collections.singletonList(deleteGroupResponse .getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge group from search index: " + (endSize - startSize)); } startSize = endSize; generateDeleteFromSearchIndexTasks(Activity.class, deleteActivityResponse.getActivityIds(), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge ALL activities from search index: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.ACTIVITY_BY_ID, deleteActivityResponse.getActivityIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL activities from cache: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.COMMENT_BY_ID, deleteActivityResponse.getCommentIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL comments from cache: " + (endSize - startSize)); log.debug("Total async tasks for delete: " + endSize); } if (log.isInfoEnabled()) { long now = System.currentTimeMillis(); String logMessage = "GroupId: " + groupId + " DB delete: " + (endDB - startDB) + " Async task generation: " + (now - startAsync) + " Total time: " + (now - startDB); log.info(logMessage); } return Boolean.TRUE; } DeleteGroupFromDBExecution(final DeleteGroupActivity inDeleteGroupActivityDAO,
            final RemoveGroupFollowers inRemoveGroupFollowersDAO, final DeleteGroup inDeleteGroupDAO,
            final DeleteAllFeedSubscriberByEntityTypeAndId inDeleteGroupFeedSubscriptions, final int inMaxCacheListSize); }
DeleteGroupFromDBExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long groupId = (Long) inActionContext.getActionContext().getParams(); Long startDB = null; if (log.isInfoEnabled()) { startDB = System.currentTimeMillis(); } Long startTime = null; Long endTime = null; if (log.isDebugEnabled()) { log.debug("Deleting activities for groupid:" + groupId); startTime = System.currentTimeMillis(); } BulkActivityDeleteResponse deleteActivityResponse = deleteGroupActivityDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to delete activities/comments: " + (endTime - startTime)); log.debug("Removing followers for groupid:" + groupId); startTime = endTime; } List<Long> followerIds = removeGroupFollowersDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove followers from group: " + (endTime - startTime)); log.debug("Removing group subscriptions for groupid:" + groupId); startTime = endTime; } deleteGroupFeedSubscriptions.execute(new DeleteAllFeedSubscriberByEntityTypeAndIdRequest(groupId, EntityType.GROUP)); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group subscriptions: " + (endTime - startTime)); log.debug("Removing group and associated objects for groupid:" + groupId); startTime = endTime; } DeleteGroupResponse deleteGroupResponse = deleteGroupDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group and associated objects: " + (endTime - startTime)); } Long endDB = null; if (log.isInfoEnabled()) { endDB = System.currentTimeMillis(); } Long startAsync = null; if (log.isInfoEnabled()) { startAsync = System.currentTimeMillis(); } int startSize = 0; int endSize = 0; if (log.isDebugEnabled()) { startSize = inActionContext.getUserActionRequests().size(); } generateSingleDeleteKeyFromCacheTask(getKeysToPurgeFromCache(deleteGroupResponse), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge fixed set of cache keys: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromListTasks(createKeys(CacheKeys.GROUPS_FOLLOWED_BY_PERSON, followerIds), Collections .singletonList(deleteGroupResponse.getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove group id from GROUPS_FOLLOWED_BY_PERSON lists: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromStarredActivityListTasks(deleteActivityResponse, inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove groups activity ids from starred activity lists: " + (endSize - startSize)); } List<Long> cachedActivityIds = deleteActivityResponse.getActivityIds().size() > maxCacheListSize ? deleteActivityResponse.getActivityIds().subList(0, maxCacheListSize - 1) : deleteActivityResponse.getActivityIds(); startSize = endSize; if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove activity ids from parent orgs of the deleted group: " + (endSize - startSize)); } generateRemoveIdsFromListTasks(Collections.singletonList(CacheKeys.EVERYONE_ACTIVITY_IDS), cachedActivityIds, inActionContext); startSize = endSize; generateDeleteFromSearchIndexTasks(DomainGroup.class, Collections.singletonList(deleteGroupResponse .getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge group from search index: " + (endSize - startSize)); } startSize = endSize; generateDeleteFromSearchIndexTasks(Activity.class, deleteActivityResponse.getActivityIds(), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge ALL activities from search index: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.ACTIVITY_BY_ID, deleteActivityResponse.getActivityIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL activities from cache: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.COMMENT_BY_ID, deleteActivityResponse.getCommentIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL comments from cache: " + (endSize - startSize)); log.debug("Total async tasks for delete: " + endSize); } if (log.isInfoEnabled()) { long now = System.currentTimeMillis(); String logMessage = "GroupId: " + groupId + " DB delete: " + (endDB - startDB) + " Async task generation: " + (now - startAsync) + " Total time: " + (now - startDB); log.info(logMessage); } return Boolean.TRUE; } DeleteGroupFromDBExecution(final DeleteGroupActivity inDeleteGroupActivityDAO,
            final RemoveGroupFollowers inRemoveGroupFollowersDAO, final DeleteGroup inDeleteGroupDAO,
            final DeleteAllFeedSubscriberByEntityTypeAndId inDeleteGroupFeedSubscriptions, final int inMaxCacheListSize); @Override Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext); }
DeleteGroupFromDBExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long groupId = (Long) inActionContext.getActionContext().getParams(); Long startDB = null; if (log.isInfoEnabled()) { startDB = System.currentTimeMillis(); } Long startTime = null; Long endTime = null; if (log.isDebugEnabled()) { log.debug("Deleting activities for groupid:" + groupId); startTime = System.currentTimeMillis(); } BulkActivityDeleteResponse deleteActivityResponse = deleteGroupActivityDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to delete activities/comments: " + (endTime - startTime)); log.debug("Removing followers for groupid:" + groupId); startTime = endTime; } List<Long> followerIds = removeGroupFollowersDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove followers from group: " + (endTime - startTime)); log.debug("Removing group subscriptions for groupid:" + groupId); startTime = endTime; } deleteGroupFeedSubscriptions.execute(new DeleteAllFeedSubscriberByEntityTypeAndIdRequest(groupId, EntityType.GROUP)); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group subscriptions: " + (endTime - startTime)); log.debug("Removing group and associated objects for groupid:" + groupId); startTime = endTime; } DeleteGroupResponse deleteGroupResponse = deleteGroupDAO.execute(groupId); if (log.isDebugEnabled()) { endTime = System.currentTimeMillis(); log.debug("Time to remove group and associated objects: " + (endTime - startTime)); } Long endDB = null; if (log.isInfoEnabled()) { endDB = System.currentTimeMillis(); } Long startAsync = null; if (log.isInfoEnabled()) { startAsync = System.currentTimeMillis(); } int startSize = 0; int endSize = 0; if (log.isDebugEnabled()) { startSize = inActionContext.getUserActionRequests().size(); } generateSingleDeleteKeyFromCacheTask(getKeysToPurgeFromCache(deleteGroupResponse), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge fixed set of cache keys: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromListTasks(createKeys(CacheKeys.GROUPS_FOLLOWED_BY_PERSON, followerIds), Collections .singletonList(deleteGroupResponse.getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove group id from GROUPS_FOLLOWED_BY_PERSON lists: " + (endSize - startSize)); } startSize = endSize; generateRemoveIdsFromStarredActivityListTasks(deleteActivityResponse, inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove groups activity ids from starred activity lists: " + (endSize - startSize)); } List<Long> cachedActivityIds = deleteActivityResponse.getActivityIds().size() > maxCacheListSize ? deleteActivityResponse.getActivityIds().subList(0, maxCacheListSize - 1) : deleteActivityResponse.getActivityIds(); startSize = endSize; if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove activity ids from parent orgs of the deleted group: " + (endSize - startSize)); } generateRemoveIdsFromListTasks(Collections.singletonList(CacheKeys.EVERYONE_ACTIVITY_IDS), cachedActivityIds, inActionContext); startSize = endSize; generateDeleteFromSearchIndexTasks(DomainGroup.class, Collections.singletonList(deleteGroupResponse .getGroupId()), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge group from search index: " + (endSize - startSize)); } startSize = endSize; generateDeleteFromSearchIndexTasks(Activity.class, deleteActivityResponse.getActivityIds(), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for purge ALL activities from search index: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.ACTIVITY_BY_ID, deleteActivityResponse.getActivityIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL activities from cache: " + (endSize - startSize)); } startSize = endSize; generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.COMMENT_BY_ID, deleteActivityResponse.getCommentIds())), inActionContext); if (log.isDebugEnabled()) { endSize = inActionContext.getUserActionRequests().size(); log.debug("Tasks for remove ALL comments from cache: " + (endSize - startSize)); log.debug("Total async tasks for delete: " + endSize); } if (log.isInfoEnabled()) { long now = System.currentTimeMillis(); String logMessage = "GroupId: " + groupId + " DB delete: " + (endDB - startDB) + " Async task generation: " + (now - startAsync) + " Total time: " + (now - startDB); log.info(logMessage); } return Boolean.TRUE; } DeleteGroupFromDBExecution(final DeleteGroupActivity inDeleteGroupActivityDAO,
            final RemoveGroupFollowers inRemoveGroupFollowersDAO, final DeleteGroup inDeleteGroupDAO,
            final DeleteAllFeedSubscriberByEntityTypeAndId inDeleteGroupFeedSubscriptions, final int inMaxCacheListSize); @Override Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext);  }