@Test public void testSetHostCalibrationData() { System.out.println("setHostCalibrationData"); Host host = CHOSEN_HOST; DefaultDatabaseConnector instance = new DefaultDatabaseConnector(); instance.setHostCalibrationData(host); assert (host.getCalibrationData().isEmpty()); }
@Override public void setHostCalibrationData(Host host) { connection = getConnection(connection); if (connection == null || host == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host_calibration_data (host_id, cpu, memory, energy) VALUES (?, ?, ? , ?) " + " ON DUPLICATE KEY UPDATE host_id=VALUES(`host_id`), cpu=VALUES(`cpu`), memory=VALUES(`memory`), energy=VALUES(`energy`);")) { preparedStatement.setInt(1, host.getId()); for (HostEnergyCalibrationData data : host.getCalibrationData()) { preparedStatement.setInt(1, host.getId()); preparedStatement.setDouble(2, data.getCpuUsage()); preparedStatement.setDouble(3, data.getMemoryUsage()); preparedStatement.setDouble(4, data.getWattsUsed()); preparedStatement.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public void setHostCalibrationData(Host host) { connection = getConnection(connection); if (connection == null || host == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host_calibration_data (host_id, cpu, memory, energy) VALUES (?, ?, ? , ?) " + " ON DUPLICATE KEY UPDATE host_id=VALUES(`host_id`), cpu=VALUES(`cpu`), memory=VALUES(`memory`), energy=VALUES(`energy`);")) { preparedStatement.setInt(1, host.getId()); for (HostEnergyCalibrationData data : host.getCalibrationData()) { preparedStatement.setInt(1, host.getId()); preparedStatement.setDouble(2, data.getCpuUsage()); preparedStatement.setDouble(3, data.getMemoryUsage()); preparedStatement.setDouble(4, data.getWattsUsed()); preparedStatement.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } } }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public void setHostCalibrationData(Host host) { connection = getConnection(connection); if (connection == null || host == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host_calibration_data (host_id, cpu, memory, energy) VALUES (?, ?, ? , ?) " + " ON DUPLICATE KEY UPDATE host_id=VALUES(`host_id`), cpu=VALUES(`cpu`), memory=VALUES(`memory`), energy=VALUES(`energy`);")) { preparedStatement.setInt(1, host.getId()); for (HostEnergyCalibrationData data : host.getCalibrationData()) { preparedStatement.setInt(1, host.getId()); preparedStatement.setDouble(2, data.getCpuUsage()); preparedStatement.setDouble(3, data.getMemoryUsage()); preparedStatement.setDouble(4, data.getWattsUsed()); preparedStatement.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } } DefaultDatabaseConnector(); }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public void setHostCalibrationData(Host host) { connection = getConnection(connection); if (connection == null || host == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host_calibration_data (host_id, cpu, memory, energy) VALUES (?, ?, ? , ?) " + " ON DUPLICATE KEY UPDATE host_id=VALUES(`host_id`), cpu=VALUES(`cpu`), memory=VALUES(`memory`), energy=VALUES(`energy`);")) { preparedStatement.setInt(1, host.getId()); for (HostEnergyCalibrationData data : host.getCalibrationData()) { preparedStatement.setInt(1, host.getId()); preparedStatement.setDouble(2, data.getCpuUsage()); preparedStatement.setDouble(3, data.getMemoryUsage()); preparedStatement.setDouble(4, data.getWattsUsed()); preparedStatement.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } } DefaultDatabaseConnector(); @Override Collection<Host> getHosts(); @Override Collection<VmDeployed> getVms(); @Override Collection<Host> getHostCalibrationData(Collection<Host> hosts); @Override Host getHostCalibrationData(Host host); @Override Host getHostProfileData(Host host); @Override void setHosts(Collection<Host> hosts); @Override void setVms(Collection<VmDeployed> vms); @Override VmDeployed getVMProfileData(VmDeployed vm); @Override Collection<VmDeployed> getVMProfileData(Collection<VmDeployed> vms); @Override void setVMProfileData(VmDeployed vm); @Override void setHostCalibrationData(Host host); @Override void setHostProfileData(Host host); @Override void writeHostHistoricData(Host host, long time, double power, double energy); @Override List<HostEnergyRecord> getHostHistoryData(Host host, TimePeriod timePeriod); @Override void writeHostVMHistoricData(Host host, long time, HostVmLoadFraction load); @Override Collection<HostVmLoadFraction> getHostVmHistoryLoadData(Host host, TimePeriod timePeriod); @Override VmLoadHistoryRecord getAverageCPUUtilisationTag(String tagName); @Override VmLoadHistoryRecord getAverageCPUUtilisationDisk(String diskRefStr); @Override List<VmLoadHistoryWeekRecord> getAverageCPUUtilisationWeekTraceForTag(String tagName); @Override List<VmLoadHistoryWeekRecord> getAverageCPUUtilisationWeekTraceForDisk(String diskRef); @Override double getVMCurrentBootTraceIndex(VmDeployed vm, int windowSize); @Override List<VmLoadHistoryBootRecord> getAverageCPUUtilisationBootTraceForTag(String tagName, int windowSize); @Override List<VmLoadHistoryBootRecord> getAverageCPUUtilisationBootTraceForDisk(String diskName, int windowSize); @Override void closeConnection(); }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public void setHostCalibrationData(Host host) { connection = getConnection(connection); if (connection == null || host == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host_calibration_data (host_id, cpu, memory, energy) VALUES (?, ?, ? , ?) " + " ON DUPLICATE KEY UPDATE host_id=VALUES(`host_id`), cpu=VALUES(`cpu`), memory=VALUES(`memory`), energy=VALUES(`energy`);")) { preparedStatement.setInt(1, host.getId()); for (HostEnergyCalibrationData data : host.getCalibrationData()) { preparedStatement.setInt(1, host.getId()); preparedStatement.setDouble(2, data.getCpuUsage()); preparedStatement.setDouble(3, data.getMemoryUsage()); preparedStatement.setDouble(4, data.getWattsUsed()); preparedStatement.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } } DefaultDatabaseConnector(); @Override Collection<Host> getHosts(); @Override Collection<VmDeployed> getVms(); @Override Collection<Host> getHostCalibrationData(Collection<Host> hosts); @Override Host getHostCalibrationData(Host host); @Override Host getHostProfileData(Host host); @Override void setHosts(Collection<Host> hosts); @Override void setVms(Collection<VmDeployed> vms); @Override VmDeployed getVMProfileData(VmDeployed vm); @Override Collection<VmDeployed> getVMProfileData(Collection<VmDeployed> vms); @Override void setVMProfileData(VmDeployed vm); @Override void setHostCalibrationData(Host host); @Override void setHostProfileData(Host host); @Override void writeHostHistoricData(Host host, long time, double power, double energy); @Override List<HostEnergyRecord> getHostHistoryData(Host host, TimePeriod timePeriod); @Override void writeHostVMHistoricData(Host host, long time, HostVmLoadFraction load); @Override Collection<HostVmLoadFraction> getHostVmHistoryLoadData(Host host, TimePeriod timePeriod); @Override VmLoadHistoryRecord getAverageCPUUtilisationTag(String tagName); @Override VmLoadHistoryRecord getAverageCPUUtilisationDisk(String diskRefStr); @Override List<VmLoadHistoryWeekRecord> getAverageCPUUtilisationWeekTraceForTag(String tagName); @Override List<VmLoadHistoryWeekRecord> getAverageCPUUtilisationWeekTraceForDisk(String diskRef); @Override double getVMCurrentBootTraceIndex(VmDeployed vm, int windowSize); @Override List<VmLoadHistoryBootRecord> getAverageCPUUtilisationBootTraceForTag(String tagName, int windowSize); @Override List<VmLoadHistoryBootRecord> getAverageCPUUtilisationBootTraceForDisk(String diskName, int windowSize); @Override void closeConnection();  }