Alternative less expensive stats service. (#549)
* Alternative less expensive stats service. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix NEP. Address is optional. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * revert null check, Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Specified return object. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add tenant count overall. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
import org.eclipse.hawkbit.repository.report.model.SystemUsageReport;
|
||||
import org.eclipse.hawkbit.repository.report.model.SystemUsageReportWithTenants;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -70,6 +71,14 @@ public interface SystemManagement {
|
||||
* @return SystemUsageReport of the current system
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
||||
SystemUsageReportWithTenants getSystemUsageStatisticsWithTenants();
|
||||
|
||||
/**
|
||||
* Calculated overall system usage statistics
|
||||
*
|
||||
* @return SystemUsageReport of the current system
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
||||
SystemUsageReport getSystemUsageStatistics();
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.report.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bean for holding the system usage stats.
|
||||
*
|
||||
@@ -21,8 +17,7 @@ public class SystemUsageReport {
|
||||
private final long overallArtifacts;
|
||||
private final long overallArtifactVolumeInBytes;
|
||||
private final long overallActions;
|
||||
|
||||
private final List<TenantUsage> tenants = new ArrayList<>();
|
||||
private final long overallTenants;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -35,60 +30,35 @@ public class SystemUsageReport {
|
||||
* of the system
|
||||
* @param overallArtifactVolumeInBytes
|
||||
* of the system
|
||||
* @param overallTenants
|
||||
* of the system
|
||||
*/
|
||||
public SystemUsageReport(final long overallTargets, final long overallArtifacts, final long overallActions,
|
||||
final long overallArtifactVolumeInBytes) {
|
||||
super();
|
||||
final long overallArtifactVolumeInBytes, final long overallTenants) {
|
||||
this.overallTargets = overallTargets;
|
||||
this.overallArtifacts = overallArtifacts;
|
||||
this.overallActions = overallActions;
|
||||
|
||||
this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes;
|
||||
this.overallTenants = overallTenants;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return overallTargets in the system
|
||||
*/
|
||||
public long getOverallTargets() {
|
||||
return overallTargets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return overallArtifacts in the system
|
||||
*/
|
||||
public long getOverallArtifacts() {
|
||||
return overallArtifacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return overallArtifactVolumeInBytes of the system
|
||||
*/
|
||||
public long getOverallArtifactVolumeInBytes() {
|
||||
return overallArtifactVolumeInBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenantUsage
|
||||
* of one tenant
|
||||
* @return updated bean
|
||||
*/
|
||||
public SystemUsageReport addTenantData(final TenantUsage tenantUsage) {
|
||||
tenants.add(tenantUsage);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return actions of system
|
||||
*/
|
||||
public long getOverallActions() {
|
||||
return overallActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return tenant data
|
||||
*/
|
||||
public List<TenantUsage> getTenants() {
|
||||
return Collections.unmodifiableList(tenants);
|
||||
public long getOverallTenants() {
|
||||
return overallTenants;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.report.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bean for holding the system usage stats including tenant specific data.
|
||||
*
|
||||
*/
|
||||
public class SystemUsageReportWithTenants extends SystemUsageReport {
|
||||
|
||||
private final List<TenantUsage> tenants = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param overallTargets
|
||||
* of the system
|
||||
* @param overallArtifacts
|
||||
* of the system
|
||||
* @param overallActions
|
||||
* of the system
|
||||
* @param overallArtifactVolumeInBytes
|
||||
* of the system
|
||||
*/
|
||||
public SystemUsageReportWithTenants(final long overallTargets, final long overallArtifacts,
|
||||
final long overallActions, final long overallArtifactVolumeInBytes, final long overallTenants) {
|
||||
super(overallTargets, overallArtifacts, overallActions, overallArtifactVolumeInBytes, overallTenants);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenantUsage
|
||||
* of one tenant
|
||||
* @return updated bean
|
||||
*/
|
||||
public SystemUsageReportWithTenants addTenantData(final TenantUsage tenantUsage) {
|
||||
tenants.add(tenantUsage);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return tenant data
|
||||
*/
|
||||
public List<TenantUsage> getTenants() {
|
||||
return Collections.unmodifiableList(tenants);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user