Sergeonclear

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, December 31, 2007

Hibernate second level cache

Posted on 4:21 AM by Unknown

Second level cache(2LC) of hibernate boosts the performance of websites.
One needs to be careful to handle the cache refresh.
By default hibernate 3 comes with EHcache for session level
cache(primary cache).
EhCache can also be used for secondary level cache.


Setup of 2LC using EHcache:

1. Setup the session factory with the below details:
hibernate.cache.provider_class as org.hibernate.cache.EhCacheProvider
hibernate.cache.use_query_cache as true

Optionally cache statistics can be enabled by using below

hibernate.generate_statistics as true
hibernate.cache.use_structured_entries as true


2. In the hbm files just under the class element put the below:
cache region="com.xmp.web2.model.Article" usage="read-only"

--in the above, the region is used to identify as cache key.

3. For query cache, set the Query as cacheable programatically.

Query queryObj = session.createQuery(query);
queryObj.setCacheable(true);

-- This will cache all the query result, thus reducing DB hits.

4. To refresh a query programatically, do the below:
-- sessionFactory.evict(Article.class, id); //this will remove from the cache the article object instance with the primary key id. Note that the id is serializable and the type should be the same as defined in hbm.

5. To optionally print the statistics, enable statistic monitoring as told in step 1 and use the below:

static void printCacheStatistics(String regionName) {
Statistics statistics = sessionFactory.getStatistics();
SecondLevelCacheStatistics secondLevelCacheStatistics = statistics.getSecondLevelCacheStatistics(regionName);
System.out.println("2nd level CACHE Statistics :"+secondLevelCacheStatistics.toString());
}

To check cache statistics use the JSP as below:
<%@ page language="java" import="org.springframework.web.context.*,org.springframework.web.context.support.*,org.hibernate.*,org.hibernate.stat.*"%>

<%
String cacheRegion="com.xmp.web2.model.Article";

WebApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(
this.getServletContext());
SessionFactory sessionFactory = (SessionFactory) ctx.getBean("sessionFactory");
out.print(sessionFactory);
Statistics statistics = sessionFactory.getStatistics();
SecondLevelCacheStatistics secondLevelCacheStatistics = statistics.getSecondLevelCacheStatistics(cacheRegion);
out.print("<br/>");
out.println("Query cache hit count :"+statistics.getQueryCacheHitCount());
out.print("<br/>");
out.print("<br/>");
out.println("2nd level CACHE Statistics :" + secondLevelCacheStatistics.toString());

%>

Reference:
http://doc.javanb.com/hibernate-reference-3-2-4-ga-en/performance.html
http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-cache

An excellent write-up on 2ndLC http://tech.puredanger.com/2009/07/10/hibernate-query-cache/
Read More
Posted in hibernate second level cache, linux), LinuxPerformance Tuning(apache, Spring + Hibernate Usefuls BaseDAOHibernate, tomcat | No comments

Monday, December 17, 2007

All about UK Visa.

Posted on 10:25 PM by Unknown

HSMP is a 2 step process as of now.I applied for HSMP visa through a consultant y-axis in Bangalore, India.
They provided good service for getting step 1done(HSMP acceptance). The second part(Entry clearance)
was hopeless service by y-axis. I feel like chewing that consultant who processed it.

They are very keen about proof's (original documents) which has to be genuine and no scope for any errors.

Eg: Say you have your salary credited through cheques, then in the bank statement
you wont have the mention that your XYZ company paid you the salary. So you need
to get a letter for the same from bank or company stating you got the salary from
XYZ company. As long as you prove yourself with the documents the chances of
rejection is very low. Also all your salary slips should be attested by the
corresponding authority.

H1 vs HSMP:
  • The chances of getting visa depends on your documentation which serves as the proof of you skills. Not entirely on luck like in H1.
  • It is not like H1 visa (phaltu lottery system and only done once a year ). HSMP's points calculator is best and you can calculate before hand if you are eligible for it or not. Also you can apply any time of the year as long as you have your documents right. UK guys are smart at applying rules i guess.

As I said before, it is a 2 step process-
  1. Get HSMP acceptance from UK consulate by sending your documents, 400 pounds and details to UK. It took me 3 weeks for getting the HSMP accepted. Actually gathering all the documents for proof of salary, bank stmts, medium of instruction letter etc. took me 1 month. On a whole you should get this first part done in 2-3 months.
2. Once u get HSMP acceptance from UK office, apply for Entry clearance in chennai or
mumbai. I applied through local VFS in bangalore(VFS sent it to chennai).Paid Rs.17,000
at VFS office fee for EC. It is already 3 weeks since I applied. Yet to get a response. HSMP
visa Entry clearance application status can be checked from here
I have got the first part done(got HSMP acceptance letter), the second one is also done. 
Overall the entire process took me 6 months as of now. I could have saved some 2 months had I got all the documents ready. By and large
4-6 months.

Right now I am in UK. More to blog soon.


UK HSMP visa useful Links:
  1. hsmphelp.blogspot.com/
  2. Check the blog ec-hsmp.blogspot.com HSMP blog .On the right you can find various useful section's. This blog is one of the best. No need to go to visa consultant and shell out so much fortune.
  3. http://www.workpermit.com/uk/hsmp_calculator.htm --> HSMP point calculator. This may change in first quarter of 2008. Watch out.
  4. Job assistance in Uk 00 44 114 207 6020 -Aman http://www.vertex-solutions.co.uk/technical-recruitment/immigrationservices.asp Tel (UK): 08456 448 441
http://forums.gumtree.com/about2685-25.html
  1. Direct Dial: (+44) 144 222 1320
  2. Buy tickets for UK to/from india at
    1. http://www.ticketstoindia.co.uk/result_new.aspx
  3. For currency, time, phone number conversion check
    1. http://www.timeanddate.com

FAQ
What is the cheap and best place to stay in london. What is the price of apartments?

Eastham is cheap with lot of asians but not so safe. For a bachelor it will cost around 300 pounds for a shared acco of 3 people.
Around 450 for 2 people. Thats a rough estimate...Depends on the owner.

How much cash should one carry for travel and job search?
Around 300 pounds for flight + travel.. You might spend 600 pounds a month overall staying here.
If u r traveling for job search you will need some more like 100 pounds more.
So that might cost you 2- 3 lak rs for 2-3 months to come here and stay ,search a job.... Its ur best try and luck how
soon u get the job.
Suggest some possible ways to get a job by seating here in india?
Sitting in India and trying a job is not a good idea. Chances are i can say only 10%. If u want to get work form India , chances are u end up with an Indian company who has UK requirement.... Also many consultants here dont call indian numbers. You need to prepare yourself with finances so that u survive in UK for atleast 2-3 months without a job(that might cost you 2- 3 lak rs).


Read More
Posted in All about UK Visa HSMP VS H1 hsmp assistance | No comments

Wednesday, December 12, 2007

LinuxPerformance Tuning(apache,tomcat,linux) and related

Posted on 11:21 PM by Unknown
Web profiling
-- HTTPAnalyzer --
-- YSlow --CSS,Javascript report , time/size measurement for individual component is good.
-- FireBug -- Net performance, for a quick analysis.
--Open STA
Tomcat profiling
-- JProfiler
-- Hot spots ,JDBC queries(J2ee components), object instance count are useful.

--Database connection pooling with optimal values.
Connection leakage in DBCP can be easily detected by settin logAbandoned=true in resource configuration (server.xml). This is a very nice feature and throws up the exact location of the code which is not closing the connection. These connection issues normally come up during load testing.Also the jndi resource configuration for DBCP should have ideal settings. The one used for our project is below:

[GlobalNamingResources]
[Resource
name="jdbc/cmpPubPool"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:oci:@[TNSNAME]"
removeAbandoned="true"
logAbandoned="true"
maxActive="2"
maxIdle="2"
initialSize="2"
maxWait="-1"
username="[USER_NAME]"
password="[USER_PASSWORD]"
validationQuery=”select 1 from dual” /]
[/GlobalNamingResources]


JVM Tuning
Modify the heap size in JAVA_OPTS.


Apache tuning
prefork or worker module can be used.
prefork is non thread based.
Worker module is multi threaded and may yield a better performance.

Linux
--$top -- to check CPU status

top


Top has probably hundreds of keys to do whatever you want. A few are most useful for me.


The > key sorts by the next column (%MEM) instead of the default (%CPU). < sorts by the previous column.


Hit c
to toggle the display of command line arguments. Useful for me when I
have a lot of processes that otherwise just show up as “java”





Typing A
brings up the alternate display, showing processes sorted by different
fields with different columns. One section shows a nice memory-centric
view, for example.
Hitting z turns on colors. Z brings you to a color selection screen where you can pick colors you want. B turns on bold for some fields.
Hit W to save all your configuration changes to ~/.toprc where it will be loaded next time.
Type k allows you to kill a process without exiting top.

-- kill -3 <TOMCAT_PID> will log the threads running/inactive details useful for troubleshooting performance issues.
On windows use CTRL +Break.

Hardware
-Linux memory size can be checked using
cat /proc/meminfo --Gives RAM size
free -m -- Gives RAM size in MB (-k for kb)
df -H -- Human readable format of hard disk size


Useful links
http://jha.rajeev.googlepages.com/web2push



Powered by ScribeFire.

Read More
Posted in linux), LinuxPerformance Tuning(apache, tomcat | No comments
Newer Posts Older Posts Home
Subscribe to: Comments (Atom)

Popular Posts

  • LinuxPerformance Tuning(apache,tomcat,linux) and related
    Web profiling -- HTTPAnalyzer -- -- YSlow --CSS,Javascript report , time/size measurement for individual component is good. -- F...
  • (no title)
    Hardware/Software stack:  iPhone 3Gs having iOS 5.1.1(latest as of today).  The Xcdode 4.2 failed to detect this iphone as it has support on...
  • Spring interceptor ordering
    SimpleUrlHandlerMapping uses a hashMap to hold the interceptors. Ordering can only be guaranteed by setting  order property.. By default it ...
  • SVN/ Subversion Tips and traps
    SVN could be tricky and waste a hell lot of time. Case Issue : Normally we run SVN server in linux. Our dev env will be in windows NT. Windo...
  • Liferay CMS/ web content management/ workflow/ staging
    Liferay out of the box has a web content management system. The web pages can mostly have these web content (articles) as web pages. The web...
  • Cobertura- junit coverage tool
    First, you need to add a task definition to the build.xml file. This top-level taskdef element specifies that the cobertura.jar file is i...
  • XSLT caching Transformers
     The usage of cached transformer objects is recommended here A sample implementation of CachingTransformerFactory is here The above code abs...
  • Rewrite rules in apache and IIS
    Well we can control how the server serves stuff to clients by defining rewrite rules. As servers are dumb, its important to explain well abo...
  • Real-Time Tracking and Tuning for Busy Tomcat Servers
    A very nice article which details on possible options for tomcat server monitoring to tweak its performance. http://www.devx.com/Java/Articl...
  • External Javascript from Java Servlets
    Copied from http://myappsecurity.blogspot.com/2007/01 Like to thank anurag for the content. /breaking-same-origin-barrier-of.html External ...

Categories

  • AJAX javascript
  • All about UK Visa HSMP VS H1
  • All about UK Visa HSMP VS H1 hsmp assistance
  • amazon
  • android apps ship control radio hindi
  • Apache 2.x setup Quick guide for Linux
  • apache commons configurator usage
  • apache commons usage
  • arsenals for developers
  • article
  • Batch script to load developer environment
  • Blind folded chess
  • Castor castor convert dtd to xsd
  • cloud comparision price
  • cloud comparison blog
  • cloud computing monthly price
  • cloud usage
  • Cobertura- junit coverage tool
  • Code generators
  • cron jobs expressions
  • cruisecontrol cruise control
  • debugging eclipse tips
  • developer tools
  • document library
  • easy mock jmock vs mocking java tdd
  • External Javascript from Java Servlets
  • fedora 9 lenovo 3000 n200 windows xp dual boot problem
  • Fire fox plugins and tweaks
  • Free PHP hosting
  • gods debris the religion war scott adams dilbert
  • google app engine
  • gwt javascript
  • hibernate second level cache
  • i18n locale localization internationalization spring liferay portlet locale
  • ibatis sybase mapping
  • image gallery
  • iphone apps bri8 apple
  • iphone shsh 3gs ipsw downgrade ifaith tinyumbrella ios5.1.1 to ios5.0
  • java
  • java JDBC
  • javascript junit testing
  • Javascript trouble shooting tool
  • Jboss overview
  • jmeter load testing custom java sampler javasamplerclient xml test
  • JNDI test JSP page
  • Joomla CMS
  • JProfiler setup jprofiler on linux
  • jquery IE AJAX issues
  • jquery spring AJAX
  • keyboard music java typing soothing notes auto suggest
  • liferay kids version
  • liferay web 2.0 java/j2ee
  • linux - the difference between hard and soft links
  • linux mysql
  • linux mysql setup quick start
  • Linux ssh autologin with putty
  • LINUX usefuls
  • linux)
  • LinuxPerformance Tuning(apache
  • log4j setup useful
  • lucene solr
  • mac m701 android skype not working crash
  • maven
  • maven cut reduce build time
  • microsoft ODBC oracle dll connection issues
  • Mobile Ad Services (adwhirl)
  • opsourcecloud
  • oracle connect by hierarchy
  • oracle table previlege
  • Oracle thin vs OCI(type II/thick) drivers
  • pdf 2 text
  • Pega PRPC
  • php
  • rackspacecloud
  • Rewrite rules in apache and IIS
  • scaffold
  • setting up a static ip on SKY broadband
  • setup quick start
  • Single Sign on - OpenSSO with Liferay
  • smart gwt
  • smtp email test mock server james
  • SMTP MAIL telnet windows
  • Software tools mind map freemind j2ee tools
  • Speed typing tips.
  • Spring + Hibernate Usefuls BaseDAOHibernate
  • Spring annotations with spring-mock not working 2.0 2.5.6
  • spring jndi datasource lookup
  • Spring portlet mvc and spring servlet mvc validation
  • Spyware trojan and virus removal tools
  • struts magic
  • SVN/ Subversion Tips and traps
  • tabbed ms dos console cygwin console
  • Texter - An auto text expander autotyper
  • Textpad tricks
  • The art of debugging
  • tomcat
  • Tomcat Exploded war - cut deployment time
  • Tomcat on linux tips
  • Tomcat on linux tips commands
  • TypeIt4Me
  • Typinator
  • Useful Eclipse Plugins
  • Useful Eclipse Plugins eclipse shortcuts keys
  • Useful tools
  • web content
  • xcode cocos2d iphone box2d
  • xpath xml xquery

Blog Archive

  • ►  2013 (19)
    • ►  August (17)
    • ►  July (1)
    • ►  January (1)
  • ►  2012 (7)
    • ►  August (1)
    • ►  June (4)
    • ►  April (2)
  • ►  2011 (20)
    • ►  November (1)
    • ►  October (1)
    • ►  August (1)
    • ►  July (3)
    • ►  June (1)
    • ►  April (2)
    • ►  March (4)
    • ►  February (1)
    • ►  January (6)
  • ►  2010 (27)
    • ►  December (3)
    • ►  July (2)
    • ►  May (3)
    • ►  April (2)
    • ►  March (5)
    • ►  February (10)
    • ►  January (2)
  • ►  2009 (32)
    • ►  December (5)
    • ►  November (2)
    • ►  September (3)
    • ►  August (6)
    • ►  June (4)
    • ►  May (4)
    • ►  April (3)
    • ►  March (2)
    • ►  February (3)
  • ►  2008 (28)
    • ►  December (1)
    • ►  October (2)
    • ►  September (2)
    • ►  August (4)
    • ►  July (7)
    • ►  June (1)
    • ►  April (2)
    • ►  March (2)
    • ►  February (2)
    • ►  January (5)
  • ▼  2007 (24)
    • ▼  December (3)
      • Hibernate second level cache
      • All about UK Visa.
      • LinuxPerformance Tuning(apache,tomcat,linux) and r...
    • ►  November (2)
    • ►  October (6)
    • ►  September (1)
    • ►  August (3)
    • ►  July (8)
    • ►  June (1)
Powered by Blogger.

About Me

Unknown
View my complete profile