This handy script can be used to find various useful network settings on any server.

#!/bin/bash
date
uname -a
echo -e "\nTHE CRITICAL SETTINGS"
/sbin/sysctl -a 2> /dev/null | grep -P "(net.core.netdev_max_backlog|net.core.rmem_default|net.core.rmem_max|net.core.wmem_default|net.core.wmem_max|net.ipv4.tcp_adv_win_scale|net.ipv4.tcp_mem|net.ipv4.tcp_no_metrics_save|net.ipv4.tcp_rmem|net.ipv4.tcp_sack|net.ipv4.tcp_slow_start_after_idle|net.ipv4.tcp_timestamps|net.ipv4.tcp_window_scaling|net.ipv4.tcp_wmem)"
 
echo -e "\nTHE OPTIONAL SETTINGS"
/sbin/sysctl -a 2> /dev/null | grep -P "(net.ipv4.conf.all.accept_redirects|net.ipv4.conf.all.accept_source_route|net.ipv4.conf.all.log_martians|net.ipv4.conf.all.send_redirects|net.ipv4.conf.default.accept_redirects|net.ipv4.conf.default.log_martians|net.ipv4.conf.default.send_redirects|net.ipv4.icmp_echo_ignore_broadcasts|net.ipv4.icmp_ignore_bogus_error_responses|net.ipv4.ip_local_port_range|net.ipv4.tcp_keepalive_time|net.ipv4.tcp_syncookies)"
 
echo

Output from a default CentOS 6.3 installation

[liferay@dell-16g-n1 bin]$ ./get_tcp_settings.sh
Wed Feb 27 16:20:10 EST 2013
Linux dell-16g-n1 2.6.32-279.22.1.el6.x86_64 #1 SMP Wed Feb 6 03:10:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
 
THE CRITICAL SETTINGS
net.core.wmem_max = 131071
net.core.rmem_max = 131071
net.core.wmem_default = 229376
net.core.rmem_default = 229376
net.core.netdev_max_backlog = 1000
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_mem = 1528704      2038272 3057408
net.ipv4.tcp_wmem = 4096        16384   4194304
net.ipv4.tcp_rmem = 4096        87380   4194304
net.ipv4.tcp_adv_win_scale = 2
net.ipv4.tcp_no_metrics_save = 0
net.ipv4.tcp_slow_start_after_idle = 1
 
THE OPTIONAL SETTINGS
net.ipv4.tcp_keepalive_time = 7200
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_local_port_range = 32768    61000
net.ipv4.conf.all.accept_redirects = 1
net.ipv4.conf.all.send_redirects = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.default.accept_redirects = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.default.log_martians = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
 

 

Save this as findclass.sh (or whatever), put it on your path and make it executable:

#!/bin/sh
find "$1" -name "*.jar" -exec sh -c 'jar -tf {} | grep -H --label {} '$2'' \;

The first parameter is the directory to search recursively and the second parameter is a regular expression (typically just a simple class name) to search for.

$ findclass.sh . MyClass

The script relies on the -t option to the jar command (which lists the contents) and greps each table of contents, labelling any matches with the path of the JAR file in which it was found.

 

The URL and way to pass parameter has change a bit in 6.1 so here is how you can do it.

To get user details

http://localhost:8080/api/secure/json?serviceClassName=com.liferay.portal.service.UserServiceUtil&serviceMethodName=getUserById&serviceParameters=['userId']&userId=10424

To de-activate user

http://localhost:8080/api/secure/json?serviceClassName=com.liferay.portal.service.UserServiceUtil&serviceMethodName=updateStatus&serviceParameters=['userId','status']&userId=10424&status=5

To re-activate user

http://localhost:8080/api/secure/json?serviceClassName=com.liferay.portal.service.UserServiceUtil&serviceMethodName=updateStatus&serviceParameters=['userId','status']&userId=10424&status=0

Shell script for de-activating given user

[liferay@localhost ~]$ wget "http://test:test@localhost:8080/api/secure/json?serviceClassName=com.liferay.portal.service.UserServiceUtil&serviceMethodName=updateStatus&serviceParameters=['userId','status']&userId=10424&status=5"

PHP script

#
# This example uses HTTP_Request package located found here:
# http://pear.php.net/package/HTTP_Request
#
require_once("HTTP/Request.php");

$lr = &new HTTP_Request('http://localhost:8080/api/secure/json');
$lr->setMethod("POST");
$lr->setBasicAuth("test","test");

$lr->addPostData("serviceClassName", "com.liferay.portal.service.UserServiceUtil");
$lr->addPostData("serviceMethodName", "updateStatus");
$lr->addPostData("serviceParameters", "['userId','status']");
$lr->addPostData("userId", "10424");
$lr->addPostData("status", "5");
$lr->sendRequest();

echo $lr->getResponseBody();

?>

 

Ref: http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_lower_case_table_names
Ref: http://www.liferay.com/community/wiki/-/wiki/Main/Database+Configuration

This trick is a good to have if your Liferay development process includes Linux & Windows both.

[mysqld]
# My custom settings '/etc/my.cnf'
bind-address=127.0.0.1
lower_case_table_names=1
character-set-server=utf8
collation-server=utf8_general_ci

Without this trick the database export from Windows will not be recognized on Linux side because by default User_ is not equal to user_ for MySQL on the destination side.

Cheers,

 

Few days back a dear friend of mine asked this question – “Our application server is freezing with 100% CPU. How to troubleshoot it?”

This is tricky but easy once you know the right switch. Look for match in output of following two commands using given logic and you’ll know the abusing thread which is bring your JVM down.

Look for PID here; convert to HEX

top -Hb -n1 | head -n20

And match with nid=”HEX” in regular thread dump.

jstack PID

TODO – examples.

 

Test case: liferay-portal-6.1.0-ce-ga1 (default tomcat bundle)
Test URL: default homepage

Observations:

Total server request count: 35

Main site request count: 21

/
/html/portlet/journal_content/css/main.css?browserId=firefox&themeId=classic&minifierType=css&languageId=en_US&b=6100&t=1325881930000
/html/portlet/login/css/main.css?browserId=firefox&themeId=classic&minifierType=css&languageId=en_US&b=6100&t=1325881930000
/image/10180/29fb8a90-ad33-4c1e-a454-f6ffb0e5a7d9
/image/10180/7919061f-b773-478f-96a2-6a9444c922f4
/image/10180/8055e99a-a65f-4d8f-9fc1-142027869c06
/image/10180/fc53c3c3-cc07-4cbb-a95c-815975822c4b
/image/10180/79828c41-f706-4d1b-ab42-1b501c0a2bee
/image/10180/a6ccf000-2072-4ae6-b630-b592452c0452
/image/10180/9f2080c7-3b43-455e-ae56-8cf226f78e2c
/image/10180/1ca03500-c9d2-4cfb-bb3e-d8dd82651aae
/image/10180/65121e78-fdbf-4c13-9800-9bedcd0d0ba2
/image/10180/754514bd-feca-4b6e-8dc1-39bc889eb272
/image/10180/2ff8cd74-16f2-4202-86e1-28eb28c44669
/html/js/editor/fckeditor/editor/images/smiley/msn/lightbulb.gif
/image/user_portrait?screenName=michelle&companyId=10154&t=1228845375823
/image/user_portrait?screenName=bruno&companyId=10154&t=1228845375900
/image/user_portrait?screenName=richard&companyId=10154&t=1228845375871
/image/user_portrait?screenName=kendra&companyId=10154&t=1228845375887
/html/icons/login.png
/html/themes/classic/images/common/view_tasks.png

CDN site request count: 14

/html/themes/classic/js/main.js?browserId=firefox&minifierType=js&languageId=en_US&b=6100&t=1330883851000
/html/css/main.css?browserId=firefox&themeId=classic&minifierType=css&languageId=en_US&b=6100&t=1330883851000
/html/themes/classic/css/main.css?browserId=firefox&themeId=classic&minifierType=css&languageId=en_US&b=6100&t=1330883851000
/html/js/barebone.jsp?browserId=firefox&themeId=classic&colorSchemeId=01&minifierType=js&minifierBundleId=javascript.barebone.files&languageId=en_US&b=6100&t=1325878880000
/image/company_logo?img_id=0&t=1330884003724
/html/themes/classic/images/forms/input_shadow.png
/html/themes/classic/images/common/breadcrumbs.png
/html/themes/classic/images/common/openid.gif
/html/themes/classic/images/common/key.png
/html/themes/classic/images/navigation/bg.png
/html/themes/classic/images/portlet/header_bg.png
/combo/?browserId=firefox&minifierType=&languageId=en_US&b=6100&t=1325878880000&p=/html/js&m=/aui/widget-base/assets/skins/sam/widget-base.css
/combo/?browserId=firefox&minifierType=&languageId=en_US&b=6100&t=1325878880000&p=/html/js&m=/liferay/hudcrumbs.js&m=/liferay/navigation_interaction.js
/combo/?browserId=firefox&minifierType=&languageId=en_US&b=6100&t=1325878880000&p=/html/js&m=/aui/widget-stack/assets/skins/sam/widget-stack.css&m=/aui/overlay/assets/skins/sam/overlay.css

Conclusion: The out of box Liferay CDN implementation is a confusing mix-and-match and insufficient for serious implementations. Following URLs are actually serving static content but no straight forward way to terminate them at Apache or CDN services like Akamai.

  • /combo/*
  • /html/js/barebone.jsp
  • /html/js/everything.jsp
  • /image/*
 

The default Liferay bundle comes with HSQL which is good for demo but you need a serious database for serious development. I’m a big fan of portable apps and always try to use it whenever possible.

A simple search on google for “portable mysql” did not return much useful result so I decided to write my own. You can download it from here, source build here.

MySQL Launcher

This bundle also include a tiny launcher which can be used to

  • start/stop the server
  • initialize lportal database (id/password: liferay)
  • launch mysql client
  • reset lportal database

And this is how use this mysql database in portal-ext.properties

jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=liferay
jdbc.default.password=liferay

Cheers,

© 2012 Liferay US Powered by Wordpress and Suffusion