@Test public void testGetHosts() { System.out.println("getHosts"); DefaultDatabaseConnector instance = new DefaultDatabaseConnector(); Collection<Host> result = instance.getHosts(); assert (result != null); assert (!result.isEmpty()); }
@Override public Collection<Host> getHosts() { Collection<Host> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT host_id , host_name FROM host"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> hostData : results) { Host host = new Host((Integer) hostData.get(0), (String) hostData.get(1)); host = getHostCalibrationData(host); answer.add(host); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } return answer; }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public Collection<Host> getHosts() { Collection<Host> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT host_id , host_name FROM host"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> hostData : results) { Host host = new Host((Integer) hostData.get(0), (String) hostData.get(1)); host = getHostCalibrationData(host); answer.add(host); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } return answer; } }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public Collection<Host> getHosts() { Collection<Host> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT host_id , host_name FROM host"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> hostData : results) { Host host = new Host((Integer) hostData.get(0), (String) hostData.get(1)); host = getHostCalibrationData(host); answer.add(host); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } return answer; } DefaultDatabaseConnector(); }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public Collection<Host> getHosts() { Collection<Host> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT host_id , host_name FROM host"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> hostData : results) { Host host = new Host((Integer) hostData.get(0), (String) hostData.get(1)); host = getHostCalibrationData(host); answer.add(host); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } return answer; } 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 Collection<Host> getHosts() { Collection<Host> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT host_id , host_name FROM host"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> hostData : results) { Host host = new Host((Integer) hostData.get(0), (String) hostData.get(1)); host = getHostCalibrationData(host); answer.add(host); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } return answer; } 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();  }