Skip to content

Commit e9efd81

Browse files
authored
AdminClient: add getServerInfo API (#1468)
1 parent 6f1a144 commit e9efd81

15 files changed

Lines changed: 1206 additions & 1 deletion

adminapi/src/main/java/io/minio/admin/MinioAdminClient.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.minio.Signer;
3232
import io.minio.Time;
3333
import io.minio.admin.messages.DataUsageInfo;
34+
import io.minio.admin.messages.info.Message;
3435
import io.minio.credentials.Credentials;
3536
import io.minio.credentials.Provider;
3637
import io.minio.credentials.StaticProvider;
@@ -79,7 +80,8 @@ private enum Command {
7980
DATA_USAGE_INFO("datausageinfo"),
8081
ADD_UPDATE_REMOVE_GROUP("update-group-members"),
8182
GROUP_INFO("group"),
82-
LIST_GROUPS("groups");
83+
LIST_GROUPS("groups"),
84+
INFO("info");
8385
private final String value;
8486

8587
private Command(String value) {
@@ -597,6 +599,20 @@ public DataUsageInfo getDataUsageInfo()
597599
}
598600
}
599601

602+
/**
603+
* Obtains admin info for the Minio server.
604+
*
605+
* @return admin info for the Minio server.
606+
* @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library.
607+
* @throws InvalidKeyException thrown to indicate missing of HMAC SHA-256 library.
608+
* @throws IOException thrown to indicate I/O error on MinIO REST operation.
609+
*/
610+
public Message getServerInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
611+
try (Response response = execute(Method.GET, Command.INFO, null, null)) {
612+
return OBJECT_MAPPER.readValue(response.body().charStream(), Message.class);
613+
}
614+
}
615+
600616
/**
601617
* Sets HTTP connect, write and read timeouts. A value of 0 means no timeout, otherwise values
602618
* must be between 1 and Integer.MAX_VALUE when converted to milliseconds.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage,
3+
* (C) 2022 MinIO, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package io.minio.admin.messages.info;
19+
20+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
import java.util.Collections;
23+
import java.util.LinkedList;
24+
import java.util.List;
25+
26+
/**
27+
* ErasureBackend contains specific erasure storage information
28+
*
29+
* @see <a href=
30+
* "https://github.com/minio/madmin-go/blob/main/info-commands.go#L359">info-commands.go</a>
31+
*/
32+
@JsonIgnoreProperties(ignoreUnknown = true)
33+
public class Backend {
34+
@JsonProperty("backendType")
35+
private String backendType;
36+
37+
@JsonProperty("onlineDisks")
38+
private Integer onlineDisks;
39+
40+
@JsonProperty("offlineDisks")
41+
private Integer offlineDisks;
42+
43+
@JsonProperty("standardSCParity")
44+
private Integer standardSCParity;
45+
46+
@JsonProperty("rrSCParity")
47+
private Integer rrSCParity;
48+
49+
@JsonProperty("totalSets")
50+
private List<Integer> totalSets;
51+
52+
@JsonProperty("totalDrivesPerSet")
53+
private List<Integer> totalDrivesPerSet;
54+
55+
public String backendType() {
56+
return backendType;
57+
}
58+
59+
public Integer onlineDisks() {
60+
return onlineDisks;
61+
}
62+
63+
public Integer offlineDisks() {
64+
return offlineDisks;
65+
}
66+
67+
public Integer standardSCParity() {
68+
return standardSCParity;
69+
}
70+
71+
public Integer rrSCParity() {
72+
return rrSCParity;
73+
}
74+
75+
public List<Integer> totalSets() {
76+
return Collections.unmodifiableList(totalSets == null ? new LinkedList<>() : totalSets);
77+
}
78+
79+
public List<Integer> totalDrivesPerSet() {
80+
return Collections.unmodifiableList(
81+
totalDrivesPerSet == null ? new LinkedList<>() : totalDrivesPerSet);
82+
}
83+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage,
3+
* (C) 2022 MinIO, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package io.minio.admin.messages.info;
19+
20+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
23+
/**
24+
* Buckets contains the number of buckets
25+
*
26+
* @see <a href=
27+
* "https://github.com/minio/madmin-go/blob/main/info-commands.go#L286">info-commands.go</a>
28+
*/
29+
@JsonIgnoreProperties(ignoreUnknown = true)
30+
public class Buckets {
31+
@JsonProperty("count")
32+
private Integer count;
33+
34+
@JsonProperty("error")
35+
private String error;
36+
37+
public Integer count() {
38+
return count;
39+
}
40+
41+
public String error() {
42+
return error;
43+
}
44+
}
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
/*
2+
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage,
3+
* (C) 2022 MinIO, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package io.minio.admin.messages.info;
19+
20+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
import java.math.BigDecimal;
23+
24+
/**
25+
* Disk holds Disk information
26+
*
27+
* @see <a href=
28+
* "https://github.com/minio/madmin-go/blob/main/info-commands.go#L404">info-commands.go</a>
29+
*/
30+
@JsonIgnoreProperties(ignoreUnknown = true)
31+
public class Disk {
32+
@JsonProperty("endpoint")
33+
private String endpoint;
34+
35+
@JsonProperty("rootDisk")
36+
private boolean rootDisk;
37+
38+
@JsonProperty("path")
39+
private String path;
40+
41+
@JsonProperty("healing")
42+
private boolean healing;
43+
44+
@JsonProperty("scanning")
45+
private boolean scanning;
46+
47+
@JsonProperty("state")
48+
private String state;
49+
50+
@JsonProperty("uuid")
51+
private String uuid;
52+
53+
@JsonProperty("major")
54+
private BigDecimal major;
55+
56+
@JsonProperty("minor")
57+
private BigDecimal minor;
58+
59+
@JsonProperty("model")
60+
private String model;
61+
62+
@JsonProperty("totalspace")
63+
private BigDecimal totalspace;
64+
65+
@JsonProperty("usedspace")
66+
private BigDecimal usedspace;
67+
68+
@JsonProperty("availspace")
69+
private BigDecimal availspace;
70+
71+
@JsonProperty("readthroughput")
72+
private BigDecimal readthroughput;
73+
74+
@JsonProperty("writethroughput")
75+
private BigDecimal writethroughput;
76+
77+
@JsonProperty("readlatency")
78+
private BigDecimal readlatency;
79+
80+
@JsonProperty("writelatency")
81+
private BigDecimal writelatency;
82+
83+
@JsonProperty("utilization")
84+
private BigDecimal utilization;
85+
86+
@JsonProperty("metrics")
87+
private DiskMetrics metrics;
88+
89+
@JsonProperty("heal_info")
90+
private HealingDisk healInfo;
91+
92+
@JsonProperty("used_inodes")
93+
private BigDecimal usedInodes;
94+
95+
@JsonProperty("free_inodes")
96+
private BigDecimal freeInodes;
97+
98+
@JsonProperty("pool_index")
99+
private Integer poolIndex;
100+
101+
@JsonProperty("set_index")
102+
private Integer setIndex;
103+
104+
@JsonProperty("disk_index")
105+
private Integer diskIndex;
106+
107+
public String endpoint() {
108+
return endpoint;
109+
}
110+
111+
public boolean isRootDisk() {
112+
return rootDisk;
113+
}
114+
115+
public String path() {
116+
return path;
117+
}
118+
119+
public boolean isHealing() {
120+
return healing;
121+
}
122+
123+
public boolean isScanning() {
124+
return scanning;
125+
}
126+
127+
public String state() {
128+
return state;
129+
}
130+
131+
public String uuid() {
132+
return uuid;
133+
}
134+
135+
public BigDecimal major() {
136+
return major;
137+
}
138+
139+
public BigDecimal minor() {
140+
return minor;
141+
}
142+
143+
public String model() {
144+
return model;
145+
}
146+
147+
public BigDecimal totalspace() {
148+
return totalspace;
149+
}
150+
151+
public BigDecimal usedspace() {
152+
return usedspace;
153+
}
154+
155+
public BigDecimal availspace() {
156+
return availspace;
157+
}
158+
159+
public BigDecimal readthroughput() {
160+
return readthroughput;
161+
}
162+
163+
public BigDecimal writethroughput() {
164+
return writethroughput;
165+
}
166+
167+
public BigDecimal readlatency() {
168+
return readlatency;
169+
}
170+
171+
public BigDecimal writelatency() {
172+
return writelatency;
173+
}
174+
175+
public BigDecimal utilization() {
176+
return utilization;
177+
}
178+
179+
public DiskMetrics metrics() {
180+
return metrics;
181+
}
182+
183+
public HealingDisk healInfo() {
184+
return healInfo;
185+
}
186+
187+
public BigDecimal usedInodes() {
188+
return usedInodes;
189+
}
190+
191+
public BigDecimal freeInodes() {
192+
return freeInodes;
193+
}
194+
195+
public Integer poolIndex() {
196+
return poolIndex;
197+
}
198+
199+
public Integer setIndex() {
200+
return setIndex;
201+
}
202+
203+
public Integer diskIndex() {
204+
return diskIndex;
205+
}
206+
}

0 commit comments

Comments
 (0)