cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: updated refs/heads/4.2 to 7202683
Date Mon, 19 Aug 2013 17:27:14 GMT
Updated Branches:
  refs/heads/4.2 f8899f2d1 -> 720268347


CLOUDSTACK-4403: vmInstanceDao - initialize the SearchBuilder in init() method instead of
the search dao method which wasn't thread safe, and could cause NPEs during search builder
initializing.


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

Branch: refs/heads/4.2
Commit: 7202683476b69ccf35baba3a5ab634c5532fb415
Parents: f8899f2
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Aug 19 10:18:16 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Aug 19 10:18:16 2013 -0700

----------------------------------------------------------------------
 .../src/com/cloud/vm/dao/VMInstanceDaoImpl.java | 28 +++++++++-----------
 1 file changed, 13 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/72026834/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
index bc3efbb..3a7dde7 100644
--- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
@@ -228,6 +228,19 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO,
Long> implem
 
         _updateTimeAttr = _allAttributes.get("updateTime");
         assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";
+        
+        SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
+        nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+
+        DistinctHostNameSearch = createSearchBuilder(String.class);
+        DistinctHostNameSearch.selectField(DistinctHostNameSearch.entity().getHostName());
+
+        DistinctHostNameSearch.and("types", DistinctHostNameSearch.entity().getType(), SearchCriteria.Op.IN);
+        DistinctHostNameSearch.and("removed", DistinctHostNameSearch.entity().getRemoved(),
SearchCriteria.Op.NULL);
+        DistinctHostNameSearch.join("nicSearch", nicSearch, DistinctHostNameSearch.entity().getId(),
+                nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
+        DistinctHostNameSearch.done();
+        
     }
 
     @Override
@@ -629,21 +642,6 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO,
Long> implem
 
     @Override
     public List<String> listDistinctHostNames(long networkId, VirtualMachine.Type...
types) {
-        if (DistinctHostNameSearch == null) {
-
-            SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
-            nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
-
-            DistinctHostNameSearch = createSearchBuilder(String.class);
-            DistinctHostNameSearch.selectField(DistinctHostNameSearch.entity().getHostName());
-
-            DistinctHostNameSearch.and("types", DistinctHostNameSearch.entity().getType(),
SearchCriteria.Op.IN);
-            DistinctHostNameSearch.and("removed", DistinctHostNameSearch.entity().getRemoved(),
SearchCriteria.Op.NULL);
-            DistinctHostNameSearch.join("nicSearch", nicSearch, DistinctHostNameSearch.entity().getId(),
-                    nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
-            DistinctHostNameSearch.done();
-        }
-
         SearchCriteria<String> sc = DistinctHostNameSearch.create();
         if (types != null && types.length != 0) {
             sc.setParameters("types", (Object[]) types);


Mime
View raw message