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.util.Collections; 041import java.util.LinkedHashMap; 042import java.util.List; 043import java.util.Map; 044 045import com.unboundid.ldap.sdk.Entry; 046import com.unboundid.util.NotMutable; 047import com.unboundid.util.NotNull; 048import com.unboundid.util.Nullable; 049import com.unboundid.util.StaticUtils; 050import com.unboundid.util.ThreadSafety; 051import com.unboundid.util.ThreadSafetyLevel; 052 053import static com.unboundid.ldap.sdk.unboundidds.monitors.MonitorMessages.*; 054 055 056 057/** 058 * This class defines a monitor entry that provides information about the 059 * operations currently being processed by the Directory Server. 060 * <BR> 061 * <BLOCKQUOTE> 062 * <B>NOTE:</B> This class, and other classes within the 063 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 064 * supported for use against Ping Identity, UnboundID, and 065 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 066 * for proprietary functionality or for external specifications that are not 067 * considered stable or mature enough to be guaranteed to work in an 068 * interoperable way with other types of LDAP servers. 069 * </BLOCKQUOTE> 070 * <BR> 071 * The server should present at most one active operations monitor entry. It 072 * can be retrieved using the 073 * {@link MonitorManager#getActiveOperationsMonitorEntry} method. The 074 * {@link ActiveOperationsMonitorEntry#getActiveOperations} method may be used 075 * to retrieve information for each operation in progress. Alternately, this 076 * information may be accessed using the generic API. See the 077 * {@link MonitorManager} class documentation for an example that demonstrates 078 * the use of the generic API for accessing monitor data. 079 */ 080@NotMutable() 081@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 082public final class ActiveOperationsMonitorEntry 083 extends MonitorEntry 084{ 085 /** 086 * The structural object class used in active operations monitor entries. 087 */ 088 @NotNull static final String ACTIVE_OPERATIONS_MONITOR_OC = 089 "ds-active-operations-monitor-entry"; 090 091 092 093 /** 094 * The name of the attribute that contains information about the number of 095 * operations currently in progress. 096 */ 097 @NotNull private static final String ATTR_NUM_OPS_IN_PROGRESS = 098 "num-operations-in-progress"; 099 100 101 102 /** 103 * The name of the attribute that contains information about the number of 104 * persistent searches currently in progress. 105 */ 106 @NotNull private static final String ATTR_NUM_PSEARCHES_IN_PROGRESS = 107 "num-persistent-searches-in-progress"; 108 109 110 111 /** 112 * The name of the attribute that contains information about an operation in 113 * progress. 114 */ 115 @NotNull private static final String ATTR_OP_IN_PROGRESS = 116 "operation-in-progress"; 117 118 119 120 /** 121 * The name of the attribute that contains information about a persistent 122 * search in progress. 123 */ 124 @NotNull private static final String ATTR_PSEARCH_IN_PROGRESS = 125 "persistent-search-in-progress"; 126 127 128 129 /** 130 * The serial version UID for this serializable class. 131 */ 132 private static final long serialVersionUID = -6583987693176406802L; 133 134 135 136 // The list of operations currently in progress. 137 @NotNull private final List<String> activeOperations; 138 139 // The list of persistent searches currently in progress. 140 @NotNull private final List<String> activePersistentSearches; 141 142 // The number of operations currently in progress. 143 @Nullable private final Long numOpsInProgress; 144 145 // The number of persistent searches currently in progress. 146 @Nullable private final Long numPsearchesInProgress; 147 148 149 150 /** 151 * Creates a new active operations monitor entry from the provided entry. 152 * 153 * @param entry The entry to be parsed as a active operations monitor entry. 154 * It must not be {@code null}. 155 */ 156 public ActiveOperationsMonitorEntry(@NotNull final Entry entry) 157 { 158 super(entry); 159 160 activeOperations = getStrings(ATTR_OP_IN_PROGRESS); 161 activePersistentSearches = getStrings(ATTR_PSEARCH_IN_PROGRESS); 162 numOpsInProgress = getLong(ATTR_NUM_OPS_IN_PROGRESS); 163 numPsearchesInProgress = getLong(ATTR_NUM_PSEARCHES_IN_PROGRESS); 164 } 165 166 167 168 /** 169 * Retrieves the number of operations currently in progress in the Directory 170 * Server. 171 * 172 * @return The number of operations currently in progress in the Directory 173 * Server, or {@code null} if it was not included in the monitor 174 * entry. 175 */ 176 @Nullable() 177 public Long getNumOperationsInProgress() 178 { 179 return numOpsInProgress; 180 } 181 182 183 184 /** 185 * Retrieves a list of the string representations of the operations in 186 * progress in the Directory Server. 187 * 188 * @return A list of the string representations of the operations in 189 * progress in the Directory Server, or an empty list if it was not 190 * included in the monitor entry. 191 */ 192 @NotNull() 193 public List<String> getActiveOperations() 194 { 195 return activeOperations; 196 } 197 198 199 200 /** 201 * Retrieves the number of persistent searches currently in progress in the 202 * Directory Server. 203 * 204 * @return The number of persistent searches currently in progress in the 205 * Directory Server, or {@code null} if it was not included in the 206 * monitor entry. 207 */ 208 @Nullable() 209 public Long getNumPersistentSearchesInProgress() 210 { 211 return numPsearchesInProgress; 212 } 213 214 215 216 /** 217 * Retrieves a list of the string representations of the persistent searches 218 * in progress in the Directory Server. 219 * 220 * @return A list of the string representations of the persistent searches in 221 * progress in the Directory Server, or an empty list if it was not 222 * included in the monitor entry. 223 */ 224 @NotNull() 225 public List<String> getActivePersistentSearches() 226 { 227 return activePersistentSearches; 228 } 229 230 231 232 /** 233 * {@inheritDoc} 234 */ 235 @Override() 236 @NotNull() 237 public String getMonitorDisplayName() 238 { 239 return INFO_ACTIVE_OPERATIONS_MONITOR_DISPNAME.get(); 240 } 241 242 243 244 /** 245 * {@inheritDoc} 246 */ 247 @Override() 248 @NotNull() 249 public String getMonitorDescription() 250 { 251 return INFO_ACTIVE_OPERATIONS_MONITOR_DESC.get(); 252 } 253 254 255 256 /** 257 * {@inheritDoc} 258 */ 259 @Override() 260 @NotNull() 261 public Map<String,MonitorAttribute> getMonitorAttributes() 262 { 263 final LinkedHashMap<String,MonitorAttribute> attrs = 264 new LinkedHashMap<>(StaticUtils.computeMapCapacity(4)); 265 266 if (numOpsInProgress != null) 267 { 268 addMonitorAttribute(attrs, 269 ATTR_NUM_OPS_IN_PROGRESS, 270 INFO_ACTIVE_OPERATIONS_DISPNAME_NUM_OPS_IN_PROGRESS.get(), 271 INFO_ACTIVE_OPERATIONS_DESC_NUM_OPS_IN_PROGRESS.get(), 272 numOpsInProgress); 273 } 274 275 if (! activeOperations.isEmpty()) 276 { 277 addMonitorAttribute(attrs, 278 ATTR_OP_IN_PROGRESS, 279 INFO_ACTIVE_OPERATIONS_DISPNAME_OPS_IN_PROGRESS.get(), 280 INFO_ACTIVE_OPERATIONS_DESC_OPS_IN_PROGRESS.get(), 281 activeOperations); 282 } 283 284 if (numPsearchesInProgress != null) 285 { 286 addMonitorAttribute(attrs, 287 ATTR_NUM_PSEARCHES_IN_PROGRESS, 288 INFO_ACTIVE_OPERATIONS_DISPNAME_NUM_PSEARCHES_IN_PROGRESS.get(), 289 INFO_ACTIVE_OPERATIONS_DESC_NUM_PSEARCHES_IN_PROGRESS.get(), 290 numPsearchesInProgress); 291 } 292 293 if (! activePersistentSearches.isEmpty()) 294 { 295 addMonitorAttribute(attrs, 296 ATTR_PSEARCH_IN_PROGRESS, 297 INFO_ACTIVE_OPERATIONS_DISPNAME_PSEARCHES_IN_PROGRESS.get(), 298 INFO_ACTIVE_OPERATIONS_DESC_PSEARCHES_IN_PROGRESS.get(), 299 activePersistentSearches); 300 } 301 302 return Collections.unmodifiableMap(attrs); 303 } 304}