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