Search in sources :

Example 1 with UsageEventDetailsVO

use of com.cloud.event.UsageEventDetailsVO in project cloudstack by apache.

the class UsageEventDetailsDaoImpl method persist.

@Override
public void persist(long eventId, Map<String, String> details) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    SearchCriteria<UsageEventDetailsVO> sc = EventDetailsSearch.create();
    sc.setParameters("eventId", eventId);
    expunge(sc);
    for (Map.Entry<String, String> detail : details.entrySet()) {
        UsageEventDetailsVO vo = new UsageEventDetailsVO(eventId, detail.getKey(), detail.getValue());
        persist(vo);
    }
    txn.commit();
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) UsageEventDetailsVO(com.cloud.event.UsageEventDetailsVO) Map(java.util.Map)

Example 2 with UsageEventDetailsVO

use of com.cloud.event.UsageEventDetailsVO in project cloudstack by apache.

the class UsageEventDetailsDaoImpl method deleteDetails.

@Override
public void deleteDetails(long eventId) {
    SearchCriteria<UsageEventDetailsVO> sc = EventDetailsSearch.create();
    sc.setParameters("eventId", eventId);
    List<UsageEventDetailsVO> results = search(sc, null);
    for (UsageEventDetailsVO result : results) {
        remove(result.getId());
    }
}
Also used : UsageEventDetailsVO(com.cloud.event.UsageEventDetailsVO)

Example 3 with UsageEventDetailsVO

use of com.cloud.event.UsageEventDetailsVO in project cloudstack by apache.

the class UsageManagerImpl method populateDynamicComputeOfferingDetailsAndPersist.

private void populateDynamicComputeOfferingDetailsAndPersist(UsageVMInstanceVO usageInstance, Long eventId) {
    //populate the cpu, memory and cpuSpeed of the vm when created from a dynamic offering.
    UsageEventDetailsVO cpuNumber = _usageEventDetailsDao.findDetail(eventId, UsageEventVO.DynamicParameters.cpuNumber.name());
    if (cpuNumber != null) {
        usageInstance.setCpuCores(Long.parseLong(cpuNumber.getValue()));
    } else {
        usageInstance.setCpuCores(null);
    }
    UsageEventDetailsVO cpuSpeed = _usageEventDetailsDao.findDetail(eventId, UsageEventVO.DynamicParameters.cpuSpeed.name());
    if (cpuSpeed != null) {
        usageInstance.setCpuSpeed(Long.parseLong(cpuSpeed.getValue()));
    } else {
        usageInstance.setCpuSpeed(null);
    }
    UsageEventDetailsVO memory = _usageEventDetailsDao.findDetail(eventId, UsageEventVO.DynamicParameters.memory.name());
    if (memory != null) {
        usageInstance.setMemory(Long.parseLong(memory.getValue()));
    } else {
        usageInstance.setMemory(null);
    }
    _usageInstanceDao.persist(usageInstance);
}
Also used : UsageEventDetailsVO(com.cloud.event.UsageEventDetailsVO)

Aggregations

UsageEventDetailsVO (com.cloud.event.UsageEventDetailsVO)3 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1 Map (java.util.Map)1