bug 9550: get storagePool to Host mappings before doing processDisconnect because these references are being deleted as a part of processDisconnect call.

status 9550: resolved fixed

Conflicts:

	server/src/com/cloud/agent/manager/AgentManagerImpl.java
	server/src/com/cloud/storage/StorageManagerImpl.java
This commit is contained in:
alena 2011-04-23 20:43:24 -07:00
parent c157d3375c
commit b749c64d4e
4 changed files with 206 additions and 287 deletions

View File

@ -138,11 +138,11 @@ import com.cloud.org.Grouping;
import com.cloud.resource.Discoverer;
import com.cloud.resource.ResourceService;
import com.cloud.resource.ServerResource;
import com.cloud.server.ManagementServer;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.Storage;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateVO;
@ -772,7 +772,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
bareMetalParams.put("hostTag", hostTags.get(0));
}
}
String allocationState = cmd.getAllocationState();
if (allocationState == null) {
allocationState = Host.HostAllocationState.Enabled.toString();
@ -1079,6 +1078,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
}
AgentAttache attache = findAttache(hostId);
// Get storage pool host mappings here because they can be removed as a part of handleDisconnect later
List<StoragePoolHostVO> pools = _storagePoolHostDao.listByHostId(hostId);
try {
@ -1164,7 +1165,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
txn.start();
_dcDao.releasePrivateIpAddress(host.getPrivateIpAddress(), host.getDataCenterId(), null);
if (attache != null) {
handleDisconnect(attache, Status.Event.Remove, false);
}
@ -1186,27 +1186,19 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
}
}
// delete the associated primary storage from db
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
_storagePoolHostDao = locator.getDao(StoragePoolHostDao.class);
if (_storagePoolHostDao == null) {
throw new ConfigurationException("Unable to get storage pool host dao: " + StoragePoolHostDao.class);
}
// 1. Get the pool_ids from the host ref table
ArrayList<Long> pool_ids = _storagePoolHostDao.getPoolIds(hostId);
// 2.Delete the associated entries in host ref table
// Delete the associated entries in host ref table
_storagePoolHostDao.deletePrimaryRecordsForHost(hostId);
// 3.For pool ids you got, delete entries in pool table where
// type='FileSystem' || 'LVM'
for (Long poolId : pool_ids) {
// For pool ids you got, delete local storage host entries in pool table where
for (StoragePoolHostVO pool : pools) {
Long poolId = pool.getPoolId();
StoragePoolVO storagePool = _storagePoolDao.findById(poolId);
if (storagePool.isLocal()) {
storagePool.setUuid(null);
storagePool.setClusterId(null);
_storagePoolDao.update(poolId, storagePool);
_storagePoolDao.remove(poolId);
s_logger.debug("Local storage id=" + poolId + " is removed as a part of host removal id=" + hostId);
}
}
@ -1216,7 +1208,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
hostCapacitySC.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, hostId);
hostCapacitySC.addAnd("capacityType", SearchCriteria.Op.IN, capacityTypes);
_capacityDao.remove(hostCapacitySC);
txn.commit();
return true;
} catch (Throwable t) {
@ -2723,7 +2714,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
if (capacityVOCpus != null && !capacityVOCpus.isEmpty()) {
CapacityVO CapacityVOCpu = capacityVOCpus.get(0);
long newTotalCpu = (long) (server.getCpus().longValue() * server.getSpeed().longValue());
long newTotalCpu = (server.getCpus().longValue() * server.getSpeed().longValue());
if ((CapacityVOCpu.getTotalCapacity() <= newTotalCpu) || ((CapacityVOCpu.getUsedCapacity() + CapacityVOCpu.getReservedCapacity()) <= newTotalCpu)) {
CapacityVOCpu.setTotalCapacity(newTotalCpu);
} else if ((CapacityVOCpu.getUsedCapacity() + CapacityVOCpu.getReservedCapacity() > newTotalCpu) && (CapacityVOCpu.getUsedCapacity() < newTotalCpu)) {
@ -2735,8 +2726,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
}
_capacityDao.update(CapacityVOCpu.getId(), CapacityVOCpu);
} else {
CapacityVO capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), server.getClusterId(), 0L, (long) (server.getCpus().longValue()
* server.getSpeed().longValue()), CapacityVO.CAPACITY_TYPE_CPU);
CapacityVO capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), server.getClusterId(), 0L, (server.getCpus().longValue() * server.getSpeed()
.longValue()), CapacityVO.CAPACITY_TYPE_CPU);
_capacityDao.persist(capacity);
}

View File

@ -650,7 +650,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
final HashSet<StoragePool> avoidPools = new HashSet<StoragePool>(avoids);
if (diskOffering != null && diskOffering.isCustomized()) {
diskOffering.setDiskSize(size/(1024*1024));
diskOffering.setDiskSize(size / (1024 * 1024));
}
DiskProfile dskCh = null;
if (volume.getVolumeType() == Type.ROOT && Storage.ImageFormat.ISO != template.getFormat()) {
@ -1318,7 +1318,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
@DB
private boolean deletePoolStats(Long poolId) {
CapacityVO capacity1 = _capacityDao.findByHostIdType(poolId, CapacityVO.CAPACITY_TYPE_STORAGE);
CapacityVO capacity2 = _capacityDao.findByHostIdType(poolId, CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED);
Transaction txn = Transaction.currentTxn();
@ -1359,7 +1358,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
}
@Override
public boolean delPoolFromHost(long hostId) {
List<StoragePoolHostVO> poolHosts = _poolHostDao.listByHostId(hostId);
@ -1369,7 +1367,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
return true;
}
@Override
public boolean addPoolToHost(long hostId, StoragePoolVO pool) {
s_logger.debug("Adding pool " + pool.getName() + " to host " + hostId);
@ -2498,13 +2496,13 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
@Override
public void prepare(VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException {
if(dest == null){
if (dest == null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("DeployDestination cannot be null, cannot prepare Volumes for the vm: "+ vm);
s_logger.debug("DeployDestination cannot be null, cannot prepare Volumes for the vm: " + vm);
}
throw new CloudRuntimeException("Unable to prepare Volume for vm because DeployDestination is null, vm:"+vm);
}
throw new CloudRuntimeException("Unable to prepare Volume for vm because DeployDestination is null, vm:" + vm);
}
List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Preparing " + vols.size() + " volumes for " + vm);
@ -2513,35 +2511,35 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
List<VolumeVO> recreateVols = new ArrayList<VolumeVO>(vols.size());
for (VolumeVO vol : vols) {
StoragePool assignedPool = null;
if(dest.getStorageForDisks() != null){
assignedPool = dest.getStorageForDisks().get(vol);
}
if(assignedPool != null){
Volume.State state = vol.getState();
if(state == Volume.State.Allocated){
recreateVols.add(vol);
}else{
if (vol.isRecreatable()) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Volume " + vol + " will be recreated on storage pool " + assignedPool + " assigned by deploymentPlanner");
}
recreateVols.add(vol);
}else{
if (s_logger.isDebugEnabled()) {
s_logger.debug("Volume " + vol + " is not recreatable! Cannot recreate on storagepool: "+assignedPool);
}
throw new StorageUnavailableException("Volume is not recreatable, Unable to create " + vol, Volume.class, vol.getId());
//copy volume usecase - not yet developed.
}
}
}else{
if(vol.getPoolId() == null){
throw new StorageUnavailableException("Volume has no pool associate and also no storage pool assigned in DeployDestination, Unable to create " + vol, Volume.class, vol.getId());
}
StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId());
vm.addDisk(new VolumeTO(vol, pool));
}
StoragePool assignedPool = null;
if (dest.getStorageForDisks() != null) {
assignedPool = dest.getStorageForDisks().get(vol);
}
if (assignedPool != null) {
Volume.State state = vol.getState();
if (state == Volume.State.Allocated) {
recreateVols.add(vol);
} else {
if (vol.isRecreatable()) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Volume " + vol + " will be recreated on storage pool " + assignedPool + " assigned by deploymentPlanner");
}
recreateVols.add(vol);
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Volume " + vol + " is not recreatable! Cannot recreate on storagepool: " + assignedPool);
}
throw new StorageUnavailableException("Volume is not recreatable, Unable to create " + vol, Volume.class, vol.getId());
// copy volume usecase - not yet developed.
}
}
} else {
if (vol.getPoolId() == null) {
throw new StorageUnavailableException("Volume has no pool associate and also no storage pool assigned in DeployDestination, Unable to create " + vol, Volume.class, vol.getId());
}
StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId());
vm.addDisk(new VolumeTO(vol, pool));
}
}
for (VolumeVO vol : recreateVols) {
@ -2809,9 +2807,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
@Override
public void onManagementNodeIsolated() {
}
public void onManagementNodeIsolated() {
}
@Override
public List<CapacityVO> getSecondaryStorageUsedStats(Long hostId, Long podId, Long zoneId) {
SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria();

View File

@ -16,31 +16,27 @@
*
*/
package com.cloud.storage.dao;
import java.util.ArrayList;
import java.util.List;
package com.cloud.storage.dao;
import java.util.List;
import com.cloud.host.Status;
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.utils.Pair;
import com.cloud.utils.db.GenericDao;
import com.cloud.utils.db.Transaction;
public interface StoragePoolHostDao extends GenericDao<StoragePoolHostVO, Long> {
public List<StoragePoolHostVO> listByPoolId(long id);
public List<StoragePoolHostVO> listByHostId(long hostId);
public StoragePoolHostVO findByPoolHost(long poolId, long hostId);
List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus);
List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boolean sharedOnly);
public ArrayList<Long> getPoolIds(Long hostId);
public void deletePrimaryRecordsForHost(long hostId);
public void deleteStoragePoolHostDetails(long hostId, long poolId);
}
public interface StoragePoolHostDao extends GenericDao<StoragePoolHostVO, Long> {
public List<StoragePoolHostVO> listByPoolId(long id);
public List<StoragePoolHostVO> listByHostId(long hostId);
public StoragePoolHostVO findByPoolHost(long poolId, long hostId);
List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus);
List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boolean sharedOnly);
public void deletePrimaryRecordsForHost(long hostId);
public void deleteStoragePoolHostDetails(long hostId, long poolId);
}

View File

@ -16,8 +16,8 @@
*
*/
package com.cloud.storage.dao;
package com.cloud.storage.dao;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -31,213 +31,147 @@ import org.apache.log4j.Logger;
import com.cloud.host.Status;
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.utils.Pair;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
@Local(value={StoragePoolHostDao.class})
public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Long> implements StoragePoolHostDao {
public static final Logger s_logger = Logger.getLogger(StoragePoolHostDaoImpl.class.getName());
protected final SearchBuilder<StoragePoolHostVO> PoolSearch;
protected final SearchBuilder<StoragePoolHostVO> HostSearch;
protected final SearchBuilder<StoragePoolHostVO> PoolHostSearch;
protected static final String HOST_FOR_POOL_SEARCH=
"SELECT * FROM storage_pool_host_ref ph, host h where ph.host_id = h.id and ph.pool_id=? and h.status=? ";
protected static final String STORAGE_POOL_HOST_INFO =
"SELECT p.data_center_id, count(ph.host_id) " +
" FROM storage_pool p, storage_pool_host_ref ph " +
" WHERE p.id = ph.pool_id AND p.data_center_id = ? " +
" GROUP by p.data_center_id";
protected static final String SHARED_STORAGE_POOL_HOST_INFO =
"SELECT p.data_center_id, count(ph.host_id) " +
" FROM storage_pool p, storage_pool_host_ref ph " +
" WHERE p.id = ph.pool_id AND p.data_center_id = ? " +
" AND p.pool_type NOT IN ('LVM', 'Filesystem')" +
" GROUP by p.data_center_id";
protected static final String GET_POOL_IDS =
"SELECT pool_id "+
"FROM storage_pool_host_ref "+
"WHERE host_id = ?";
protected static final String DELETE_PRIMARY_RECORDS =
"DELETE "+
"FROM storage_pool_host_ref "+
"WHERE host_id = ?";
public StoragePoolHostDaoImpl () {
PoolSearch = createSearchBuilder();
PoolSearch.and("pool_id", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
PoolSearch.done();
HostSearch = createSearchBuilder();
HostSearch.and("host_id", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
HostSearch.done();
PoolHostSearch = createSearchBuilder();
PoolHostSearch.and("pool_id", PoolHostSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
PoolHostSearch.and("host_id", PoolHostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
PoolHostSearch.done();
}
@Override
public List<StoragePoolHostVO> listByPoolId(long id) {
SearchCriteria<StoragePoolHostVO> sc = PoolSearch.create();
sc.setParameters("pool_id", id);
return listIncludingRemovedBy(sc);
}
@Override
public List<StoragePoolHostVO> listByHostId(long hostId) {
SearchCriteria<StoragePoolHostVO> sc = HostSearch.create();
sc.setParameters("host_id", hostId);
return listIncludingRemovedBy(sc);
}
@Override
public StoragePoolHostVO findByPoolHost(long poolId, long hostId) {
SearchCriteria<StoragePoolHostVO> sc = PoolHostSearch.create();
sc.setParameters("pool_id", poolId);
sc.setParameters("host_id", hostId);
return findOneIncludingRemovedBy(sc);
}
@Override
public List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus) {
Transaction txn = Transaction.currentTxn();
PreparedStatement pstmt = null;
List<StoragePoolHostVO> result = new ArrayList<StoragePoolHostVO>();
ResultSet rs = null;
try {
String sql = HOST_FOR_POOL_SEARCH;
pstmt = txn.prepareStatement(sql);
pstmt.setLong(1, poolId);
pstmt.setString(2, hostStatus.toString());
rs = pstmt.executeQuery();
while (rs.next()) {
// result.add(toEntityBean(rs, false)); TODO: this is buggy in GenericDaoBase for hand constructed queries
long id = rs.getLong(1); //ID column
result.add(findById(id));
}
} catch (Exception e) {
s_logger.warn("Exception: ", e);
} finally {
try {
if (rs != null) {
rs.close();
}
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException e) {
}
}
return result;
}
@Override
public List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boolean sharedOnly) {
ArrayList<Pair<Long, Integer>> l = new ArrayList<Pair<Long, Integer>>();
String sql = sharedOnly?SHARED_STORAGE_POOL_HOST_INFO:STORAGE_POOL_HOST_INFO;
Transaction txn = Transaction.currentTxn();;
PreparedStatement pstmt = null;
try {
pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.setLong(1, dcId);
ResultSet rs = pstmt.executeQuery();
while(rs.next()) {
l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
}
} catch (SQLException e) {
} catch (Throwable e) {
}
return l;
}
/**
* This method returns the pool_ids associated with the host
* @param hostId -- id for the host
* @return -- list of pool ids
*/
@DB
public ArrayList<Long> getPoolIds(Long hostId)
{
ArrayList<Long> poolIdsList = new ArrayList<Long>();
Transaction txn = Transaction.currentTxn();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String sql = GET_POOL_IDS;
pstmt = txn.prepareStatement(sql);
pstmt.setLong(1, hostId);
rs = pstmt.executeQuery();
while (rs.next())
{
poolIdsList.add(rs.getLong(1));
}
}
catch (Exception e)
{
s_logger.warn("Exception getting pool ids: ", e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
}
if (pstmt != null)
{
pstmt.close();
}
}
catch (SQLException e)
{
}
}
return poolIdsList;
}
@Local(value = { StoragePoolHostDao.class })
public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Long> implements StoragePoolHostDao {
public static final Logger s_logger = Logger.getLogger(StoragePoolHostDaoImpl.class.getName());
/**
* This method deletes the primary records from the host
* @param hostId -- id of the host
*/
public void deletePrimaryRecordsForHost(long hostId)
{
SearchCriteria<StoragePoolHostVO> sc = HostSearch.create();
sc.setParameters("host_id", hostId);
Transaction txn = Transaction.currentTxn();
txn.start();
remove(sc);
txn.commit();
}
protected final SearchBuilder<StoragePoolHostVO> PoolSearch;
protected final SearchBuilder<StoragePoolHostVO> HostSearch;
protected final SearchBuilder<StoragePoolHostVO> PoolHostSearch;
protected static final String HOST_FOR_POOL_SEARCH = "SELECT * FROM storage_pool_host_ref ph, host h where ph.host_id = h.id and ph.pool_id=? and h.status=? ";
protected static final String STORAGE_POOL_HOST_INFO = "SELECT p.data_center_id, count(ph.host_id) " + " FROM storage_pool p, storage_pool_host_ref ph "
+ " WHERE p.id = ph.pool_id AND p.data_center_id = ? " + " GROUP by p.data_center_id";
@Override
public void deleteStoragePoolHostDetails(long hostId, long poolId) {
SearchCriteria<StoragePoolHostVO> sc = PoolHostSearch.create();
sc.setParameters("host_id", hostId);
sc.setParameters("pool_id", poolId);
Transaction txn = Transaction.currentTxn();
txn.start();
remove(sc);
txn.commit();
}
}
protected static final String SHARED_STORAGE_POOL_HOST_INFO = "SELECT p.data_center_id, count(ph.host_id) " + " FROM storage_pool p, storage_pool_host_ref ph "
+ " WHERE p.id = ph.pool_id AND p.data_center_id = ? " + " AND p.pool_type NOT IN ('LVM', 'Filesystem')" + " GROUP by p.data_center_id";
protected static final String DELETE_PRIMARY_RECORDS = "DELETE " + "FROM storage_pool_host_ref " + "WHERE host_id = ?";
public StoragePoolHostDaoImpl() {
PoolSearch = createSearchBuilder();
PoolSearch.and("pool_id", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
PoolSearch.done();
HostSearch = createSearchBuilder();
HostSearch.and("host_id", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
HostSearch.done();
PoolHostSearch = createSearchBuilder();
PoolHostSearch.and("pool_id", PoolHostSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
PoolHostSearch.and("host_id", PoolHostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
PoolHostSearch.done();
}
@Override
public List<StoragePoolHostVO> listByPoolId(long id) {
SearchCriteria<StoragePoolHostVO> sc = PoolSearch.create();
sc.setParameters("pool_id", id);
return listIncludingRemovedBy(sc);
}
@Override
public List<StoragePoolHostVO> listByHostId(long hostId) {
SearchCriteria<StoragePoolHostVO> sc = HostSearch.create();
sc.setParameters("host_id", hostId);
return listIncludingRemovedBy(sc);
}
@Override
public StoragePoolHostVO findByPoolHost(long poolId, long hostId) {
SearchCriteria<StoragePoolHostVO> sc = PoolHostSearch.create();
sc.setParameters("pool_id", poolId);
sc.setParameters("host_id", hostId);
return findOneIncludingRemovedBy(sc);
}
@Override
public List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus) {
Transaction txn = Transaction.currentTxn();
PreparedStatement pstmt = null;
List<StoragePoolHostVO> result = new ArrayList<StoragePoolHostVO>();
ResultSet rs = null;
try {
String sql = HOST_FOR_POOL_SEARCH;
pstmt = txn.prepareStatement(sql);
pstmt.setLong(1, poolId);
pstmt.setString(2, hostStatus.toString());
rs = pstmt.executeQuery();
while (rs.next()) {
// result.add(toEntityBean(rs, false)); TODO: this is buggy in GenericDaoBase for hand constructed queries
long id = rs.getLong(1); // ID column
result.add(findById(id));
}
} catch (Exception e) {
s_logger.warn("Exception: ", e);
} finally {
try {
if (rs != null) {
rs.close();
}
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException e) {
}
}
return result;
}
@Override
public List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boolean sharedOnly) {
ArrayList<Pair<Long, Integer>> l = new ArrayList<Pair<Long, Integer>>();
String sql = sharedOnly ? SHARED_STORAGE_POOL_HOST_INFO : STORAGE_POOL_HOST_INFO;
Transaction txn = Transaction.currentTxn();
;
PreparedStatement pstmt = null;
try {
pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.setLong(1, dcId);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
}
} catch (SQLException e) {
} catch (Throwable e) {
}
return l;
}
/**
* This method deletes the primary records from the host
*
* @param hostId
* -- id of the host
*/
@Override
public void deletePrimaryRecordsForHost(long hostId) {
SearchCriteria<StoragePoolHostVO> sc = HostSearch.create();
sc.setParameters("host_id", hostId);
Transaction txn = Transaction.currentTxn();
txn.start();
remove(sc);
txn.commit();
}
@Override
public void deleteStoragePoolHostDetails(long hostId, long poolId) {
SearchCriteria<StoragePoolHostVO> sc = PoolHostSearch.create();
sc.setParameters("host_id", hostId);
sc.setParameters("pool_id", poolId);
Transaction txn = Transaction.currentTxn();
txn.start();
remove(sc);
txn.commit();
}
}