/** * Indicates whether this optimization algorithm may be used when running the specified type of * job. This algorithm is only available for jobs that report at least one "searchable" stat * tracker. * * @param jobClass The job class for which to make the determination. * @return <CODE>true</CODE> if this optimization algorithm may be used with the provided job * class, or <CODE>false</CODE> if not. */ @Override() public boolean availableWithJobClass(JobClass jobClass) { StatTracker[] jobStats = jobClass.getStatTrackerStubs("", "", 1); if ((jobStats == null) || (jobStats.length == 0)) { return false; } for (int i = 0; i < jobStats.length; i++) { if (jobStats[i].isSearchable()) { return true; } } return false; }
/** * Retrieves a set of parameter stubs that should be used to prompt the end user for the settings * to use when executing the optimizing job. * * @param jobClass The job class that will be used for the optimizing job. * @return A set of parameter stubs that should be used to prompt the end user for the settings to * use when executing the optimizing job. */ @Override() public ParameterList getOptimizationAlgorithmParameterStubs(JobClass jobClass) { // First, compile a list of all the "searchable" statistics that this job // reports it collects. ArrayList<String> availableStatList = new ArrayList<String>(); StatTracker[] jobStats = jobClass.getStatTrackerStubs("", "", 1); for (int i = 0; i < jobStats.length; i++) { if (jobStats[i].isSearchable()) { availableStatList.add(jobStats[i].getDisplayName()); } } int numAvailable = availableStatList.size(); if (numAvailable == 0) { return new ParameterList(); } String[] searchableStatNames = new String[numAvailable]; availableStatList.toArray(searchableStatNames); if (optimizeStat == null) { optimizeStat = searchableStatNames[0]; } String[] optimizationTypes = { Constants.OPTIMIZE_TYPE_MAXIMIZE, Constants.OPTIMIZE_TYPE_MINIMIZE }; String optimizeTypeStr; switch (optimizeType) { case OPTIMIZE_TYPE_MAXIMIZE: optimizeTypeStr = Constants.OPTIMIZE_TYPE_MAXIMIZE; break; case OPTIMIZE_TYPE_MINIMIZE: optimizeTypeStr = Constants.OPTIMIZE_TYPE_MINIMIZE; break; default: optimizeTypeStr = Constants.OPTIMIZE_TYPE_MAXIMIZE; break; } optimizeStatParameter = new MultiChoiceParameter( PARAM_OPTIMIZE_STAT, "Statistic to Optimize", "The name of the statistic for which to " + "try to find the optimal value.", searchableStatNames, optimizeStat); optimizeTypeParameter = new MultiChoiceParameter( PARAM_OPTIMIZE_TYPE, "Optimization Type", "The type of optimization to perform for " + "the statistic to optimize.", optimizationTypes, optimizeTypeStr); maxLatencyParameter = new FloatParameter( PARAM_MAX_REPLICA_LATENCY, "Maximum Acceptable Replication Latency (ms)", "The maximum average replication latency in " + "milliseconds that will be allowed for an " + "iteration to be considered acceptable. A " + "negative value indicates that there will be no " + "maximum latency.", false, (float) maxLatency); maxIncreaseParameter = new FloatParameter( PARAM_MAX_PERCENT_INCREASE, "Maximum Acceptable Percent Increase in Latency", "The maximum percentage of increase in " + "replication latency that will be allowed for an " + "iteration to be considered acceptable.", true, (float) maxIncrease, true, (float) 0.0, false, (float) 0.0); minPctImprovementParameter = new FloatParameter( PARAM_MIN_PCT_IMPROVEMENT, "Min. % Improvement for New Best Iteration", "The minimum percentage improvement in " + "performance that an iteration must have over " + "the previous best to be considered the new best " + "iteration.", false, minPctImprovement, true, 0.0F, false, 0.0F); Parameter[] algorithmParams = { new PlaceholderParameter(), optimizeStatParameter, optimizeTypeParameter, maxLatencyParameter, maxIncreaseParameter, minPctImprovementParameter }; return new ParameterList(algorithmParams); }
/** * Retrieves a set of parameter stubs that should be used to prompt the end user for the settings * to use when executing the optimizing job. * * @param jobClass The job class that will be used for the optimizing job. * @return A set of parameter stubs that should be used to prompt the end user for the settings to * use when executing the optimizing job. */ @Override() public ParameterList getOptimizationAlgorithmParameterStubs(JobClass jobClass) { // First, compile a list of all the "searchable" statistics that this job // reports it collects. ArrayList<String> availableStatList = new ArrayList<String>(); StatTracker[] jobStats = jobClass.getStatTrackerStubs("", "", 1); for (int i = 0; i < jobStats.length; i++) { if (jobStats[i].isSearchable()) { availableStatList.add(jobStats[i].getDisplayName()); } } int numAvailable = availableStatList.size(); if (numAvailable == 0) { return new ParameterList(); } String[] searchableStatNames = new String[numAvailable]; availableStatList.toArray(searchableStatNames); if (optimizeStat == null) { optimizeStat = searchableStatNames[0]; } String[] optimizationTypes = { Constants.OPTIMIZE_TYPE_MAXIMIZE, Constants.OPTIMIZE_TYPE_MINIMIZE }; String optimizeTypeStr; switch (optimizeType) { case OPTIMIZE_TYPE_MAXIMIZE: optimizeTypeStr = Constants.OPTIMIZE_TYPE_MAXIMIZE; break; case OPTIMIZE_TYPE_MINIMIZE: optimizeTypeStr = Constants.OPTIMIZE_TYPE_MINIMIZE; break; default: optimizeTypeStr = Constants.OPTIMIZE_TYPE_MAXIMIZE; break; } String[] utilizationComponents = { UTILIZATION_COMPONENT_USER_STRING, UTILIZATION_COMPONENT_SYSTEM_STRING, UTILIZATION_COMPONENT_BUSY_STRING }; String componentStr; switch (utilizationComponent) { case UTILIZATION_COMPONENT_USER_TIME: componentStr = UTILIZATION_COMPONENT_USER_STRING; break; case UTILIZATION_COMPONENT_SYSTEM_TIME: componentStr = UTILIZATION_COMPONENT_SYSTEM_STRING; break; case UTILIZATION_COMPONENT_BUSY_TIME: componentStr = UTILIZATION_COMPONENT_BUSY_STRING; break; default: componentStr = UTILIZATION_COMPONENT_BUSY_STRING; break; } optimizeStatParameter = new MultiChoiceParameter( PARAM_OPTIMIZE_STAT, "Statistic to Optimize", "The name of the statistic for which to " + "try to find the optimal value.", searchableStatNames, optimizeStat); optimizeTypeParameter = new MultiChoiceParameter( PARAM_OPTIMIZE_TYPE, "Optimization Type", "The type of optimization to perform for " + "the statistic to optimize.", optimizationTypes, optimizeTypeStr); maxUtilizationParameter = new FloatParameter( PARAM_MAX_CPU_UTILIZATION, "Maximum Acceptable CPU Utilization", "The maximum CPU utilization that will be " + "allowed for the specified CPU component for " + "an iteration to be considered acceptable.", true, (float) maxUtilization, true, (float) 0.0, true, (float) 100.0); utilizationComponentParameter = new MultiChoiceParameter( PARAM_UTILIZATION_COMPONENT, "Utilization Component to Consider", "The CPU utilization component to consider " + "when deciding whether an iteration is " + "acceptable.", utilizationComponents, componentStr); minPctImprovementParameter = new FloatParameter( PARAM_MIN_PCT_IMPROVEMENT, "Min. % Improvement for New Best Iteration", "The minimum percentage improvement in " + "performance that an iteration must have over " + "the previous best to be considered the new best " + "iteration.", false, minPctImprovement, true, 0.0F, false, 0.0F); Parameter[] algorithmParams = { new PlaceholderParameter(), optimizeStatParameter, optimizeTypeParameter, maxUtilizationParameter, utilizationComponentParameter, minPctImprovementParameter }; return new ParameterList(algorithmParams); }