001/*
002 * Copyright 2008-2020 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2008-2020 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) 2015-2020 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;
041
042import com.unboundid.util.NotMutable;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045
046
047
048/**
049 * This class provides a data structure that may be used to hold information
050 * about disk space information for a Directory Server component.
051 * <BR>
052 * <BLOCKQUOTE>
053 *   <B>NOTE:</B>  This class, and other classes within the
054 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
055 *   supported for use against Ping Identity, UnboundID, and
056 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
057 *   for proprietary functionality or for external specifications that are not
058 *   considered stable or mature enough to be guaranteed to work in an
059 *   interoperable way with other types of LDAP servers.
060 * </BLOCKQUOTE>
061 */
062@NotMutable()
063@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
064public final class DiskSpaceInfo
065       implements Serializable
066{
067  /**
068   * The serial version UID for this serializable class.
069   */
070  private static final long serialVersionUID = -7798824641501237274L;
071
072
073
074  // The number of total bytes at the specified path.
075  private final Long totalBytes;
076
077  // The number of usable bytes at the specified path.
078  private final Long usableBytes;
079
080  // The percentage of the total space that is usable.
081  private final Long usablePercent;
082
083  // The name of the associated disk space consumer.
084  private final String consumerName;
085
086  // The path in which the disk space is being consumed.
087  private final String path;
088
089
090
091  /**
092   * Creates a new disk space info object with the provided information.
093   *
094   * @param  consumerName   The name of the server component which may consume
095   *                        disk space.
096   * @param  path           The path in which the server component may consume
097   *                        disk space.
098   * @param  totalBytes     The total amount of space in bytes on the volume
099   *                        that holds the specified path.
100   * @param  usableBytes    The amount of usable space in bytes on the volume
101   *                        that holds the specified path.
102   * @param  usablePercent  The percentage of the total space that is usable on
103   *                        the volume that holds the specified path.
104   */
105  public DiskSpaceInfo(final String consumerName, final String path,
106                       final Long totalBytes, final Long usableBytes,
107                       final long usablePercent)
108  {
109    this.consumerName  = consumerName;
110    this.path          = path;
111    this.totalBytes    = totalBytes;
112    this.usableBytes   = usableBytes;
113    this.usablePercent = usablePercent;
114  }
115
116
117
118  /**
119   * The name of the server component which may consume disk space.
120   *
121   * @return  The name of the server component which may consume disk space, or
122   *          {@code null} if that is not available.
123   */
124  public String getConsumerName()
125  {
126    return consumerName;
127  }
128
129
130
131  /**
132   * Retrieves the path in which the server component may consume disk space.
133   *
134   * @return  The path in which the server component may consume disk space, or
135   *          {@code null} if that is not available.
136   */
137  public String getPath()
138  {
139    return path;
140  }
141
142
143
144  /**
145   * Retrieves the total amount of space in bytes on the volume that holds the
146   * specified path.
147   *
148   * @return  The total amount of space in bytes on the volume that holds the
149   *          specified path, or {@code null} if that is not available.
150   */
151  public Long getTotalBytes()
152  {
153    return totalBytes;
154  }
155
156
157
158  /**
159   * Retrieves the amount of usable free space in bytes on the volume that holds
160   * the specified path.
161   *
162   * @return  The total amount of usable free space in bytes on the volume that
163   *          holds the specified path, or {@code null} if that is not
164   *          available.
165   */
166  public Long getUsableBytes()
167  {
168    return usableBytes;
169  }
170
171
172
173  /**
174   * Retrieves the percentage of the total space on the volume that holds the
175   * specified path which is free and usable by the Directory Server.
176   *
177   * @return  The percentage of the total space on the volume that holds the
178   *          specified path which is free and usable by the Directory Server.
179   */
180  public Long getUsablePercent()
181  {
182    return usablePercent;
183  }
184
185
186
187  /**
188   * Retrieves a string representation of this disk space info object.
189   *
190   * @return  A string representation of this disk space info object.
191   */
192  @Override()
193  public String toString()
194  {
195    final StringBuilder buffer = new StringBuilder();
196    toString(buffer);
197    return buffer.toString();
198  }
199
200
201
202  /**
203   * Appends a string representation of this disk space info object to the
204   * provided buffer.
205   *
206   * @param  buffer  The buffer to which the information should be appended.
207   */
208  public void toString(final StringBuilder buffer)
209  {
210    buffer.append("DiskSpaceInfo(consumerName='");
211    buffer.append(consumerName);
212    buffer.append("', path='");
213    buffer.append(path);
214    buffer.append("', totalBytes=");
215    buffer.append(totalBytes);
216    buffer.append(", usableBytes=");
217    buffer.append(usableBytes);
218    buffer.append(", usablePercent=");
219    buffer.append(usablePercent);
220    buffer.append(')');
221  }
222}