info.aduna.gee.publication.servlets.util
Class ZpadCounter

java.lang.Object
  extended by info.aduna.gee.publication.servlets.util.ZpadCounter

public class ZpadCounter
extends Object

Zpad hit counter utility


Field Summary
protected static String[] _counterNames
           
protected static Hashtable[] _hitCounters
           
protected static HashMap _lastHitDowPerHost
          This map remembers per virtual host the day of week (dow) at which the last hit was registered.
static int CONTENT
           
protected static int HIT_COUNTERS
           
static int LOGIN
           
static int PAGE
           
static String PAGE_USERNAME
          The fake username used for the pages counter.
static int ZPAD
           
 
Constructor Summary
ZpadCounter()
           
 
Method Summary
protected static String _dayIndexToName(int dayIndex)
          Translate our day indices (0,..6) to names.
protected static void _store(String host, int type, int dow)
          Store a type/dow counter.
static void destroy()
          On destroy save the current counters to disk.
static void ensureCountersLoaded(String host)
          Make sure the stored files on disk are loaded for a host.
static Date getDate(int day)
          Get a Date matching a day in the last week.
static int getHighestCount(int type, String host, String username)
          Get the highest count of one type for a specific user in the last week.
static SortedSet getHits(int type, String host)
          Get a sorted overview of all hits of a single type for all users on a host over the last 7 days.
static int getUserHits(int type, String host, String username)
          Get the number of hits of a single type for a single user on a host over the last 7 days.
static int getUserHitsPerDay(int day, int type, String host, String username)
          Get the number of hits of a single type for a single user on a host for a specific day.
static void hit(int type, String host, UserInfo user)
          Count a hit of a type on a server for a user.
static void restore(String host)
          Restore the current counters for a host from disk.
static void store(String host)
          Store the (all) current counters for a host to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_lastHitDowPerHost

protected static HashMap _lastHitDowPerHost
This map remembers per virtual host the day of week (dow) at which the last hit was registered.


PAGE_USERNAME

public static String PAGE_USERNAME
The fake username used for the pages counter.


ZPAD

public static int ZPAD

CONTENT

public static int CONTENT

LOGIN

public static int LOGIN

PAGE

public static int PAGE

_counterNames

protected static String[] _counterNames

HIT_COUNTERS

protected static int HIT_COUNTERS

_hitCounters

protected static Hashtable[] _hitCounters
Constructor Detail

ZpadCounter

public ZpadCounter()
Method Detail

hit

public static void hit(int type,
                       String host,
                       UserInfo user)
Count a hit of a type on a server for a user.

Parameters:
type - one of ZPAD, CONTENT, LOGIN, PAGE
host - the host
user - the user

getHits

public static SortedSet getHits(int type,
                                String host)
Get a sorted overview of all hits of a single type for all users on a host over the last 7 days.

Parameters:
type - one of ZPAD, CONTENT, LOGIN, PAGE
host - the host

getUserHits

public static int getUserHits(int type,
                              String host,
                              String username)
Get the number of hits of a single type for a single user on a host over the last 7 days.

Parameters:
type - one of ZPAD, CONTENT, LOGIN, PAGE
host - the host
username - the user's name

getUserHitsPerDay

public static int getUserHitsPerDay(int day,
                                    int type,
                                    String host,
                                    String username)
Get the number of hits of a single type for a single user on a host for a specific day.

Parameters:
day - 0 = today, -1 = yesterday, -2 = day before yesterday, ... -6 = almost one week ago
type - one of ZPAD, CONTENT, LOGIN, PAGE
host - the host
username - the user's name

getHighestCount

public static int getHighestCount(int type,
                                  String host,
                                  String username)
Get the highest count of one type for a specific user in the last week.

Parameters:
type - one of ZPAD, CONTENT, LOGIN, PAGE
host - the host
username - the user's name

getDate

public static Date getDate(int day)
Get a Date matching a day in the last week.

Parameters:
day - 0 = today, -1 = yesterday, -2 = day before yesterday, ... -6 = almost one week ago

ensureCountersLoaded

public static void ensureCountersLoaded(String host)
Make sure the stored files on disk are loaded for a host.


store

public static void store(String host)
Store the (all) current counters for a host to disk.


_store

protected static void _store(String host,
                             int type,
                             int dow)
Store a type/dow counter.


restore

public static void restore(String host)
Restore the current counters for a host from disk.


destroy

public static void destroy()
                    throws IOException
On destroy save the current counters to disk.

Throws:
IOException

_dayIndexToName

protected static String _dayIndexToName(int dayIndex)
Translate our day indices (0,..6) to names.



Copyright © 1997-2008 Aduna. All Rights Reserved.