mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
CLOUDSTACK-7639: make cidr updation more efficient
check and update only when required Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> (cherry picked from commit b879916f5c64ddbca8713852b2c0ac187e9be1ff) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
e1cbe6d18a
commit
9b669f0648
@ -31,6 +31,8 @@ public interface NetworkACLItemCidrsDao extends GenericDao<NetworkACLItemCidrsVO
|
||||
|
||||
void persist(long networkACLItemId, List<String> cidrs);
|
||||
|
||||
void updateCidrs(long networkACLItemId, List<String> cidrs);
|
||||
|
||||
List<String> getCidrs(long networkACLItemId);
|
||||
|
||||
@DB
|
||||
|
||||
@ -64,6 +64,17 @@ public class NetworkACLItemCidrsDaoImpl extends GenericDaoBase<NetworkACLItemCid
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCidrs(long networkACLItemId, List<String> cidrs) {
|
||||
List<String> oldCidrs = getCidrs(networkACLItemId);
|
||||
if (!(oldCidrs.size() == cidrs.size() && oldCidrs.equals(cidrs))) {
|
||||
SearchCriteria<NetworkACLItemCidrsVO> sc = cidrsSearch.create();
|
||||
sc.setParameters("networkAclItemId", networkACLItemId);
|
||||
remove(sc);
|
||||
persist(networkACLItemId, cidrs);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.dao.NetworkAclItemCidrsDao#getCidrs(long)
|
||||
*/
|
||||
|
||||
@ -93,7 +93,7 @@ public class NetworkACLItemDaoImpl extends GenericDaoBase<NetworkACLItemVO, Long
|
||||
@Override
|
||||
public boolean update(Long id, NetworkACLItemVO item) {
|
||||
boolean result = super.update(id, item);
|
||||
saveCidrs(item, item.getSourceCidrList());
|
||||
_networkACLItemCidrsDao.updateCidrs(item.getId(), item.getSourceCidrList());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user