001 /*
002 * Copyright 2008-2015 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2015 UnboundID Corp.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021 package com.unboundid.ldap.sdk.unboundidds.monitors;
022
023
024
025 import java.io.Serializable;
026 import java.util.Collections;
027 import java.util.List;
028
029 import com.unboundid.util.NotMutable;
030 import com.unboundid.util.ThreadSafety;
031 import com.unboundid.util.ThreadSafetyLevel;
032
033
034
035 /**
036 * <BLOCKQUOTE>
037 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID
038 * LDAP SDK for Java. It is not available for use in applications that
039 * include only the Standard Edition of the LDAP SDK, and is not supported for
040 * use in conjunction with non-UnboundID products.
041 * </BLOCKQUOTE>
042 * This class defines a data structure that can hold information about a thread
043 * stack trace read from the UnboundID Directory Server's stack trace monitor.
044 * The information available in a thread stack trace includes:
045 * <UL>
046 * <LI>The name of the thread. This is generally a user-friendly string that
047 * indicates what that thread does within the server.</LI>
048 * <LI>The thread ID that is assigned to the thread by the JVM.</LI>
049 * <LI>The stack trace frames for that thread as a list of
050 * {@link StackTraceElement} objects.</LI>
051 * </UL>
052 * See the documentation in the {@link StackTraceMonitorEntry} class for
053 * information about accessing the Directory Server stack trace.
054 */
055 @NotMutable()
056 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
057 public final class ThreadStackTrace
058 implements Serializable
059 {
060 /**
061 * The serial version UID for this serializable class.
062 */
063 private static final long serialVersionUID = 5032934844534051999L;
064
065
066
067 // The thread ID for this thread.
068 private final int threadID;
069
070 // The list of stack trace elements for the thread.
071 private final List<StackTraceElement> stackTraceElements;
072
073 // The name for this thread.
074 private final String threadName;
075
076
077
078 /**
079 * Creates a new thread stack trace with the provided information.
080 *
081 * @param threadID The thread ID for the associated thread.
082 * @param threadName The name for the associated thread.
083 * @param stackTraceElements A list of the stack trace elements for the
084 * associated thread. It may be empty if no stack
085 * trace was available.
086 */
087 public ThreadStackTrace(final int threadID, final String threadName,
088 final List<StackTraceElement> stackTraceElements)
089 {
090 this.threadID = threadID;
091 this.threadName = threadName;
092 this.stackTraceElements = Collections.unmodifiableList(stackTraceElements);
093 }
094
095
096
097 /**
098 * Retrieves the thread ID for the associated thread.
099 *
100 * @return The thread ID for the associated thread.
101 */
102 public int getThreadID()
103 {
104 return threadID;
105 }
106
107
108
109 /**
110 * Retrieves the name of the associated thread.
111 *
112 * @return The name of the associated thread.
113 */
114 public String getThreadName()
115 {
116 return threadName;
117 }
118
119
120
121 /**
122 * Retrieves the list of stack trace elements for the associated thread.
123 *
124 * @return The list of stack trace elements for the associated thread, or an
125 * empty list if no stack trace was available.
126 */
127 public List<StackTraceElement> getStackTraceElements()
128 {
129 return stackTraceElements;
130 }
131 }