Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Please help - Checking permission
Hi friends,
I am using liferay 5.1.2
We had a requirement that when a user logs in he is able to see all his private pages as well as community private pages in the tabs. So i had written code to merge both layouts in ServicePreAction as under and its working fine.
The above code is working fine but during load test with roughly 60 users we found that it was taking hell of a time. On further investigation we found that the following line of code is taking more time
I guess the reason being ServicePreAction being called on every request + there may be many community private pages.
Is there a way to minimize the impact that is reduce the time??
Please reply. Eagerly waiting for an answer.
Regards,
Sandeep
I am using liferay 5.1.2
We had a requirement that when a user logs in he is able to see all his private pages as well as community private pages in the tabs. So i had written code to merge both layouts in ServicePreAction as under and its working fine.
try {
List<group> userGroups = GroupLocalServiceUtil.getUserGroups(userId);
_log.debug("Total usergroup size: "+userGroups.size());
for(Group group: userGroups){
String label = group.getTypeLabel();
String name = group.getName();
_log.debug("Name: "+group.getName()+" group Type: "+label+" url: "+group.getFriendlyURL());
if(group.isCommunity()){
List<layout> communityLayouts = LayoutLocalServiceUtil.getLayouts(
group.getGroupId(), true);
List<layout> viewableCommunityLayouts = new ArrayList<layout>();
for(Layout communityLayout: communityLayouts){
// boolean isViewable = LayoutPermissionUtil.contains(permissionChecker,communityLayout,ActionKeys.VIEW);
boolean isViewable = true;
//Only show community layouts if user is active, has agreed to Terms of use and not a password reset screen.
if(isViewable && user.isActive() && user.getAgreedToTermsOfUse() && !user.isPasswordReset()){
viewableCommunityLayouts.add(communityLayout);
}
}
communitylayouts.addAll(viewableCommunityLayouts);
_log.debug("Groupt layouts size: "+communityLayouts.size()+" User Layouts size: "+viewableCommunityLayouts.size());
}
_log.debug("Group label: "+label);
_log.debug("Group Name: "+ name);
}
}</layout></layout></layout></group>The above code is working fine but during load test with roughly 60 users we found that it was taking hell of a time. On further investigation we found that the following line of code is taking more time
LayoutPermissionUtil.contains(permissionChecker,communityLayout,ActionKeys.VIEW);I guess the reason being ServicePreAction being called on every request + there may be many community private pages.
Is there a way to minimize the impact that is reduce the time??
Please reply. Eagerly waiting for an answer.
Regards,
Sandeep
Sandeep, it is probably hard at the moment to analyze why the system is clogged, have a look at the approach described in this thread.
What it does - it shifts the permissions analysis stage to the moment when user logs in, so you would have a system hit only once per user instead of doing it at every consequent render call. For us, it works really well in both 5.1.2(4) and 5.2.1.
What it does - it shifts the permissions analysis stage to the moment when user logs in, so you would have a system hit only once per user instead of doing it at every consequent render call. For us, it works really well in both 5.1.2(4) and 5.2.1.
Thanks Victor,
We did as you said and have done all those permission related code change in custom login post event class. It did help. But i have found that in clustered environment the performance decreases to a great magnitude than on single server. Do you have any idea about that?
Regards,
Sandeep
We did as you said and have done all those permission related code change in custom login post event class. It did help. But i have found that in clustered environment the performance decreases to a great magnitude than on single server. Do you have any idea about that?
Regards,
Sandeep
You've got to find the way to detect those bottlenecks in your configuration. Every setup is unique. Draw your diagram, analyze it, define and implement simple measurements at all cross-sections. Check your database and transaction tuning guide. Check sizes of connection pools, check maximum size of allowed connections on db end. To get better measurements, you may have to further spread your system (one system module per hardware node). Check, how the change of configuration limits affects system performance, try to change limits in such way that similar performance degradation would start earlier. This way, it is going to be much easier to do analysis, i.e. less complex setup. Apply the same thinking approach as you do while writing the code.
Usually, if such behavior is not intermittent, the explanation and fix (or workaround) are quite simple.
Usually, if such behavior is not intermittent, the explanation and fix (or workaround) are quite simple.