Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdminClient: add getServerInfo API #1468

Merged
merged 23 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion adminapi/src/main/java/io/minio/admin/MinioAdminClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.minio.Signer;
import io.minio.Time;
import io.minio.admin.messages.DataUsageInfo;
import io.minio.admin.messages.InfoMessage;
dormanze marked this conversation as resolved.
Show resolved Hide resolved
import io.minio.credentials.Credentials;
import io.minio.credentials.Provider;
import io.minio.credentials.StaticProvider;
Expand Down Expand Up @@ -79,7 +80,8 @@ private enum Command {
DATA_USAGE_INFO("datausageinfo"),
ADD_UPDATE_REMOVE_GROUP("update-group-members"),
GROUP_INFO("group"),
LIST_GROUPS("groups");
LIST_GROUPS("groups"),
INFO("info");
private final String value;

private Command(String value) {
Expand Down Expand Up @@ -597,6 +599,21 @@ public DataUsageInfo getDataUsageInfo()
}
}

/**
* Obtains admin info for the Minio server.
*
* @return admin info for the Minio server.
* @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library.
* @throws InvalidKeyException thrown to indicate missing of HMAC SHA-256 library.
* @throws IOException thrown to indicate I/O error on MinIO REST operation.
*/
public InfoMessage getServerInfo()
throws IOException, NoSuchAlgorithmException, InvalidKeyException {
try (Response response = execute(Method.GET, Command.INFO, null, null)) {
return OBJECT_MAPPER.readValue(response.body().charStream(), InfoMessage.class);
}
}

/**
* Sets HTTP connect, write and read timeouts. A value of 0 means no timeout, otherwise values
* must be between 1 and Integer.MAX_VALUE when converted to milliseconds.
Expand Down
83 changes: 83 additions & 0 deletions adminapi/src/main/java/io/minio/admin/clusterinfo/Backend.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage,
* (C) 2022 MinIO, 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 io.minio.admin.clusterinfo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
* ErasureBackend contains specific erasure storage information
*
* @see <a href=
* "https://github.com/minio/madmin-go/blob/main/info-commands.go#L359">info-commands.go</a>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Backend {
@JsonProperty("backendType")
private String backendType;

@JsonProperty("onlineDisks")
private Integer onlineDisks;

@JsonProperty("offlineDisks")
private Integer offlineDisks;

@JsonProperty("standardSCParity")
private Integer standardSCParity;

@JsonProperty("rrSCParity")
private Integer rrSCParity;

@JsonProperty("totalSets")
private List<Integer> totalSets;

@JsonProperty("totalDrivesPerSet")
private List<Integer> totalDrivesPerSet;

public String backendType() {
return backendType;
}

public Integer onlineDisks() {
return onlineDisks;
}

public Integer offlineDisks() {
return offlineDisks;
}

public Integer standardSCParity() {
return standardSCParity;
}

public Integer rrSCParity() {
return rrSCParity;
}

public List<Integer> totalSets() {
return Collections.unmodifiableList(totalSets == null ? new LinkedList<>() : totalSets);
}

public List<Integer> totalDrivesPerSet() {
return Collections.unmodifiableList(
totalDrivesPerSet == null ? new LinkedList<>() : totalDrivesPerSet);
}
}
44 changes: 44 additions & 0 deletions adminapi/src/main/java/io/minio/admin/clusterinfo/Buckets.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage,
* (C) 2022 MinIO, 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 io.minio.admin.clusterinfo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Buckets contains the number of buckets
*
* @see <a href=
* "https://github.com/minio/madmin-go/blob/main/info-commands.go#L286">info-commands.go</a>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Buckets {
@JsonProperty("count")
private Integer count;

@JsonProperty("error")
private String error;

public Integer count() {
return count;
}

public String error() {
return error;
}
}
206 changes: 206 additions & 0 deletions adminapi/src/main/java/io/minio/admin/clusterinfo/Disk.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
/*
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage,
* (C) 2022 MinIO, 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 io.minio.admin.clusterinfo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;

/**
* Disk holds Disk information
*
* @see <a href=
* "https://github.com/minio/madmin-go/blob/main/info-commands.go#L404">info-commands.go</a>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Disk {
@JsonProperty("endpoint")
private String endpoint;

@JsonProperty("rootDisk")
private boolean rootDisk;

@JsonProperty("path")
private String path;

@JsonProperty("healing")
private boolean healing;

@JsonProperty("scanning")
private boolean scanning;

@JsonProperty("state")
private String state;

@JsonProperty("uuid")
private String uuid;

@JsonProperty("major")
private BigDecimal major;

@JsonProperty("minor")
private BigDecimal minor;

@JsonProperty("model")
private String model;

@JsonProperty("totalspace")
private BigDecimal totalspace;

@JsonProperty("usedspace")
private BigDecimal usedspace;

@JsonProperty("availspace")
private BigDecimal availspace;

@JsonProperty("readthroughput")
private BigDecimal readthroughput;

@JsonProperty("writethroughput")
private BigDecimal writethroughput;

@JsonProperty("readlatency")
private BigDecimal readlatency;

@JsonProperty("writelatency")
private BigDecimal writelatency;

@JsonProperty("utilization")
private BigDecimal utilization;

@JsonProperty("metrics")
private DiskMetrics metrics;

@JsonProperty("heal_info")
private HealingDisk healInfo;

@JsonProperty("used_inodes")
private BigDecimal usedInodes;

@JsonProperty("free_inodes")
private BigDecimal freeInodes;

@JsonProperty("pool_index")
private Integer poolIndex;

@JsonProperty("set_index")
private Integer setIndex;

@JsonProperty("disk_index")
private Integer diskIndex;

public String endpoint() {
return endpoint;
}

public boolean isRootDisk() {
return rootDisk;
}

public String path() {
return path;
}

public boolean isHealing() {
return healing;
}

public boolean isScanning() {
return scanning;
}

public String state() {
return state;
}

public String uuid() {
return uuid;
}

public BigDecimal major() {
return major;
}

public BigDecimal minor() {
return minor;
}

public String model() {
return model;
}

public BigDecimal totalspace() {
return totalspace;
}

public BigDecimal usedspace() {
return usedspace;
}

public BigDecimal availspace() {
return availspace;
}

public BigDecimal readthroughput() {
return readthroughput;
}

public BigDecimal writethroughput() {
return writethroughput;
}

public BigDecimal readlatency() {
return readlatency;
}

public BigDecimal writelatency() {
return writelatency;
}

public BigDecimal utilization() {
return utilization;
}

public DiskMetrics metrics() {
return metrics;
}

public HealingDisk healInfo() {
return healInfo;
}

public BigDecimal usedInodes() {
return usedInodes;
}

public BigDecimal freeInodes() {
return freeInodes;
}

public Integer poolIndex() {
return poolIndex;
}

public Integer setIndex() {
return setIndex;
}

public Integer diskIndex() {
return diskIndex;
}
}
Loading