This repository was archived by the owner on Jul 20, 2024. It is now read-only.
forked from splunk/splunk-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLicensePool.java
More file actions
173 lines (155 loc) · 5.03 KB
/
LicensePool.java
File metadata and controls
173 lines (155 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
* Copyright 2012 Splunk, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"): you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.splunk;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The {@code LicensePool} class represents a license pool, which is made up
* of a single license master and zero or more license slave instances of Splunk
* that are configured to use the licensing volume from a set license or license
* stack.
*/
public class LicensePool extends Entity {
/**
* Class constructor.
*
* @param service The connected {@code Service} instance.
* @param path The license pool endpoint.
*/
LicensePool(Service service, String path) {
super(service, path);
}
/**
* Returns the description of this license pool.
*
* @return The description, or {@code null} if not specified.
*/
public String getDescription() {
return getString("description", null);
}
/**
* Returns the indexing quota for this license pool.
*
* @return A string containing the indexing quota in bytes, or "MAX" to
* indicate the maximum amount that is allowed.
*/
public String getQuota() {
return getString("quota", "0");
}
/**
* Returns the list of slaves for this license pool.
*
* @return A comma-separated list of slaves by ID, or {@code null} if not
* specified.
*/
public String[] getSlaves() {
if (toUpdate.containsKey("slaves")) {
String value = (String)toUpdate.get("slaves");
return value.split(",");
}
else {
return getStringArray("slaves", null);
}
}
/**
* Returns the usage of indexing volume by slave licenses in this license
* pool.
*
* @return A map from each slave GUID to the number of bytes it is using.
*/
public Map<String, Long> getSlavesUsageBytes() {
@SuppressWarnings("unchecked")
HashMap<String, Object> values = (HashMap<String, Object>)get("slaves_usage_bytes");
if (values == null) {
values = new HashMap<String, Object>();
}
HashMap<String, Long> usageBytes = new HashMap<String, Long>();
for(String key : values.keySet()) {
String value = (String)values.get(key);
usageBytes.put(key, Long.parseLong(value));
}
return usageBytes;
}
/**
* Returns the stack ID for this license pool. Valid values are:
* <p><ul>
* <li>"download-trial"</li>
* <li>"enterprise"</li>
* <li>"forwarder"</li>
* <li>"free"</li></ul>
*
* @return The license pool stack ID, or {@code null} if not specified.
*/
public String getStackId() {
return getString("stack_id", null);
}
/**
* Returns the usage of indexing volume for this license pool.
*
* @return This license pool's usage, in bytes.
*/
public long getUsedBytes() {
return getLong("used_bytes", 0);
}
/**
* Sets whether to append or overwrite slaves to this license pool.
*
* @param appendSlaves {@code true} to append slaves, {@code false} to
* overwrite slaves.
*/
public void setAppendSlaves(boolean appendSlaves) {
setCacheValue("append_slaves", appendSlaves);
}
/**
* Sets the description of this license pool.
*
* @param description The description.
*/
public void setDescription(String description) {
setCacheValue("description", description);
}
/**
* Sets the byte quota of this license pool.
*
* @param quota The indexing quota of this license pool, specified as:
* <ul><li><i>number</i></li>
* <li><i>number</i> followed by "MB" or "GB" (for example, "10GB")</li>
* <li>"MAX" (Only one license pool can have "MAX" size in a stack.)</li>
* </ul>
*/
public void setQuota(String quota) {
setCacheValue("quota", quota);
}
/**
* Sets the list of slaves that are members of this license pool.
*
* @param slaves The comma-separated list of slaves. Use an asterisk ("*")
* to accept all slaves.
*/
public void setSlaves(String slaves) {
setCacheValue("slaves", slaves);
}
/**
* Sets the list of slaves that are members of this license pool.
*
* @param slaves The array of slaves. To accept all slaves, use an
* array with a single asterisk element ("*").
*/
public void setSlaves(String[] slaves) {
setSlaves(Util.join(",", slaves));
}
}