shiva sarna

Greenhorn
+ Follow
since Jul 23, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by shiva sarna

Hi,


If you want to guarantee that Thread should wake exactly after the time then the best this is to use the wait() method.

For further explaination check this article LINK.

Protozoa
Hi,

I have two serial devices with different baud rates. One is the end device with baud rate 9600 and the other is the coordinator with baud rate 38400. My application is supposed to detect the connected device by sending a command.

1. I open the port with 9600 baud rate, send a command and wait for reply. If I get a reply I detect the end device.

2. If I don't get a reply I close the port and open it with 38400 baud rate, send a command and wait for a reply.

My problem is that when I open the port with one baud rate(9600), close it and then open with other baud rate(38400) my input stream is 0 even when the device is connected to the port.

AM I doing anything wrong here. I am using a RXTX library for serial communication. I tried flushing the output stream but it gives a nativeDrain Exception.

Thanks for your help in advance.

regards
Shiva
15 years ago
Hi,

are you using any frame work? It is possible to set form elements in struts.

If it is plain jsp, try setting 'option' in a session.

<option selected>session element goes here</option>

so what ever the user selects is set in a session and when he comes back he sees that option in the drop down list.

regards

Shiva
16 years ago
Hi,

Here eat() method is overrideen by class Dog2.

Hence according to the overriding rule which version of the method(Animal or Dog2) will be called will de determined at run time depending on the object type and not at compile time.

If the supertype has declared a checked exception the compiler will think that supertype's version is called( in this case Animal's eat method) hence this exception should be caugth.

The following code will compile fine:

class Animal {
public void eat() throws Exception
{

}
}
class Dog2 extends Animal {
public void eat(){ }
public static void main(String [] args)
{
Animal a = new Dog2();
Dog2 d = new Dog2();
d.eat();
try
{
a.eat();
}
catch(Exception e){}
}
}


So even at run time Dog2's eat() version is called at compile time the compiler thinks it is calling Animal's version.

Remember which overridden method is called is determined at runtime and not compile time.

regards

Shiva
Thanks Bill for your prompt reply.

I did try making connection pool small but I got an error that the thread pool is exhausted.

regards

shiva
[ January 29, 2007: Message edited by: shiva sarna ]
17 years ago
Hi,

I am working with tomcat 5.5.17 and am invloved in increasing the performance of a web application.

I have identified database connections as the bottleneck have taken measures to slove the problem as follows.

1. While trying to hit the server with 500 simultaneous users I have changed the parameter of connector as follows:

<Connector port="8080" maxHttpHeaderSize="8192" maxProcessors="150"
maxThreads="200" minSpareThreads="25" maxSpareThreads="75"
maxKeepAliveRequests="1" enableLookups="false" redirectPort="8443" acceptCount="200"
connectionTimeout="0" disableUploadTimeout="true"
moveAbandoned="true" removeAbandonedTimeout="300"/>


If I am expecting 500 users to hit my server I make the total count of maxSpareThread,maxThreads,minSpareThread and acceptCount to 500 i.e all these 4 parameters add upto 500.

2) I have also made my connection pool large enough to handle 500 threads ( I am using JNDI for connection pooling).

My questions are:

1) Is this approach right?.

2) How can I further optomize my tomcat?.

3)Can you please refer any documentation which can help me with this. At present I refer to apache tomcat website for help http://tomcat.apache.org/.

4) Please suggest any open source tools which can help me view how much time tomcat takes to process each request and other usefull informations. At present I am using Jmeter to load test the web application.

thanks for your time and help.

regards

shiva
17 years ago
Hi Merrill,

You were right. Connection was not closed in one of the methods.

The module is working fine, pool size is not increasing and performance is fast.

The problem that we face now is how to make changes to all our action classes.

I really can't think of anything as of now. Even if I write a helper class I will have to refer it in all the classes where I have called the datasource.

You have been of great help.

Thank you.

regards

shiva
17 years ago
Hi Merrill,

When you say JDBC helper class, is it possible to get the reference to the database once and then keep it in session for a user.

Is there any example on net where they have explained how to create a JDBC helper class and get a reference from it.

One more question. Yesterday when I was checking the database connections, I saw that the old connections are not released for example if 5 users login 5 connections will be created. If after logging of these 5 users, I log them back in I see on my ser 10 database connections. I understand this is because of the pool size but then after some time the pool gets exhausted.

So how can I determine the maximum connections in the pool.

Because the client can have anywhere between 100 to 5000 users.

thanks for your help.

regards

shiva
17 years ago
Hi Merrill,

Where the server hanged after 5 users now I am able to run the test for 100 users and it is working fine.

But now the problem is that we have more than 1300 Action classes with us and to change the way connections are called will be a huge task.

I just changed the code for 3 action classes and tested for a module.

So is there a way where I can directly use JNDI without making any changes to all the action classes.

thanks in advance for your time and advice.

regards

shiva
17 years ago
Thanks Merril for your help and advice.

Infact my team has asked me to say thanks to you on their behalf, we all were
cracking our heads over this.

take care

Regards

Shiva
17 years ago
Thanks Merrill and Ajaya for your help. Where have I gone wrong. Why just specifying the datasource in struts config is not sufficient. The books that I referred suggested this method of connection pooling. When connections are pooled then why the performance is degrading.
Our server configuration is perfect,we have zeroed the problem on the database connection code.

Why JNDI connection pooling is better than specifying the datasource in struts config.

Can you please also suggest a document which gives me a proper reason explaning JNDI connection pooling is better than struts connection pooling.

It will be a great help to my team and then we can start making the changes in our application.

thanks again for your help and advice which is useful for me.

Regards

Shiva
17 years ago
Hi Rusty,

I have a question. While I was searching on internet for this problem I came across JNDI connection pooling. Could you suggest how I can do this kind of poling in my application. Any type of documentation on this will be helpfull.

I used jmeter for performance testing and checked out the console for server response. My application works fine for 5 users but as soon as I try to log on 10 users users the server hangs.

thanks for your advice and help.

regards

shiva
17 years ago
Hi,


In my struts application if more than 5 users login at a time it goes extremely slow.

I have checked my action classes and DAO and all my database connection are closed properly.

The login page takes lot of time to load though it is fast if only one or two users have logged in.

Please let me know if there is any other way to pool the database connection.


public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
log.warn("INSIDE AUTHENTICATE ACTION");

LoginForm currentLogin = (LoginForm) form;

String type = null;
int flag = 0;
int userId=0;
String target = "success";
TestTemplate testTemplate = null;

String uid = "";
String pwd = "";
String nonEncryptedPassword = "";

int count = 0;
DataSource dataSource = null;
Connection conn = null;

HttpSession session1 = request.getSession();
ActionErrors errors = new ActionErrors();

dataSource = getDataSource(request);

conn= dataSource.getConnection();

further code goes here
.
.
.
.
.
}

I pass the conn object to my DAO methods

count = UserData.validateUser(uid, pwd, conn);

and then after querying the database I close the statement and result set and int my action class close the connection as well.

if (conn != null) {
conn.close();
conn = null;
}

My question is:

In my web application I am calling a lot of action clases which constantly interact with my database and in all those action clases this is the way the connection is obtained and database queried.
Then why my application goes slow with more users.
Can you please suggest me some ways to improve my application performance.
My application should run fast with atleast 100 users logged in but it goes extremely slow just after five.

Thanks for your time and advice in advance.

regards

Shiva
17 years ago
Hi,

I am new to using Jmeter. I want to load test my struts application with Jmeter.

Could you please suggest any document which can guide me step by step in this procedure.

I did refer apache user manual but I want to know how can I test my action classes.

For example..when a user logs in how can i call my login jsp and then my login action class which validates user name and password.

thanks in advance for your help.

regards

shiva sarna
17 years ago
Hi,

I am working on a scheduler, where the user can add events.

As soon as the user adds the event he is taken back to the calendar where he can see the event link appearing beside the selected date.

My problem is this.

Add event is a pop up window and after the user click the Add button I want the calendar page(parent window) to reload.

As I am using struts to implement this there are different classes involved.

I tried
window.location="Scheduler.do";
window.opener.location.reload();
But this call my Add Action class and not the class I want to call.


Then I tried

window.opener.location.href="Scheduler.do". This works but only once..that is when the user add events to a date first time, the page get refereshed but if he adds the event the second time the add window just closes without refereshing the page.

I am confused why this is happening. is there a way to reset window.opener.location.href.

thanks for your help in advance

regards

shiva