@@ -108,12 +108,17 @@ public CapacityDaoImpl() {
108108 public List <SummedCapacity > findCapacityBy (Integer capacityType , Long zoneId , Long podId , Long clusterId ){
109109
110110 SummedCapacitySearch = createSearchBuilder (SummedCapacity .class );
111+ SummedCapacitySearch .select ("dcId" , Func .NATIVE , SummedCapacitySearch .entity ().getDataCenterId ());
111112 SummedCapacitySearch .select ("sumUsed" , Func .SUM , SummedCapacitySearch .entity ().getUsedCapacity ());
112113 SummedCapacitySearch .select ("sumReserved" , Func .SUM , SummedCapacitySearch .entity ().getReservedCapacity ());
113114 SummedCapacitySearch .select ("sumTotal" , Func .SUM , SummedCapacitySearch .entity ().getTotalCapacity ());
114115 SummedCapacitySearch .select ("capacityType" , Func .NATIVE , SummedCapacitySearch .entity ().getCapacityType ());
115-
116- SummedCapacitySearch .groupBy (SummedCapacitySearch .entity ().getCapacityType ());
116+
117+ if (zoneId ==null && podId ==null && clusterId ==null ){ // List all the capacities grouped by zone, capacity Type
118+ SummedCapacitySearch .groupBy (SummedCapacitySearch .entity ().getDataCenterId (), SummedCapacitySearch .entity ().getCapacityType ());
119+ }else {
120+ SummedCapacitySearch .groupBy (SummedCapacitySearch .entity ().getCapacityType ());
121+ }
117122
118123 if (zoneId != null ){
119124 SummedCapacitySearch .and ("dcId" , SummedCapacitySearch .entity ().getDataCenterId (), Op .EQ );
@@ -262,6 +267,7 @@ public static class SummedCapacity {
262267 public short capacityType ;
263268 public Long clusterId ;
264269 public Long podId ;
270+ public Long dcId ;
265271 public SummedCapacity () {
266272 }
267273 public SummedCapacity (long sumUsed , long sumReserved , long sumTotal ,
@@ -274,6 +280,11 @@ public SummedCapacity(long sumUsed, long sumReserved, long sumTotal,
274280 this .clusterId = clusterId ;
275281 this .podId = podId ;
276282 }
283+ public SummedCapacity (long sumUsed , long sumReserved , long sumTotal ,
284+ short capacityType , Long clusterId , Long podId , Long zoneId ) {
285+ this (sumUsed , sumReserved , sumTotal , capacityType , clusterId , podId );
286+ this .dcId = zoneId ;
287+ }
277288 public Short getCapacityType () {
278289 return capacityType ;
279290 }
@@ -286,6 +297,9 @@ public long getReservedCapacity() {
286297 public Long getTotalCapacity () {
287298 return sumTotal ;
288299 }
300+ public Long getDataCenterId () {
301+ return dcId ;
302+ }
289303 }
290304 public List <SummedCapacity > findByClusterPodZone (Long zoneId , Long podId , Long clusterId ){
291305
0 commit comments