@Override public void removeBy(long accountId, long volId) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); try(PreparedStatement pstmt = txn.prepareStatement(REMOVE_BY_USERID_VOLID);) { if (pstmt != null) { pstmt.setLong(1, accountId); pstmt.setLong(2, volId); pstmt.executeUpdate(); } }catch (SQLException e) { throw new CloudException("Error removing usageVolumeVO:"+e.getMessage(), e); } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.warn("Error removing usageVolumeVO:"+e.getMessage(), e); } finally { txn.close(); } }
@Override public void removeBy(long accountId, long volId, int storageType) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); String sql = REMOVE_BY_USERID_STORAGEID; try( PreparedStatement pstmt = txn.prepareStatement(sql);) { pstmt.setLong(1, accountId); pstmt.setLong(2, volId); pstmt.setInt(3, storageType); pstmt.executeUpdate(); }catch(SQLException e) { throw new CloudException("removeBy:Exception:"+e.getMessage(),e); } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.error("Error removing usageStorageVO", e); } finally { txn.close(); } }
throw new CloudException("getUsageRecords:"+e.getMessage(),e);
throw new CloudException("Error getting usage records"+e.getMessage(), e);
@Override public void update(UsagePortForwardingRuleVO usage) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); if (usage.getDeleted() != null) { try(PreparedStatement pstmt = txn.prepareStatement(UPDATE_DELETED);) { if (pstmt != null) { pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted())); pstmt.setLong(2, usage.getAccountId()); pstmt.setLong(3, usage.getId()); pstmt.executeUpdate(); } }catch (SQLException e) { throw new CloudException("Error updating UsagePortForwardingRuleVO:"+e.getMessage(), e); } } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.warn("Error updating UsagePortForwardingRuleVO:"+e.getMessage(), e); } finally { txn.close(); } }
@Override public void update(UsageNetworkOfferingVO usage) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); if (usage.getDeleted() != null) { try(PreparedStatement pstmt = txn.prepareStatement(UPDATE_DELETED);) { if (pstmt != null) { pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted())); pstmt.setLong(2, usage.getAccountId()); pstmt.setLong(3, usage.getVmInstanceId()); pstmt.setLong(4, usage.getNetworkOfferingId()); pstmt.executeUpdate(); } }catch (SQLException e) { throw new CloudException("Error updating UsageNetworkOfferingVO:"+e.getMessage(), e); } } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.warn("Error updating UsageNetworkOfferingVO:"+e.getMessage(), e); } finally { txn.close(); } }
@Override public void update(UsageIPAddressVO usage) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); if (usage.getReleased() != null) { try(PreparedStatement pstmt = txn.prepareStatement(UPDATE_RELEASED);) { if (pstmt != null) { pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getReleased())); pstmt.setLong(2, usage.getAccountId()); pstmt.setString(3, usage.getAddress()); pstmt.executeUpdate(); } }catch(SQLException e) { throw new CloudException("update:Exception:"+e.getMessage(), e); } } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.error("Error updating usageIPAddressVO:"+e.getMessage(), e); } finally { txn.close(); } }
@Override public void update(UsageVPNUserVO usage) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); if (usage.getDeleted() != null) { try(PreparedStatement pstmt = txn.prepareStatement(UPDATE_DELETED);) { if (pstmt != null) { pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted())); pstmt.setLong(2, usage.getAccountId()); pstmt.setLong(3, usage.getUserId()); pstmt.executeUpdate(); } }catch (SQLException e) { throw new CloudException("Error updating UsageVPNUserVO"+e.getMessage(), e); } } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.error("Error updating UsageVPNUserVO:"+e.getMessage(), e); } finally { txn.close(); } }
@Override public void update(UsageLoadBalancerPolicyVO usage) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); if (usage.getDeleted() != null) { try(PreparedStatement pstmt = txn.prepareStatement(UPDATE_DELETED);) { if (pstmt != null) { pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted())); pstmt.setLong(2, usage.getAccountId()); pstmt.setLong(3, usage.getId()); pstmt.executeUpdate(); } }catch (SQLException e) { throw new CloudException("Error updating UsageLoadBalancerPolicyVO:" + e.getMessage(), e); } } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.warn("Error updating UsageLoadBalancerPolicyVO"+e.getMessage(), e); } finally { txn.close(); } }
@Override public void update(UsageSecurityGroupVO usage) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); if (usage.getDeleted() != null) { try(PreparedStatement pstmt = txn.prepareStatement(UPDATE_DELETED);) { if (pstmt != null) { pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted())); pstmt.setLong(2, usage.getAccountId()); pstmt.setLong(3, usage.getVmInstanceId()); pstmt.setLong(4, usage.getSecurityGroupId()); pstmt.executeUpdate(); } }catch (SQLException e) { throw new CloudException("Error updating UsageSecurityGroupVO:"+e.getMessage(), e); } } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.warn("Error updating UsageSecurityGroupVO:"+e.getMessage(), e); } finally { txn.close(); } }
@Override public void update(UsageStorageVO usage) { TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { txn.start(); if (usage.getDeleted() != null) { try(PreparedStatement pstmt = txn.prepareStatement(UPDATE_DELETED);) { if (pstmt != null) { pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted())); pstmt.setLong(2, usage.getAccountId()); pstmt.setLong(3, usage.getId()); pstmt.setInt(4, usage.getStorageType()); pstmt.setLong(5, usage.getZoneId()); pstmt.executeUpdate(); } }catch (SQLException e) { throw new CloudException("UsageStorageVO update Error:"+e.getMessage(),e); } } txn.commit(); } catch (Exception e) { txn.rollback(); s_logger.error("Error updating UsageStorageVO:"+e.getMessage(), e); } finally { txn.close(); } }