001/* 002 * Copyright 2008-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2008-2024 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2008-2024 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.unboundidds.monitors; 037 038 039 040import java.io.Serializable; 041import java.util.Collections; 042import java.util.List; 043 044import com.unboundid.util.NotMutable; 045import com.unboundid.util.NotNull; 046import com.unboundid.util.ThreadSafety; 047import com.unboundid.util.ThreadSafetyLevel; 048 049 050 051/** 052 * This class defines a data structure that can hold information about a thread 053 * stack trace read from the Directory Server's stack trace monitor. 054 * <BR> 055 * <BLOCKQUOTE> 056 * <B>NOTE:</B> This class, and other classes within the 057 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 058 * supported for use against Ping Identity, UnboundID, and 059 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 060 * for proprietary functionality or for external specifications that are not 061 * considered stable or mature enough to be guaranteed to work in an 062 * interoperable way with other types of LDAP servers. 063 * </BLOCKQUOTE> 064 * <BR> 065 * The information available in a thread stack trace includes: 066 * <UL> 067 * <LI>The name of the thread. This is generally a user-friendly string that 068 * indicates what that thread does within the server.</LI> 069 * <LI>The thread ID that is assigned to the thread by the JVM.</LI> 070 * <LI>The stack trace frames for that thread as a list of 071 * {@link StackTraceElement} objects.</LI> 072 * </UL> 073 * See the documentation in the {@link StackTraceMonitorEntry} class for 074 * information about accessing the Directory Server stack trace. 075 */ 076@NotMutable() 077@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 078public final class ThreadStackTrace 079 implements Serializable 080{ 081 /** 082 * The serial version UID for this serializable class. 083 */ 084 private static final long serialVersionUID = 5032934844534051999L; 085 086 087 088 // The thread ID for this thread. 089 private final int threadID; 090 091 // The list of stack trace elements for the thread. 092 @NotNull private final List<StackTraceElement> stackTraceElements; 093 094 // The name for this thread. 095 @NotNull private final String threadName; 096 097 098 099 /** 100 * Creates a new thread stack trace with the provided information. 101 * 102 * @param threadID The thread ID for the associated thread. 103 * @param threadName The name for the associated thread. 104 * @param stackTraceElements A list of the stack trace elements for the 105 * associated thread. It may be empty if no stack 106 * trace was available. 107 */ 108 public ThreadStackTrace(final int threadID, @NotNull final String threadName, 109 @NotNull final List<StackTraceElement> stackTraceElements) 110 { 111 this.threadID = threadID; 112 this.threadName = threadName; 113 this.stackTraceElements = Collections.unmodifiableList(stackTraceElements); 114 } 115 116 117 118 /** 119 * Retrieves the thread ID for the associated thread. 120 * 121 * @return The thread ID for the associated thread. 122 */ 123 public int getThreadID() 124 { 125 return threadID; 126 } 127 128 129 130 /** 131 * Retrieves the name of the associated thread. 132 * 133 * @return The name of the associated thread. 134 */ 135 @NotNull() 136 public String getThreadName() 137 { 138 return threadName; 139 } 140 141 142 143 /** 144 * Retrieves the list of stack trace elements for the associated thread. 145 * 146 * @return The list of stack trace elements for the associated thread, or an 147 * empty list if no stack trace was available. 148 */ 149 @NotNull() 150 public List<StackTraceElement> getStackTraceElements() 151 { 152 return stackTraceElements; 153 } 154}