mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 10297: make default page size unlimited (-1)
This commit is contained in:
parent
2421236414
commit
93090d867d
@ -23,7 +23,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
||||
|
||||
public abstract class BaseListCmd extends BaseCmd {
|
||||
|
||||
private static Long MAX_PAGESIZE = 500L;
|
||||
private static Long MAX_PAGESIZE = null;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////// BaseList API parameters /////////////////
|
||||
@ -52,15 +52,21 @@ public abstract class BaseListCmd extends BaseCmd {
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
if (pageSize != null && pageSize.longValue() > MAX_PAGESIZE.longValue()) {
|
||||
if (pageSize != null && MAX_PAGESIZE != null && pageSize.longValue() > MAX_PAGESIZE.longValue()) {
|
||||
throw new InvalidParameterValueException("Page size can't exceed max allowed page size value: " + MAX_PAGESIZE.longValue());
|
||||
}
|
||||
|
||||
if (pageSize != null && pageSize.longValue() == -1 && page != null) {
|
||||
throw new InvalidParameterValueException("Can't specify page parameter when pagesize is -1 (Unlimited)");
|
||||
}
|
||||
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
static void configure() {
|
||||
MAX_PAGESIZE = _configService.getDefaultPageSize();
|
||||
if (_configService.getDefaultPageSize().longValue() != -1) {
|
||||
MAX_PAGESIZE = _configService.getDefaultPageSize();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,19 +76,21 @@ public abstract class BaseListCmd extends BaseCmd {
|
||||
}
|
||||
|
||||
public Long getPageSizeVal() {
|
||||
Long pageSize = MAX_PAGESIZE;
|
||||
Long defaultPageSize = MAX_PAGESIZE;
|
||||
Integer pageSizeInt = getPageSize();
|
||||
if (pageSizeInt != null && pageSizeInt.intValue() != -1) {
|
||||
pageSize = pageSizeInt.longValue();
|
||||
defaultPageSize = pageSizeInt.longValue();
|
||||
}
|
||||
return pageSize;
|
||||
return defaultPageSize;
|
||||
}
|
||||
|
||||
public Long getStartIndex() {
|
||||
Long startIndex = Long.valueOf(0);
|
||||
Long pageSizeVal = getPageSizeVal();
|
||||
|
||||
if (page != null) {
|
||||
if (pageSizeVal == null) {
|
||||
startIndex = null;
|
||||
} else if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeVal * (pageNum - 1));
|
||||
|
||||
@ -229,7 +229,7 @@ public enum Config {
|
||||
VmOpCleanupWait("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.wait", "3600", "Time (in seconds) to wait before cleanuping up any vm work items", "Seconds"),
|
||||
VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval", "3600", "Time (in seconds) to wait before cancelling a operation", "Seconds"),
|
||||
|
||||
DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null),
|
||||
DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "-1", "Default page size for API list* commands; default value is -1 (Unlimited) ", null),
|
||||
|
||||
TaskCleanupRetryInterval("Advanced", ManagementServer.class, Integer.class, "task.cleanup.retry.interval", "600", "Time (in seconds) to wait before retrying cleanup of tasks if the cleanup failed previously. 0 means to never retry.", "Seconds"),
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user