001/* 002// This software is subject to the terms of the Eclipse Public License v1.0 003// Agreement, available at the following URL: 004// http://www.eclipse.org/legal/epl-v10.html. 005// You must accept the terms of that agreement to use this software. 006// 007// Copyright (C) 2011-2013 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.server.monitor; 011 012import mondrian.rolap.RolapUtil; 013 014import java.io.PrintWriter; 015import java.io.StringWriter; 016 017/** 018 * Base class for an event of interest. 019 * 020 * <p>This class, and subclasses, is an immutable but serializable.</p> 021 */ 022public abstract class Event implements Message { 023 /** 024 * When the event occurred. Milliseconds since the epoch UTC, just like 025 * {@link System#currentTimeMillis()}. 026 */ 027 public final long timestamp; 028 029 /** 030 * When {@link RolapUtil#MONITOR_LOGGER} is set to TRACE, 031 * this field will contain the stack of the code which 032 * created this event. 033 */ 034 public final String stack; 035 036 /** 037 * Creates an Event. 038 * 039 * @param timestamp Timestamp 040 * 041 */ 042 public Event( 043 long timestamp) 044 { 045 this.timestamp = timestamp; 046 if (RolapUtil.MONITOR_LOGGER.isTraceEnabled()) { 047 try { 048 throw new Exception(); 049 } catch (Exception e) { 050 StringWriter sw = new StringWriter(); 051 e.printStackTrace(new PrintWriter(sw, true)); 052 this.stack = sw.toString(); 053 } 054 } else { 055 this.stack = null; 056 } 057 } 058} 059 060// End Event.java