Web Application – Load Test for Millions of Users Hits – Simple Java Program

import java.io.BufferedReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Random;
import java.io.InputStreamReader;

public class URLRequest
{

public int totalRequests=0;

public void URLHit(int dataID)
{
try {
// Send data
URL url = new URL(“http://121.243.185.200:5050/hbase/search.do?search=r”+dataID);
System.out.print(“URL : “+url +” ID “+dataID);

URLConnection conn = url.openConnection();
conn.setDoOutput(true);
/*OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();*/
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));

String line;
String result=””;
//while ((line = rd.readLine()) != null) {
// Process line…
//result += line;
//}
//System.out.println(“”+result);
//wr.close();
//rd.close();
} catch (Exception e) {
}
}

public static void main(String args[])
{

Random generator = new Random(1000000 );
for(int i=0;i<=100000;i++)
{
int roll = generator.nextInt(1000000);
URLRequest ur = new URLRequest();
ur.URLHit(roll);
}
}

}

Advertisements

About ashokabhat

I am a C,C ,JAVA,Adobe Flex,.NET Programmer Currently working as a Software Developer
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s