Mmmm, I think people is answering more than one question ;-)
If you need to be strict with respect to the timings, that is, you need
exactly the number of requests in the past five seconds counting from
the moment your request is done, you will need the solution proposed by
Tim. Just remember
More academic exercise than recommendation, but...
Write your own implementation of a Map/HashMap
specific to java.util.Date objects.
Identify your smallest time increment (5 seconds in your email).
Identify largest time increment (60 seconds)
Create (60/5)+1 buckets for your hash function
I need to display on a .jsp page the number of requests for Tomcat in the past 5 / 10
/ 15/ 30 / 45 / 60 seconds. I've already implement a Filter will count the total
number of requests. I did this with a static int, which is incremented everytime a
request comes in. But what should I do so
You could use a list of java.util.Dates with the oldest date at the beginning
of the list and the newest at the end of the List. Push new Dates onto the
list and pull (expired) dates from the front of the list accoring to your
threshold.
The number of hits per unit time is the size of each
display number of requests over the past n seconds?
I need to display on a .jsp page the number of requests for Tomcat in
the
past 5 / 10 / 15/ 30 / 45 / 60 seconds. I've already implement a
Filter
will count the total number of requests. I did this with a static int,
which is incremented everytime