incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [43/45] git commit: CLOUDSTACK-355: fix count for listSwiftsCmd.
Date Wed, 23 Jan 2013 07:15:57 GMT
CLOUDSTACK-355: fix count for listSwiftsCmd.

Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/c3f1a9d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/c3f1a9d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/c3f1a9d3

Branch: refs/heads/cloud-agent-with-openvswitch
Commit: c3f1a9d324ad01450df315242bdabe6edd0c7e60
Parents: 26be5ce
Author: Min Chen <min.chen@citrix.com>
Authored: Tue Jan 22 17:14:44 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Tue Jan 22 17:14:44 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/resource/ResourceService.java    |    5 +++--
 .../api/command/admin/swift/ListSwiftsCmd.java     |   10 +++++-----
 .../com/cloud/resource/ResourceManagerImpl.java    |    5 +++--
 .../src/com/cloud/storage/swift/SwiftManager.java  |    3 ++-
 .../com/cloud/storage/swift/SwiftManagerImpl.java  |    7 ++++---
 .../cloud/resource/MockResourceManagerImpl.java    |    2 +-
 6 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c3f1a9d3/api/src/com/cloud/resource/ResourceService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/resource/ResourceService.java b/api/src/com/cloud/resource/ResourceService.java
index b9db8e7..7348a5a 100755
--- a/api/src/com/cloud/resource/ResourceService.java
+++ b/api/src/com/cloud/resource/ResourceService.java
@@ -34,6 +34,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.org.Cluster;
 import com.cloud.storage.S3;
 import com.cloud.storage.Swift;
+import com.cloud.utils.Pair;
 import com.cloud.utils.fsm.NoTransitionException;
 import org.apache.cloudstack.api.command.admin.host.ReconnectHostCmd;
 
@@ -94,10 +95,10 @@ public interface ResourceService {
     Swift discoverSwift(AddSwiftCmd addSwiftCmd) throws DiscoveryException;
 
     S3 discoverS3(AddS3Cmd cmd) throws DiscoveryException;
-    
+
     List<HypervisorType> getSupportedHypervisorTypes(long zoneId, boolean forVirtualRouter,
Long podId);
 
-    List<? extends Swift> listSwifts(ListSwiftsCmd cmd);
+    Pair<List<? extends Swift>, Integer> listSwifts(ListSwiftsCmd cmd);
 
     List<? extends S3> listS3s(ListS3sCmd cmd);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c3f1a9d3/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java
index d7c1511..af26643 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java
@@ -30,6 +30,7 @@ import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.SwiftResponse;
 import com.cloud.storage.Swift;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 @APICommand(name = "listSwifts", description = "List Swift.", responseObject = HostResponse.class,
since="3.0.0")
 public class ListSwiftsCmd extends BaseListCmd {
@@ -64,20 +65,19 @@ public class ListSwiftsCmd extends BaseListCmd {
 
     @Override
     public void execute(){
-        List<? extends Swift> result = _resourceService.listSwifts(this);
+        Pair<List<? extends Swift>, Integer> result = _resourceService.listSwifts(this);
         ListResponse<SwiftResponse> response = new ListResponse<SwiftResponse>();
         List<SwiftResponse> swiftResponses = new ArrayList<SwiftResponse>();
 
         if (result != null) {
-            SwiftResponse swiftResponse = null;
-            for (Swift swift : result) {
-                swiftResponse = _responseGenerator.createSwiftResponse(swift);
+            for (Swift swift : result.first()) {
+                SwiftResponse swiftResponse = _responseGenerator.createSwiftResponse(swift);
                 swiftResponse.setResponseName(getCommandName());
                 swiftResponse.setObjectName("swift");
                 swiftResponses.add(swiftResponse);
             }
         }
-        response.setResponses(swiftResponses);
+        response.setResponses(swiftResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c3f1a9d3/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index b6ee747..f82424a 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -560,8 +560,9 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService,
Ma
     }
 
     @Override
-    public List<SwiftVO> listSwifts(ListSwiftsCmd cmd) {
-        return _swiftMgr.listSwifts(cmd);
+    public Pair<List<? extends Swift>, Integer> listSwifts(ListSwiftsCmd cmd)
{
+        Pair<List<SwiftVO>, Integer> swifts =  _swiftMgr.listSwifts(cmd);
+        return new Pair<List<? extends Swift>, Integer>(swifts.first(), swifts.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c3f1a9d3/server/src/com/cloud/storage/swift/SwiftManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/swift/SwiftManager.java b/server/src/com/cloud/storage/swift/SwiftManager.java
index 0dd6e1c..2abdac7 100644
--- a/server/src/com/cloud/storage/swift/SwiftManager.java
+++ b/server/src/com/cloud/storage/swift/SwiftManager.java
@@ -27,6 +27,7 @@ import com.cloud.exception.DiscoveryException;
 import com.cloud.storage.Swift;
 import com.cloud.storage.SwiftVO;
 import com.cloud.storage.VMTemplateSwiftVO;
+import com.cloud.utils.Pair;
 import com.cloud.utils.component.Manager;
 public interface SwiftManager extends Manager {
 
@@ -50,7 +51,7 @@ public interface SwiftManager extends Manager {
 
     Long chooseZoneForTmpltExtract(Long tmpltId);
 
-    List<SwiftVO> listSwifts(ListSwiftsCmd cmd);
+    Pair<List<SwiftVO>, Integer> listSwifts(ListSwiftsCmd cmd);
 
     VMTemplateSwiftVO findByTmpltId(Long tmpltId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c3f1a9d3/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/swift/SwiftManagerImpl.java b/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
index dab16ce..d62dd63 100644
--- a/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
+++ b/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
@@ -50,6 +50,7 @@ import com.cloud.storage.dao.SwiftDao;
 import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.dao.VMTemplateSwiftDao;
 import com.cloud.storage.dao.VMTemplateZoneDao;
+import com.cloud.utils.Pair;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.SearchCriteria;
@@ -242,7 +243,7 @@ public class SwiftManagerImpl implements SwiftManager {
         if (swift == null) {
             return null;
         }
-        
+
         List<VMTemplateHostVO> tmpltHosts = _vmTmpltHostDao.listByOnlyTemplateId(tmpltId);
         if (tmpltHosts != null) {
             Collections.shuffle(tmpltHosts);
@@ -260,13 +261,13 @@ public class SwiftManagerImpl implements SwiftManager {
     }
 
     @Override
-    public List<SwiftVO> listSwifts(ListSwiftsCmd cmd) {
+    public Pair<List<SwiftVO>, Integer> listSwifts(ListSwiftsCmd cmd) {
         Filter searchFilter = new Filter(SwiftVO.class, "id", Boolean.TRUE, cmd.getStartIndex(),
cmd.getPageSizeVal());
         SearchCriteria<SwiftVO> sc = _swiftDao.createSearchCriteria();
         if (cmd.getId() != null) {
             sc.addAnd("id", SearchCriteria.Op.EQ, cmd.getId());
         }
-        return _swiftDao.search(sc, searchFilter);
+        return _swiftDao.searchAndCount(sc, searchFilter);
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c3f1a9d3/server/test/com/cloud/resource/MockResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/resource/MockResourceManagerImpl.java b/server/test/com/cloud/resource/MockResourceManagerImpl.java
index e94cdea..a0dad47 100644
--- a/server/test/com/cloud/resource/MockResourceManagerImpl.java
+++ b/server/test/com/cloud/resource/MockResourceManagerImpl.java
@@ -202,7 +202,7 @@ public class MockResourceManagerImpl implements ResourceManager, Manager
{
      * @see com.cloud.resource.ResourceService#listSwifts(com.cloud.api.commands.ListSwiftsCmd)
      */
     @Override
-    public List<? extends Swift> listSwifts(ListSwiftsCmd cmd) {
+    public Pair<List<? extends Swift>, Integer> listSwifts(ListSwiftsCmd cmd)
{
         // TODO Auto-generated method stub
         return null;
     }


Mime
View raw message