Tuesday, January 25, 2011

Tomcat Clustering

Open Source Load Balancing Softwares

Nice post about LB softwares and I found this on a good blog http://linuxpoison.blogspot.com/

 Linux Virtual Server

The Linux Virtual Server Project is a project to cluster many real servers together into a highly available, high-performance virtual server. The LVS load balancer handles connections from clients and passes them on the the real servers (so-called Layer 4 switching) and can virtualize almost any TCP or UDP service, like HTTP, HTTPS, NNTP, FTP, DNS, ssh, POP3, IMAP4, SMTP, etc. It is fully transparent to the client accessing the virtual service.
Homepage:
http://www.LinuxVirtualServer.org/

BalanceNG

BalanceNG is a modern software IP load balancing solution. It is small, fast, and easy to use and setup. It offers session persistence, different distribution methods (Round Robin, Random, Weighted Random, Least Session, Least Bandwidth, Hash, Agent, and Randomized Agent) and a customizable UDP health check agent in source code. It supports VRRP to set up high availability configurations on multiple nodes. It supports SNMP, integrating the BALANCENG-MIB with Net-SNMPD. It implements a very fast in-memory IP-to-location database, allowing powerful location-based server load-balancing.
Homepage:http://www.inlab.de/balanceng/

HAproxy 

HAproxy is a high-performance and highly-robust TCP and HTTP load balancer which provides cookie-based persistence, content-based switching, advanced traffic regulation with surge protection, automatic failover, run-time regex-based header control, Web-based reporting, advanced logging to help trouble-shooting buggy applications and/or networks, and a few other features. Its own event-driven state machine achieves 20,000 hits per second and surpasses GigaEthernet on modern hardware, even with tens of thousands of simultaneous connections.
Homepage:
http://haproxy.1wt.eu/

Pen

Pen is a load balancer for "simple" TCP-based protocols such as HTTP or SMTP. It allows several servers to appear as one to the outside. It automatically detects servers that are down and distributes clients among the available servers. This gives high availability and scalable performance.
Homepage:
http://siag.nu/pen/

Crossroads Load Balancer

Crossroads is a daemon running in user space, and features extensive configurability, polling of back ends using wake up calls, status reporting, many algorithms to select the 'right' back end for a request (and user-defined algorithms for very special cases), and much more. Crossroads is service-independent: it is usable for any TCP service, such as HTTP(S), SSH, SMTP, and database connections. In the case of HTTP balancing, Crossroads can provide session stickiness for back end processes that need sessions, but aren't session-aware of other back ends. Crossroads can be run as a stand-alone daemon or via inetd.
Homepage:
http://crossroads.e-tunity.com/

Balance

Balance is a simple but powerful generic TCP proxy with round-robin load balancing and failover mechanisms. Its behavior can be controlled at runtime using a simple command line syntax. Balance supports IPv6 on the listening side, which makes it a very useful tool for IPv6 migration of IPv4 only services and servers.
Homepage:
http://www.inlab.de/balance.html

Distributor load balancer

Distributor is a software TCP load balancer. Like other load balancers, it accepts connections and distributes them to an array of back end servers. It is compatible with any standard TCP protocol (HTTP, LDAP, IMAP, etc.) and is also IPv6 compatible. It has many unique and advanced features and a high-performance architecture.
Homepage:
http://distributor.sourceforge.net/

Pure Load Balancer

Pure Load Balancer is a high-performance software load balancer for the HTTP and SMTP protocols. It uses an asynchronous non-forking/non-blocking model, and provides fail-over abilities. When a backend server goes down, it automatically removes it from the server pool, and tries to bring it back to life later. Pure Load Balancer has full IPv6 support and works on OpenBSD, NetBSD, FreeBSD and Linux.
Homepage:
http://plb.sunsite.dk/

Load Balancer Project

The Load Balancer Project is a tool that allows you to balance requests using clusters of servers. The goal is to achieve high availability load balancing with a simple configuration for the load balancer and the network topology. It leaves the servers untouched so the configuration only resides on the load balancer, and it allows you to manage any type of service via a plugin model design and a transparent proxy feature.
Homepage:
http://www.jmcresearch.com/projects/loadbalancer/

mod_athena

mod_athena is an Apache-based application load balancer for large systems. It allows the HTTP server to act as a load balancer either internally to Apache's own mod_proxy (for reverse proxying), or externally to machines querying it. Arbitrary statistics are sent to the engine via a simple GET plus query-string interface, from which it will then make decisions based on chosen algorithms.
Homepage:
http://ath.sourceforge.net/

udpbalancer 

Udpbalancer is a reverse proxy that sorts UDP requests from your clients to your servers. It may operate in round-robin, volume balance, and load balance modes.
Homepage:
http://dev.acts.hu/udpbalancer/

MultiLoad

MultiLoad is a load balancer that redirects HTTP requests to pre-defined servers/locations. It gives the provider a way to balance the traffic and hides the real download location. It allows you to manage different version of each download. It is also a load balancing server extension. You can distribute files on some servers so that a downloaded file can be loaded form different servers. These servers can have different priorities to control the active traffic.
Homepage:
http://download.laukien.com

Tuesday, January 18, 2011

Hibernate Connection Fails if there is Database inconsistency or DB fail-over (Oracle RAC)

        /**
     * A static method with returns Hibernate Sessoin Object.
     *
     * @return {@link Session}
     */
    public static Session getSession() throws HibernateException {
        Session appSession = sessionFactory.openSession();
        try
        {
                if(appSession.connection().isClosed()||!appSession.isConnected()||!appSession.isOpen()){
                        System.out.println("Session Closed, Creating Session again...");
                        appSession.reconnect(appSession.connection());
                }
        }
            catch (Exception e) {
                System.err.println("Got Problem while getting Session from Factory:"+ e.getMessage());
                e.printStackTrace();
            }
        return appSession;
      
    }

Sunday, January 16, 2011

Printing CLOB Object Data in JSP

<tr>
                <td>
                        <PRE><%String line;
                                if (docObj != null) {
                                    BufferedReader in = new BufferedReader(docObj.getDocument().getCharacterStream());
                                    line = in.readLine();
                                    while (line != null) {
                                        line = line.replace(">", "&gt;");
                                        line = line.replace("<", "&lt;");
                                        out.println(line);
                                        out.flush();
                                        line = in.readLine();
                                    }
                                }
                            %>
                         </PRE>
                </td>
            </tr>

Monday, October 25, 2010

Top Ten Tomcat Configuration Tips - O'Reilly Media

Top Ten Tomcat Configuration Tips - O'Reilly Media

Modifying the JVM heap size Formula

 
The total value of all server JVM heap sizes within the dynamic cluster for a specific node must be less than half of the total RAM of that computer. To determine the maximum heap size setting for a single server instance, use the following equation:
total_RAM / 2 / number_of_servers = maximum_heap_size
For example, to support three servers on a machine with 1.5 GB of RAM:
1.5 GB / 2 = 750 MB
750 MB / 3 = 250 MB
The maximum heap size is 250 MB for each server instance.

Friday, October 22, 2010

oracle queries

Covert Date to Timestamp
  1. TO_TIMESTAMP(SYSDATE,'DD-MM-RRRR HH24:MI:SS') FROM DUAL;

Oracle Dates difference in Days

create or replace
function date_diff( p_date1 DATE , p_date2 DATE)
return char
is
 Years        NUMBER;
 months       NUMBER;
 days         NUMBER;
 day_fraction NUMBER;
 hrs          NUMBER;
 mints        NUMBER;
 sec          NUMBER;
begin
 Years :=trunc( months_between( p_date2 , p_date1 ) /12 );
 months:=mod( trunc( months_between( p_date2, p_date1 ) ), 12 );
 days  :=trunc(p_date2 - add_months(p_date1,trunc(months_between(p_date2,p_date1) )));
 day_fraction:= (p_date2-p_date1)-trunc(p_date2-p_date1);
 hrs   :=trunc(day_fraction*24);
 mints :=trunc((((day_fraction)*24)-(hrs))*60);
 sec   :=trunc(mod((p_date2-p_date1)*86400,60));
--Just Retrun days as of now, igonore rest output.
 --return(years||' Years '||months||' Months '||days||' Days '||hrs||' Hours '||mints||' Minutes '||sec||' Seconds');
 return(days);
end;

Oracle timestamp difference in Days

create or replace
FUNCTION timestamp_diff
(
start_time_in TIMESTAMP
, end_time_in TIMESTAMP
)
-- RETURN NUMBER
RETURN VARCHAR
AS
l_days NUMBER;
l_hours NUMBER;
l_minutes NUMBER;
l_seconds NUMBER;
l_milliseconds NUMBER;
BEGIN
SELECT extract(DAY FROM end_time_in-start_time_in)
, extract(HOUR FROM end_time_in-start_time_in)
, extract(MINUTE FROM end_time_in-start_time_in)
, extract(SECOND FROM end_time_in-start_time_in)
INTO l_days, l_hours, l_minutes, l_seconds
FROM dual;
--l_milliseconds := l_seconds*1000 + l_minutes*60*1000 + l_hours*60*60*1000 + l_days*24*60*60*1000;
--RETURN ' Milliseconds ' || l_milliseconds;
l_milliseconds := (l_seconds - FLOOR(l_seconds) ) * 1000000 ; -- + l_minutes*60*1000 + l_hours*60*60*1000 + l_days*24*60*60*1000;
--RETURN 'Days '|| l_days ||' Hours '|| l_hours||' Minutes '||l_minutes||' Seconds '||FLOOR(l_seconds)||' Milliseconds '|| l_milliseconds;
--Just return days from now.
RETURN l_days;
END;

Saturday, October 16, 2010

Interesting aspects of life - Warren Buffet

Something to think about....

There was one hour interview on CNBC with Warren Buffet, the second richest man who has donated $31 billion to charity.
Here are some very interesting aspects of his life:

1. He bought his first share at age 11 and he now regrets that he started too late!!!!
2. He bought a small farm at age 14 with savings from delivering newspapers.
3. He still lives in the same small 3-bedroom house in mid-town Omaha,  that he bought after he got married 50 years ago. He says that he has  everything he needs in that house. His house does not have a wall or afence.
4. He drives his own car everywhere and does not have a driver or security people around him.
5. He never travels by private jet, although he owns the world's largest private jet company.
6. His company, Berkshire Hathaway, owns 63 companies.  He writes only one letter each year to the CEOs of these companies,
giving them goals  for the year. He never holds meetings or calls them on a regular basis.

 He has given his CEO's only two rules.

Rule number 1: do not lose any  of your share holder's money.
Rule number 2: Do not forget rule number 1.

7. He does not socialize with the high society crowd. His past time  after he gets home is to make himself some pop corn and watch
Television.
8. Bill Gates, the world's richest man met him for the first time only  5 years ago. Bill Gates did not think he had anything in common with  Warren Buffet. So he had scheduled his meeting only for half hour. But  when Gates met him, the meeting lasted for ten hours and Bill Gates  became a devotee of Warren Buffet.
9. Warren Buffet does not carry a cell phone, nor has a computer on his desk.

 His advice to young people: "Stay away from credit cards and invest in yourself and  Remember:

 A. Money doesn't create man but it is man who created money.
 B. Live your life as simple as you are.
 C. Don't do what others say, just listen to them, but do what you feel good.
 D. Don't go on brand name; just wear things u feel comfortable in.
 E. Don't waste your money on unnecessary things; just spend on them who are really in need.
 F. After all it's your life then why give chance to others to rule our life."