Class StatWriteBuffer

java.lang.Object
sk.iway.iwcm.stat.StatWriteBuffer

public class StatWriteBuffer extends Object
StatWriteBuffer.java Acts as a synchronized buffer for Stat* inserts. Made this way in order to avoid database congestion caused by every user's HTTP request filling the database.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    add(String sql, String table, Object... parameters)
    Adds an SQL statement into a buffer queue.
    static void
    addUpdateInsertPair(String update, String insert, String table, Object... parameters)
    Serves as a facade for a re-occuring pattern in stat tables: int rowsTouched = executeUpdate(); //insert new values into database in case there are none if (rowsTouched == 0) executeInsert(); Acts in a same way as add method NOTE: insert and update must share the same number of parameters for this method to work correctly
    static void
    main(String[] args)
    Sweeps the buffer and flushes its contents into database.
    static int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StatWriteBuffer

      public StatWriteBuffer()
  • Method Details

    • add

      public static void add(String sql, String table, Object... parameters)
      Adds an SQL statement into a buffer queue.
      Parameters:
      sql - SQL statement pushed into prepareStatement allocation
      table - Base table name used for table creation if SQL fails. For inserting into stat_error_2010_07, pass "stat_error" as a parameter
      parameters - Pushed into prepareStatement setObject calls
    • addUpdateInsertPair

      public static void addUpdateInsertPair(String update, String insert, String table, Object... parameters)
      Serves as a facade for a re-occuring pattern in stat tables: int rowsTouched = executeUpdate(); //insert new values into database in case there are none if (rowsTouched == 0) executeInsert(); Acts in a same way as add method NOTE: insert and update must share the same number of parameters for this method to work correctly
      See Also:
    • size

      public static int size()
    • main

      public static void main(String[] args)
      Sweeps the buffer and flushes its contents into database. Launched by a background cron task.