001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: * The Original Software is NetBeans. The Initial Developer of the Original
026: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027: * Microsystems, Inc. All Rights Reserved.
028: *
029: * If you wish your version of this file to be governed by only the CDDL
030: * or only the GPL Version 2, indicate your decision by adding
031: * "[Contributor] elects to include this software in this distribution
032: * under the [CDDL or GPL Version 2] license." If you do not indicate a
033: * single choice of license, a recipient has the option to distribute
034: * your version of this file under either the CDDL, the GPL Version 2 or
035: * to extend the choice of license to its licensees as provided above.
036: * However, if you add GPL Version 2 code and therefore, elected the GPL
037: * Version 2 license, then the option applies only if the new code is
038: * made subject to such option by the copyright holder.
039: */
040:
041: package org.netbeans.lib.profiler.global;
042:
043: import java.util.ResourceBundle;
044:
045: /**
046: * Various Profiler engine-internal constants used in various parts of the system.
047: *
048: * @author Tomas Hurka
049: * @author Misha Dmitriev
050: */
051: public interface CommonConstants {
052: //~ Static fields/initializers -----------------------------------------------------------------------------------------------
053:
054: // -----
055: // I18N String constants
056: static final ResourceBundle messages = ResourceBundle
057: .getBundle("org.netbeans.lib.profiler.global.Bundle"); // NOI18N
058: public static final String THREAD_STATUS_UNKNOWN_STRING = messages
059: .getString("CommonConstants_ThreadStatusUnknownString"); // NOI18N // TODO CHECK: unused method
060: public static final String THREAD_STATUS_ZOMBIE_STRING = messages
061: .getString("CommonConstants_ThreadStatusZombieString"); // NOI18N
062: public static final String THREAD_STATUS_RUNNING_STRING = messages
063: .getString("CommonConstants_ThreadStatusRunningString"); // NOI18N
064: public static final String THREAD_STATUS_SLEEPING_STRING = messages
065: .getString("CommonConstants_ThreadStatusSleepingString"); // NOI18N;
066: public static final String THREAD_STATUS_MONITOR_STRING = messages
067: .getString("CommonConstants_ThreadStatusMonitorString"); // NOI18N
068: public static final String THREAD_STATUS_WAIT_STRING = messages
069: .getString("CommonConstants_ThreadStatusWaitString"); // NOI18N
070: // -----
071:
072: /** Names of our own classes, in various forms */
073: public static final String PROFILER_SERVER_SLASHED_CLASS_PREFIX = "org/netbeans/lib/profiler/server/"; // NOI18N
074: public static final String PROFILER_DOTTED_CLASS_PREFIX = "org.netbeans.lib.profiler."; // NOI18N
075:
076: // Agent state
077: public static final int AGENT_STATE_NOT_RUNNING = 0;
078: public static final int AGENT_STATE_READY_DYNAMIC = 1;
079: public static final int AGENT_STATE_READY_DIRECT = 2;
080: public static final int AGENT_STATE_CONNECTED = 3;
081: public static final int AGENT_STATE_DIFFERENT_ID = 4;
082: public static final int AGENT_STATE_OTHER_SESSION_IN_PROGRESS = 5;
083:
084: // Agent Id
085: public static final int AGENT_ID_ANY = -1;
086:
087: /** Numeric JDK versions that we currently distinguish between */
088: public static final int JDK_15 = 2;
089: public static final int JDK_16 = 3; // we treat JDK 1.5 the same as Tiger for now
090: public static final int JDK_17 = 4; // we treat JDK 17 the same as JDK 1.5 for now
091: public static final int JDK_UNSUPPORTED = -1;
092:
093: /** Denoting strings for JDK versions that we currently distinguish between */
094: public static final String JDK_15_STRING = "jdk15"; // NOI18N
095: public static final String JDK_16_STRING = "jdk16"; // NOI18N
096: public static final String JDK_17_STRING = "jdk17"; // NOI18N
097: public static final String JDK_UNSUPPORTED_STRING = "UNSUPPORTED_JDK"; // NOI18N
098:
099: /** Constants for determining 32/64bit architecture */
100: public static final int ARCH_32 = 32;
101: public static final int ARCH_64 = 64;
102:
103: /** Size of the event buffer, used to store/read rough profiling data */
104: public static final int EVENT_BUFFER_SIZE_IN_BYTES = 1200000;
105:
106: // Codes of various profiling events, that are generated and stored in the buffer file by server and
107: // then retrieved by tool
108: public static final byte ROOT_ENTRY = 1;
109: public static final byte ROOT_EXIT = 2;
110: public static final byte MARKER_ENTRY = 3;
111: public static final byte MARKER_EXIT = 4;
112: public static final byte ADJUST_TIME = 5;
113: public static final byte METHOD_ENTRY = 6;
114: public static final byte METHOD_EXIT = 7;
115: public static final byte THREADS_SUSPENDED = 8;
116: public static final byte THREADS_RESUMED = 9;
117: public static final byte RESET_COLLECTORS = 10;
118: public static final byte NEW_THREAD = 11;
119: public static final byte OBJ_ALLOC_STACK_TRACE = 12;
120: public static final byte SET_FOLLOWING_EVENTS_THREAD = 13;
121: public static final byte OBJ_LIVENESS_STACK_TRACE = 14;
122: public static final byte OBJ_GC_HAPPENED = 15;
123:
124: // These are used by hybrid (instrumentation-sampling) CPU profiling
125: public static final byte METHOD_ENTRY_UNSTAMPED = 16;
126: public static final byte METHOD_EXIT_UNSTAMPED = 17;
127: public static final byte MARKER_ENTRY_UNSTAMPED = 18;
128: public static final byte MARKER_EXIT_UNSTAMPED = 19;
129: public static final byte METHOD_ENTRY_WAIT = 20;
130: public static final byte METHOD_EXIT_WAIT = 21;
131: public static final byte METHOD_ENTRY_MONITOR = 22;
132: public static final byte METHOD_EXIT_MONITOR = 23;
133: public static final byte METHOD_ENTRY_SLEEP = 24;
134: public static final byte METHOD_EXIT_SLEEP = 25;
135: public static final byte BUFFEREVENT_PROFILEPOINT_HIT = 26;
136: public static final byte SERVLET_DO_METHOD = 27;
137:
138: // Used to easily check for those events that always carry two timestamps (absolute and thread CPU)
139: public static final byte TWO_TIMESTAMP_EVENTS = 6;
140:
141: // The following are used when storing unstamped method entry/exit events in the "compact" format, when both
142: // event code and method id are packed in a single char. See more comments in ProfilerRuntimeCPUSampledInstr.java
143: public static final char MAX_METHOD_ID_FOR_COMPACT_FORMAT = 0x3FFF;
144: public static final byte COMPACT_EVENT_FORMAT_BYTE_MASK = (byte) 0x80;
145: public static final char METHOD_ENTRY_COMPACT_MASK = 0x8000;
146: public static final byte METHOD_ENTRY_COMPACT_BYTE_MASK = (byte) 0x80;
147: public static final char METHOD_EXIT_COMPACT_MASK = 0xC000;
148: public static final byte METHOD_EXIT_COMPACT_BYTE_MASK = (byte) 0xC0;
149: public static final char COMPACT_EVENT_METHOD_ID_MASK = 0x3FFF;
150:
151: // Target app instrumentation types
152: public static final int INSTR_NONE = 0; // no instrumentation performed => no profiling data
153: public static final int INSTR_CODE_REGION = 1; // instrument code region for CPU data
154: public static final int INSTR_RECURSIVE_FULL = 2; // instrument for CPU data, full instrumentation (timestamps for each method entry/exit)
155: public static final int INSTR_RECURSIVE_SAMPLED = 3; // instrument for CPU data, sampled data obtained (timestamps at periodic intervals only)
156: public static final int INSTR_OBJECT_ALLOCATIONS = 4; // instrument for Memory data, allocations only
157: public static final int INSTR_OBJECT_LIVENESS = 5; // instrument for Memory data, complete
158: // These are just helpful constants, not actual instrumentation types
159: public static final int INSTR_MEMORY_BASE = 4;
160: public static final int INSTR_MAXNUMBER = 6;
161:
162: // Constants used to distinguish between "full" and "sampled" CPU instrumentation in the settings.
163: // Internally they are translated into INSTR_RECURSIVE and INSTR_RECURSIVE_SAMPLED, respectively
164: public static final int CPU_INSTR_FULL = 0;
165: public static final int CPU_INSTR_SAMPLED = 1;
166:
167: // Target app instrumentation schemes for CPU profiling
168: public static final int INSTRSCHEME_LAZY = 1; // Lazy scheme (B in the NB Profiler papers/report)
169: public static final int INSTRSCHEME_EAGER = 2; // Eager scheme (A in the above report)
170: public static final int INSTRSCHEME_TOTAL = 3; // Total instrumentation
171:
172: // Names of special Java threads created by NB Profiler
173: public static final String PROFILER_SERVER_THREAD_NAME = "*** Profiler Agent Communication Thread"; // NOI18N
174: public static final String PROFILER_SPECIAL_EXEC_THREAD_NAME = "*** Profiler Agent Special Execution Thread"; // NOI18N
175: public static final String PROFILER_SEPARATE_EXEC_THREAD_NAME = "*** JFluid Separate Command Execution Thread"; // NOI18N
176:
177: // Calibration-only run pseudo main class name
178: public static final String CALIBRATION_PSEUDO_CLASS_NAME = "____Profiler+Calibration+Run____"; // NOI18N
179:
180: // These are used to signal to server that there is no defined root class/method to instrument. Instead, we instrument
181: // run() methods of all threads spawned after instrumentation command is received.
182: public static final String NO_CLASS_NAME = "*NO_CLASS_NAME*"; // NOI18N
183: public static final String NO_METHOD_NAME = "*NO_METHOD_NAME*"; // NOI18N
184: public static final String NO_METHOD_SIGNATURE = "*NO_METHOD_SIGNATURE*"; // NOI18N
185:
186: // Stuff used by various instrumentation-related classes
187: static final String JAVA_LANG_REFLECT_METHOD_DOTTED_CLASS_NAME = "java.lang.reflect.Method"; // NOI18N
188: static final String JAVA_LANG_REFLECT_METHOD_SLASHED_CLASS_NAME = "java/lang/reflect/Method"; // NOI18N
189: static final String INVOKE_METHOD_NAME = "invoke"; // NOI18N
190: static final String INVOKE_METHOD_SIGNATURE = "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"; // NOI18N
191:
192: // Kinds of injections that we make into TA methods
193: public static final int INJ_RECURSIVE_NORMAL_METHOD = 0;
194: public static final int INJ_RECURSIVE_ROOT_METHOD = 1;
195: public static final int INJ_RECURSIVE_MARKER_METHOD = 2;
196: public static final int INJ_RECURSIVE_SAMPLED_NORMAL_METHOD = 3;
197: public static final int INJ_RECURSIVE_SAMPLED_ROOT_METHOD = 4;
198: public static final int INJ_RECURSIVE_SAMPLED_MARKER_METHOD = 5;
199: public static final int INJ_REFLECT_METHOD_INVOKE = 6;
200: public static final int INJ_SERVLET_DO_METHOD = 7;
201: public static final int INJ_CODE_REGION = 8;
202: public static final int INJ_OBJECT_ALLOCATIONS = 9;
203: public static final int INJ_OBJECT_LIVENESS = 10;
204: public static final int INJ_MAXNUMBER = 11;
205:
206: // Thread state constants. We currently use what is provided in JVMDI, and will probably have to change that once
207: // we switch to JVMTI in JDK 5.0
208: public static final byte THREAD_STATUS_UNKNOWN = -1; // Thread status is unknown.
209: public static final byte THREAD_STATUS_ZOMBIE = 0; // Thread is waiting to die. Also used for "doesn't exist yet" and "dead"
210: public static final byte THREAD_STATUS_RUNNING = 1; // Thread is runnable. Note that we unfortunately don't know whether it'
211: // s actually running or pre-empted by another thread...
212: public static final byte THREAD_STATUS_SLEEPING = 2; // Thread is sleeping - Thread.sleep() or JVM_Sleep() was called
213: public static final byte THREAD_STATUS_MONITOR = 3; // Thread is waiting on a java monitor
214: public static final byte THREAD_STATUS_WAIT = 4; // Thread is waiting - Thread.wait() or JVM_MonitorWait() was called
215:
216: // Thread state color constants.
217:
218: /** Thread status is unknown. */
219: public static final java.awt.Color THREAD_STATUS_UNKNOWN_COLOR = java.awt.Color.LIGHT_GRAY;
220:
221: /** Thread is waiting to die. Also used for "doesn't exist yet" and "dead" */
222: public static final java.awt.Color THREAD_STATUS_ZOMBIE_COLOR = java.awt.Color.BLACK;
223:
224: /** Thread is runnable. Note that we unfortunately don't know whether it's actually running or
225: * pre-empted by another thread...*/
226: public static final java.awt.Color THREAD_STATUS_RUNNING_COLOR = new java.awt.Color(
227: 58, 228, 103);
228:
229: /** Thread is sleeping - Thread.sleep() or JVM_Sleep() was called */
230: public static final java.awt.Color THREAD_STATUS_SLEEPING_COLOR = new java.awt.Color(
231: 155, 134, 221);
232:
233: /** Thread is waiting on a java monitor */
234: public static final java.awt.Color THREAD_STATUS_MONITOR_COLOR = new java.awt.Color(
235: 255, 114, 102);
236:
237: /** Thread is waiting - Thread.wait() or JVM_MonitorWait() was called */
238: public static final java.awt.Color THREAD_STATUS_WAIT_COLOR = new java.awt.Color(
239: 255, 228, 90);
240:
241: // Thread state description constants.
242: // see I18N String constants at the top of this file
243:
244: // Constants for results filter types
245: public static final int FILTER_NONE = 0;
246: public static final int FILTER_STARTS_WITH = 10;
247: public static final int FILTER_CONTAINS = 20;
248: public static final int FILTER_ENDS_WITH = 30;
249: public static final int FILTER_EQUALS = 40;
250: public static final int FILTER_REGEXP = 50;
251:
252: // Default sorting column constant, means that target component decides itself which column will be used for sorting
253: public static final int SORTING_COLUMN_DEFAULT = -1;
254:
255: // Miscellaneous
256: public static final String ENGINE_WARNING = "*** Profiler engine warning: "; // NOI18N
257: public static final String PLEASE_REPORT_PROBLEM = "*** Please report this problem to feedback@profiler.netbeans.org"; // NOI18N
258:
259: // Agent versioning
260: public static final int AGENT_VERSION_10_M9 = 1;
261: public static final int AGENT_VERSION_10_M10 = 2;
262: public static final int AGENT_VERSION_60_M5 = 3;
263: public static final int AGENT_VERSION_60_M6 = 4;
264: public static final int AGENT_VERSION_60_M7 = 5;
265: public static final int AGENT_VERSION_60_M8 = 6;
266: public static final int AGENT_VERSION_60_M10 = 7;
267: public static final int AGENT_VERSION_60_BETA1 = 8;
268: public static final int CURRENT_AGENT_VERSION = AGENT_VERSION_60_BETA1;
269: }
|