Search in sources :

Example 61 with TransactionLegacy

use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.

the class NetworkDaoImpl method update.

@Override
@DB
public boolean update(final Long networkId, final NetworkVO network, final Map<String, String> serviceProviderMap) {
    final TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    super.update(networkId, network);
    if (serviceProviderMap != null) {
        _ntwkSvcMap.deleteByNetworkId(networkId);
        persistNetworkServiceProviders(networkId, serviceProviderMap);
    }
    txn.commit();
    return true;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) DB(com.cloud.utils.db.DB)

Example 62 with TransactionLegacy

use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.

the class NetworkACLItemDaoImpl method persist.

@Override
@DB
public NetworkACLItemVO persist(NetworkACLItemVO networkAclItem) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    NetworkACLItemVO dbNetworkACLItem = super.persist(networkAclItem);
    saveCidrs(networkAclItem, networkAclItem.getSourceCidrList());
    loadCidrs(dbNetworkACLItem);
    txn.commit();
    return dbNetworkACLItem;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) NetworkACLItemVO(com.cloud.network.vpc.NetworkACLItemVO) DB(com.cloud.utils.db.DB)

Example 63 with TransactionLegacy

use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.

the class PrivateIpDaoImpl method allocateIpAddress.

@Override
public PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp) {
    SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
    sc.setParameters("networkId", networkId);
    sc.setParameters("taken", (Date) null);
    if (requestedIp != null) {
        sc.setParameters("ipAddress", requestedIp);
    }
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    PrivateIpVO vo = lockOneRandomRow(sc, true);
    if (vo == null) {
        txn.rollback();
        return null;
    }
    vo.setTakenAt(new Date());
    update(vo.getId(), vo);
    txn.commit();
    return vo;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) PrivateIpVO(com.cloud.network.vpc.PrivateIpVO) Date(java.util.Date)

Example 64 with TransactionLegacy

use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.

the class StaticRouteDaoImpl method remove.

@Override
@DB
public boolean remove(Long id) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    StaticRouteVO entry = findById(id);
    if (entry != null) {
        _tagsDao.removeByIdAndType(id, ResourceObjectType.StaticRoute);
    }
    boolean result = super.remove(id);
    txn.commit();
    return result;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) StaticRouteVO(com.cloud.network.vpc.StaticRouteVO) DB(com.cloud.utils.db.DB)

Example 65 with TransactionLegacy

use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.

the class VpcDaoImpl method remove.

@Override
@DB
public boolean remove(Long id) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    VpcVO entry = findById(id);
    if (entry != null) {
        _tagsDao.removeByIdAndType(id, ResourceObjectType.Vpc);
    }
    boolean result = super.remove(id);
    txn.commit();
    return result;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) VpcVO(com.cloud.network.vpc.VpcVO) DB(com.cloud.utils.db.DB)

Aggregations

TransactionLegacy (com.cloud.utils.db.TransactionLegacy)368 PreparedStatement (java.sql.PreparedStatement)174 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)149 SQLException (java.sql.SQLException)133 ResultSet (java.sql.ResultSet)102 ArrayList (java.util.ArrayList)98 DB (com.cloud.utils.db.DB)95 ConfigurationException (javax.naming.ConfigurationException)54 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)35 Date (java.util.Date)34 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)31 HashMap (java.util.HashMap)29 URISyntaxException (java.net.URISyntaxException)28 AccountVO (com.cloud.user.AccountVO)21 CloudException (com.cloud.exception.CloudException)20 Account (com.cloud.user.Account)20 Field (java.lang.reflect.Field)19 MockVolumeVO (com.cloud.simulator.MockVolumeVO)18 AgentManager (com.cloud.agent.AgentManager)13 IPAddressDao (com.cloud.network.dao.IPAddressDao)13