Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "OSEE/ReqAndDesign"

(Design)
(Design)
Line 10: Line 10:
  
 
=== Design ===
 
=== Design ===
  Log entry in DB: entry_id, parent_id, timestamp, user_id, log_level, type_id, duration, status, details (maybe in JSON format)
+
  Log entry in DB: entry_id, parent_id, timestamp, duration, user_id, type_id, status, details in JSON format
  
  Log entry in Java: Level level, long entryId, long timestamp, long duration, long userId, long typeId, long status, long parentId, String message
+
  Log entry in Java: long entryId, long timestamp, long duration, long userId, long typeId, long status, long parentId, String message
  
  Log entry type in DB: type_id, message_format
+
  Log entry type in DB: type_id, log_level, message_format
  
 
* id - random long returned for log method call
 
* id - random long returned for log method call
Line 35: Line 35:
 
** [http://www.precisejava.com/javaperf/j2ee/JDBC.htm Optimize JDBC Performance]
 
** [http://www.precisejava.com/javaperf/j2ee/JDBC.htm Optimize JDBC Performance]
  
  long create[Level](long userId, long typeId);
+
  long createEntry(long userId, long typeId);
  
  long create[Level](long userId, long typeId, long parentId);
+
  long createEntry(long userId, long typeId, long parentId);
  
  long create[Level](long userId, long typeId, String format, Object... args);
+
  long createEntry(long userId, long typeId, Object... messageArgs);
  
  long create[Level](long userId, long typeId, long parentId, String format, Object... args);
+
  long createEntry(long userId, long typeId, long parentId, Object... messageArgs);
  
  void updateEntry(long entryId, long status, String format, Object... args);
+
  void updateEntry(long entryId, long status, Object... messageArgs);
  
 
  void updateEntry(long entryId, long status);
 
  void updateEntry(long entryId, long status);
  
  RuntimeException create[Level](long userId, long typeId, Throwable throwable);
+
  RuntimeException createEntry[Level](long userId, long typeId, Throwable throwable);
  
  RuntimeException create[Level](long userId, long typeId, long parentId, Throwable throwable);
+
  RuntimeException createEntry[Level](long userId, long typeId, long parentId, Throwable throwable);
  
 
  RuntimeException updateEntry(long entryId, Throwable throwable);
 
  RuntimeException updateEntry(long entryId, Throwable throwable);

Revision as of 14:45, 31 October 2013

Logging

Requirements

  • shall handle creation/update of thousands of log entries per second
  • shall support logging by OSEE and other applications
  • log entries related to an individual instance of a user request shall be able to be logically grouped and accessed
  • log entries shall be quickly accessible based on any combination of source, user, timestamp, log type, duration, status
  • log entries shall be accessible (especially) when an application server is unresponsive
  • log entries shall be available until they are deleted by an admin or admin policy (applied by server automatically)
  • at run-time logging shall be enabled/disabled based on any combination of user, source, log level, and type

Design

Log entry in DB: entry_id, parent_id, timestamp, duration, user_id, type_id, status, details in JSON format
Log entry in Java: long entryId, long timestamp, long duration, long userId, long typeId, long status, long parentId, String message
Log entry type in DB: type_id, log_level, message_format
  • id - random long returned for log method call
  • parent_id - id of entry used for grouping this and related entries. Is negative for root entries and is the id of source of the entry client or server random id. Ranges are used to group by client/server kind (IDE client, app server, rest client).
  • timestamp - long with ms since epoch
  • user_id - long user id (artifact id of a user artifact)
  • log_level - as defined by java.util.logging.Level
  • type_id - a fine-grained application defined type, random id, defined as tokens and stored in the db for cross application support
  • duration - starts at -1 and is never updated if duration does not apply, otherwise updates when the associated job ends with duration in ms
  • Status:
 0     initial value
 1-99  percent complete
 100   completed normally
 101   completed abnormally
  • high performance
    • option A - 2 identical length arraylists are allocated with an initial configurable size
    • log entries are added to a queue see data structure options
    • a queue to collect log entries for a short time (configurable) and then inserts them in batch. This means that any update to a log entry that occurs in less than this configured time will not require a database update (i.e. writing the duration of a short operation). This also means only one thread writes to the log table per server.
    • Optimize JDBC Performance
long createEntry(long userId, long typeId);
long createEntry(long userId, long typeId, long parentId);
long createEntry(long userId, long typeId, Object... messageArgs);
long createEntry(long userId, long typeId, long parentId, Object... messageArgs);
void updateEntry(long entryId, long status, Object... messageArgs);
void updateEntry(long entryId, long status);
RuntimeException createEntry[Level](long userId, long typeId, Throwable throwable);
RuntimeException createEntry[Level](long userId, long typeId, long parentId, Throwable throwable);
RuntimeException updateEntry(long entryId, Throwable throwable);

Exception Handling

Requirements

  • avoid unnecessary wrapping of exceptions

Design

Checked exceptions I love you, but you have to go Why should you use Unchecked exceptions over Checked exceptions Clean Code by Example: Checked versus unchecked exceptions

  • Use application specific exceptions that extend RuntimeException - application specific allows for setting exception breakpoints in the debugger
  • Do not declare any run-time exceptions in any method signatures

Back to the top