001/*
002 * Copyright 2008-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 Ping Identity Corporation
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 */
021package com.unboundid.ldap.sdk.unboundidds.monitors;
022
023
024
025import java.io.Serializable;
026import java.util.Collections;
027import java.util.List;
028
029import com.unboundid.util.NotMutable;
030import com.unboundid.util.ThreadSafety;
031import com.unboundid.util.ThreadSafetyLevel;
032
033
034
035/**
036 * This class defines a data structure that can hold information about a thread
037 * stack trace read from the Directory Server's stack trace monitor.
038 * <BR>
039 * <BLOCKQUOTE>
040 *   <B>NOTE:</B>  This class, and other classes within the
041 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
042 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
043 *   server products.  These classes provide support for proprietary
044 *   functionality or for external specifications that are not considered stable
045 *   or mature enough to be guaranteed to work in an interoperable way with
046 *   other types of LDAP servers.
047 * </BLOCKQUOTE>
048 * <BR>
049 * The information available in a thread stack trace includes:
050 * <UL>
051 *   <LI>The name of the thread.  This is generally a user-friendly string that
052 *       indicates what that thread does within the server.</LI>
053 *   <LI>The thread ID that is assigned to the thread by the JVM.</LI>
054 *   <LI>The stack trace frames for that thread as a list of
055 *       {@link StackTraceElement} objects.</LI>
056 * </UL>
057 * See the documentation in the {@link StackTraceMonitorEntry} class for
058 * information about accessing the Directory Server stack trace.
059 */
060@NotMutable()
061@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
062public final class ThreadStackTrace
063       implements Serializable
064{
065  /**
066   * The serial version UID for this serializable class.
067   */
068  private static final long serialVersionUID = 5032934844534051999L;
069
070
071
072  // The thread ID for this thread.
073  private final int threadID;
074
075  // The list of stack trace elements for the thread.
076  private final List<StackTraceElement> stackTraceElements;
077
078  // The name for this thread.
079  private final String threadName;
080
081
082
083  /**
084   * Creates a new thread stack trace with the provided information.
085   *
086   * @param  threadID            The thread ID for the associated thread.
087   * @param  threadName          The name for the associated thread.
088   * @param  stackTraceElements  A list of the stack trace elements for the
089   *                             associated thread.  It may be empty if no stack
090   *                             trace was available.
091   */
092  public ThreadStackTrace(final int threadID, final String threadName,
093                          final List<StackTraceElement> stackTraceElements)
094  {
095    this.threadID           = threadID;
096    this.threadName         = threadName;
097    this.stackTraceElements = Collections.unmodifiableList(stackTraceElements);
098  }
099
100
101
102  /**
103   * Retrieves the thread ID for the associated thread.
104   *
105   * @return  The thread ID for the associated thread.
106   */
107  public int getThreadID()
108  {
109    return threadID;
110  }
111
112
113
114  /**
115   * Retrieves the name of the associated thread.
116   *
117   * @return  The name of the associated thread.
118   */
119  public String getThreadName()
120  {
121    return threadName;
122  }
123
124
125
126  /**
127   * Retrieves the list of stack trace elements for the associated thread.
128   *
129   * @return  The list of stack trace elements for the associated thread, or an
130   *          empty list if no stack trace was available.
131   */
132  public List<StackTraceElement> getStackTraceElements()
133  {
134    return stackTraceElements;
135  }
136}