use of com.github.ambry.server.StatsReportType in project ambry by linkedin.
the class HelixHealthReportAggregationTaskTest method testAggregationTask.
/**
* Test {@link HelixHealthReportAggregatorTask#run()} method.
* @throws Exception
*/
@Test
public void testAggregationTask() throws Exception {
int port = 10000;
int numNode = 3;
for (StatsReportType type : StatsReportType.values()) {
initializeNodeReports(type, numNode, port);
String healthReportName = type == StatsReportType.ACCOUNT_REPORT ? HEALTH_REPORT_NAME_ACCOUNT : HEALTH_REPORT_NAME_PARTITION;
String statsFieldName = type == StatsReportType.ACCOUNT_REPORT ? STATS_FIELD_NAME_ACCOUNT : STATS_FIELD_NAME_PARTITION;
task = new HelixHealthReportAggregatorTask(mockHelixManager, RELEVANT_PERIOD_IN_MINUTES, healthReportName, statsFieldName, type, null, clusterMapConfig, mockTime);
task.run();
// Verify the targeted znode has value, don't worry about the correctness of the value, it's verified by other tests.
Stat stat = new Stat();
ZNRecord record = mockHelixManager.getHelixPropertyStore().get(String.format("/%s%s", HelixHealthReportAggregatorTask.AGGREGATED_REPORT_PREFIX, healthReportName), stat, AccessOption.PERSISTENT);
Assert.assertNotNull(record);
Assert.assertNotNull(record.getSimpleField(HelixHealthReportAggregatorTask.VALID_SIZE_FIELD_NAME));
Assert.assertNotNull(record.getSimpleField(HelixHealthReportAggregatorTask.RAW_VALID_SIZE_FIELD_NAME));
}
}
use of com.github.ambry.server.StatsReportType in project ambry by linkedin.
the class HelixTaskWorkflowManagerTool method buildAggregationTaskWorkflow.
/**
* Build the workflow for aggregation tasks.
* @param workflowBuilder {@link Workflow.Builder} object.
* @param config {@link AggregationToolConfig} object.
* @param isRecurrentWorkflow {@code true} is the workflow is recurrent. {@code false} otherwise.
*/
private static void buildAggregationTaskWorkflow(Workflow.Builder workflowBuilder, AggregationToolConfig config, boolean isRecurrentWorkflow) {
// create separate job for each type of stats report
for (String report : config.statsReportsToAggregate) {
StatsReportType statsType = StatsReportType.valueOf(report);
String reportName = AmbryStatsReportImpl.convertStatsReportTypeToProperString(statsType) + AmbryStatsReportImpl.REPORT_NAME_SUFFIX;
String jobId = statsType.toString().toLowerCase() + (isRecurrentWorkflow ? RECURRENT_JOB_SUFFIX : ONE_TIME_JOB_SUFFIX);
String taskId = statsType.toString().toLowerCase() + AGGREGATE_TASK_SUFFIX;
String aggregationCommand = String.format("%s_%s", config.isMysql ? MySqlReportAggregatorTask.TASK_COMMAND_PREFIX : HelixHealthReportAggregatorTask.TASK_COMMAND_PREFIX, reportName);
// build task
List<TaskConfig> taskConfigs = new ArrayList<>();
taskConfigs.add(new TaskConfig.Builder().setTaskId(taskId).setCommand(aggregationCommand).build());
// build job
JobConfig.Builder jobConfigBuilder = new JobConfig.Builder();
jobConfigBuilder.addTaskConfigs(taskConfigs);
jobConfigBuilder.setCommand(aggregationCommand);
// add job into workflow
workflowBuilder.addJob(jobId, jobConfigBuilder);
}
}
Aggregations