/** * Trims zeros at the end of an array. * * @param data the data array * @return the trimmed array */ public static double[] trimZeroTail(final double[] data) { return Arrays.copyOfRange(data, 0, countNonZeroBeginning(data)); }
/** * Gets the host utilization MAD. * * @param host the host * @return the host utilization MAD */ protected double getHostUtilizationMad(PowerHostUtilizationHistory host) throws IllegalArgumentException { double[] data = host.getUtilizationHistory(); if (MathUtil.countNonZeroBeginning(data) >= 12) { // 12 has been suggested as a safe value return MathUtil.mad(data); } throw new IllegalArgumentException(); }
/** * Gets the host CPU utilization percentage IQR. * * @param host the host * @return the host CPU utilization percentage IQR */ protected double getHostUtilizationIqr(PowerHostUtilizationHistory host) throws IllegalArgumentException { double[] data = host.getUtilizationHistory(); if (MathUtil.countNonZeroBeginning(data) >= 12) { // 12 has been suggested as a safe value return MathUtil.iqr(data); } throw new IllegalArgumentException(); }
/** * Computes the host utilization IRQ used for generating the host over utilization threshold. * * @param host the host * @return the host CPU utilization percentage IQR */ @Override public double computeHostUtilizationMeasure(final Host host) throws IllegalArgumentException { final double[] cpuUsageArray = getHostCpuUsageArray(host); if (MathUtil.countNonZeroBeginning(cpuUsageArray) >= MIN_HISTORY_ENTRIES_FOR_IRQ) { return MathUtil.iqr(cpuUsageArray); } throw new IllegalArgumentException("There is not enough Host history to compute Host utilization IRQ"); }
/** * Computes the host utilization MAD used for generating the host over utilization threshold. * * @param host the host * @return the host utilization MAD * @throws {@inheritDoc} */ @Override public double computeHostUtilizationMeasure(final Host host) throws IllegalArgumentException { final double[] cpuUsageArray = getHostCpuUsageArray(host); if (MathUtil.countNonZeroBeginning(cpuUsageArray) >= MIN_HISTORY_ENTRIES_FOR_MAD) { return MathUtil.mad(cpuUsageArray); } throw new IllegalArgumentException("There is not enough Host history to compute Host utilization MAD"); }