Search in sources :

Example 6 with StatsReportType

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));
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat) StatsReportType(com.github.ambry.server.StatsReportType) ZNRecord(org.apache.helix.zookeeper.datamodel.ZNRecord) Test(org.junit.Test)

Example 7 with StatsReportType

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);
    }
}
Also used : ArrayList(java.util.ArrayList) TaskConfig(org.apache.helix.task.TaskConfig) StatsReportType(com.github.ambry.server.StatsReportType) JobConfig(org.apache.helix.task.JobConfig)

Aggregations

StatsReportType (com.github.ambry.server.StatsReportType)7 Test (org.junit.Test)6 StatsSnapshot (com.github.ambry.server.StatsSnapshot)5 StatsWrapper (com.github.ambry.server.StatsWrapper)5 ArrayList (java.util.ArrayList)5 LinkedHashMap (java.util.LinkedHashMap)5 Random (java.util.Random)4 HashMap (java.util.HashMap)3 JobConfig (org.apache.helix.task.JobConfig)1 TaskConfig (org.apache.helix.task.TaskConfig)1 ZNRecord (org.apache.helix.zookeeper.datamodel.ZNRecord)1 Stat (org.apache.zookeeper.data.Stat)1