@Test public void testSetHosts() { System.out.println("setHosts"); Collection<Host> hosts = hostList; DefaultDatabaseConnector instance = new DefaultDatabaseConnector(); instance.setHosts(hosts); }
@Override public void setHosts(Collection<Host> hosts) { connection = getConnection(connection); if (connection == null || hosts == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host (host_id, host_name) VALUES (?,?) ON DUPLICATE KEY UPDATE host_name=VALUES(`host_name`);")) { for (Host host : hosts) { preparedStatement.setInt(1, host.getId()); preparedStatement.setString(2, host.getHostName()); preparedStatement.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public void setHosts(Collection<Host> hosts) { connection = getConnection(connection); if (connection == null || hosts == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host (host_id, host_name) VALUES (?,?) ON DUPLICATE KEY UPDATE host_name=VALUES(`host_name`);")) { for (Host host : hosts) { preparedStatement.setInt(1, host.getId()); preparedStatement.setString(2, host.getHostName()); preparedStatement.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } } }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public void setHosts(Collection<Host> hosts) { connection = getConnection(connection); if (connection == null || hosts == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host (host_id, host_name) VALUES (?,?) ON DUPLICATE KEY UPDATE host_name=VALUES(`host_name`);")) { for (Host host : hosts) { preparedStatement.setInt(1, host.getId()); preparedStatement.setString(2, host.getHostName()); preparedStatement.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } } DefaultDatabaseConnector(); }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public void setHosts(Collection<Host> hosts) { connection = getConnection(connection); if (connection == null || hosts == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host (host_id, host_name) VALUES (?,?) ON DUPLICATE KEY UPDATE host_name=VALUES(`host_name`);")) { for (Host host : hosts) { preparedStatement.setInt(1, host.getId()); preparedStatement.setString(2, host.getHostName()); 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 setHosts(Collection<Host> hosts) { connection = getConnection(connection); if (connection == null || hosts == null) { return; } try (PreparedStatement preparedStatement = connection.prepareStatement( "INSERT INTO host (host_id, host_name) VALUES (?,?) ON DUPLICATE KEY UPDATE host_name=VALUES(`host_name`);")) { for (Host host : hosts) { preparedStatement.setInt(1, host.getId()); preparedStatement.setString(2, host.getHostName()); 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();  }