@Test public void testGetVms() { System.out.println("getVms"); DefaultDatabaseConnector instance = new DefaultDatabaseConnector(); Collection<VmDeployed> result = instance.getVms(); assert (!result.isEmpty()); System.out.println("VM Records Found: " + result.size()); for (VmDeployed vmDeployed : result) { assert (vmDeployed.getName() != null); assert (vmDeployed.getId() > 0); System.out.println("VM Name: " + vmDeployed.getName()); System.out.println("VM Id: " + vmDeployed.getId()); System.out.println("VM Deployment ID: " + vmDeployed.getDeploymentID()); System.out.println("Created: " + vmDeployed.getCreated()); System.out.println("CPU Count: " + vmDeployed.getCpus()); System.out.println("Disks GB: " + vmDeployed.getDiskGb()); System.out.println("Memory Mb: " + vmDeployed.getRamMb()); System.out.println("State: " + vmDeployed.getState()); if (vmDeployed.getAllocatedTo() != null) { System.out.println("Allocated To: " + vmDeployed.getAllocatedTo().getHostName()); } else { System.out.println("Allocated To: UNKNOWN!!"); } } }
@Override public Collection<VmDeployed> getVms() { Collection<VmDeployed> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT vm_id , vm_name, deployment_id FROM vm"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> vmData : results) { VmDeployed vm = new VmDeployed((Integer) vmData.get(0), (String) vmData.get(1)); vm.setDeploymentID((String) vmData.get(2)); answer.add(vm); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } return answer; }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public Collection<VmDeployed> getVms() { Collection<VmDeployed> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT vm_id , vm_name, deployment_id FROM vm"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> vmData : results) { VmDeployed vm = new VmDeployed((Integer) vmData.get(0), (String) vmData.get(1)); vm.setDeploymentID((String) vmData.get(2)); answer.add(vm); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } return answer; } }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public Collection<VmDeployed> getVms() { Collection<VmDeployed> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT vm_id , vm_name, deployment_id FROM vm"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> vmData : results) { VmDeployed vm = new VmDeployed((Integer) vmData.get(0), (String) vmData.get(1)); vm.setDeploymentID((String) vmData.get(2)); answer.add(vm); } } catch (SQLException ex) { Logger.getLogger(DefaultDatabaseConnector.class.getName()).log(Level.SEVERE, null, ex); } return answer; } DefaultDatabaseConnector(); }
DefaultDatabaseConnector extends MySqlDatabaseConnector implements DatabaseConnector { @Override public Collection<VmDeployed> getVms() { Collection<VmDeployed> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT vm_id , vm_name, deployment_id FROM vm"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> vmData : results) { VmDeployed vm = new VmDeployed((Integer) vmData.get(0), (String) vmData.get(1)); vm.setDeploymentID((String) vmData.get(2)); answer.add(vm); } } 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<VmDeployed> getVms() { Collection<VmDeployed> answer = new HashSet<>(); connection = getConnection(connection); if (connection == null) { return null; } try (PreparedStatement preparedStatement = connection.prepareStatement( "SELECT vm_id , vm_name, deployment_id FROM vm"); ResultSet resultSet = preparedStatement.executeQuery()) { ArrayList<ArrayList<Object>> results = resultSetToArray(resultSet); for (ArrayList<Object> vmData : results) { VmDeployed vm = new VmDeployed((Integer) vmData.get(0), (String) vmData.get(1)); vm.setDeploymentID((String) vmData.get(2)); answer.add(vm); } } 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();  }