Search in sources :

Example 1 with MasterBenchSummary

use of alluxio.stress.master.MasterBenchSummary in project alluxio by Alluxio.

the class MaxThroughput method runSuite.

@Override
public MaxThroughputSummary runSuite(String[] args) throws Exception {
    try (JobMasterClient client = JobMasterClient.Factory.create(JobMasterClientContext.newBuilder(ClientContext.create(new InstancedConfiguration(ConfigurationUtils.defaults()))).build())) {
        mNumWorkers = client.getAllWorkerHealth().size();
    }
    if (mNumWorkers <= 0) {
        throw new IllegalStateException("No workers available for testing!");
    }
    MaxThroughputSummary summary = new MaxThroughputSummary();
    summary.setParameters(mParameters);
    List<String> baseArgs = new ArrayList<>(Arrays.asList(args));
    if (!mParameters.mSkipPrepare) {
        prepareBeforeAllTests(baseArgs);
    }
    int lower = 0;
    int upper = Integer.MAX_VALUE;
    // use the input target throughput as the starting point
    int next = mParameters.mTargetThroughput;
    int best = 0;
    while (true) {
        int perWorkerThroughput = next / mNumWorkers;
        int requestedThroughput = perWorkerThroughput * mNumWorkers;
        if (perWorkerThroughput == 0) {
            // Cannot run with a target of 0
            break;
        }
        List<String> newArgs = new ArrayList<>(baseArgs);
        updateArgValue(newArgs, "--target-throughput", Integer.toString(perWorkerThroughput));
        long runSec = (FormatUtils.parseTimeSize(mParameters.mDuration) + FormatUtils.parseTimeSize(mParameters.mWarmup)) / 1000;
        // the expected number of paths required for the test to complete successfully
        long requiredCount = next * runSec;
        MasterBenchSummary mbr = runSingleTest(requiredCount, newArgs);
        int current = next;
        final float actualThroughput = mbr.getThroughput();
        if ((actualThroughput > requestedThroughput) || ((requestedThroughput - actualThroughput) / (float) requestedThroughput) < 0.02) {
            // the throughput was achieved. increase.
            summary.addPassedRun(current, mbr);
            best = current;
            // update the lower bound.
            lower = current;
            if (upper == Integer.MAX_VALUE) {
                next *= 2;
            } else {
                next = (next + upper) / 2;
            }
        } else {
            // Failed to achieve the target throughput. update the upper bound.
            summary.addFailedRun(current, mbr);
            upper = current;
            // throughput was not achieved. decrease.
            next = (lower + next) / 2;
        }
        LOG.info("target: " + requestedThroughput + " actual: " + actualThroughput + " [" + lower + " " + next + " " + upper + "]");
        for (String error : mbr.collectErrorsFromAllNodes()) {
            LOG.error("{}", error);
        }
        if (Math.abs(current - next) / (float) current <= 0.02) {
            break;
        }
    }
    LOG.info("max throughput: " + best);
    summary.setEndTimeMs(CommonUtils.getCurrentMs());
    summary.setMaxThroughput(best);
    return summary;
}
Also used : JobMasterClient(alluxio.client.job.JobMasterClient) InstancedConfiguration(alluxio.conf.InstancedConfiguration) ArrayList(java.util.ArrayList) MasterBenchSummary(alluxio.stress.master.MasterBenchSummary) MaxThroughputSummary(alluxio.stress.master.MaxThroughputSummary)

Example 2 with MasterBenchSummary

use of alluxio.stress.master.MasterBenchSummary in project alluxio by Alluxio.

the class StressMasterBenchIntegrationTest method validateTheResultWithWriteType.

private void validateTheResultWithWriteType(String writeType) throws Exception {
    String output1 = new StressMasterBench().run(new String[] { "--in-process", "--base", sLocalAlluxioClusterResource.get().getMasterURI() + "/", "--operation", "CreateFile", "--fixed-count", "20", "--target-throughput", "300", "--threads", "5", "--warmup", "0s", "--duration", "3s", "--write-type", writeType });
    String output2 = new StressMasterBench().run(new String[] { "--in-process", "--base", sLocalAlluxioClusterResource.get().getMasterURI() + "/", "--operation", "DeleteFile", "--fixed-count", "20", "--target-throughput", "100", "--threads", "5", "--warmup", "0s", "--duration", "1s", "--write-type", writeType });
    // convert the result into summary, and check whether it have errors.
    MasterBenchSummary summary1 = (MasterBenchSummary) JsonSerializable.fromJson(output1);
    MasterBenchSummary summary2 = (MasterBenchSummary) JsonSerializable.fromJson(output2);
    // confirm that the results contain information, and they don't contain errors.
    assertFalse(summary1.getNodeResults().isEmpty());
    assertTrue(summary1.collectErrorsFromAllNodes().isEmpty());
    assertFalse(summary2.getNodeResults().isEmpty());
    assertTrue(summary2.collectErrorsFromAllNodes().isEmpty());
}
Also used : StressMasterBench(alluxio.stress.cli.StressMasterBench) MasterBenchSummary(alluxio.stress.master.MasterBenchSummary)

Example 3 with MasterBenchSummary

use of alluxio.stress.master.MasterBenchSummary in project alluxio by Alluxio.

the class StressMasterBenchIntegrationTest method validateTheOutput.

private void validateTheOutput(String operation) throws Exception {
    long startTime = System.currentTimeMillis();
    String basePath = sLocalAlluxioClusterResource.get().getMasterURI() + "/";
    String output = new StressMasterBench().run(new String[] { "--in-process", "--base", basePath, "--operation", operation, "--stop-count", "100", "--target-throughput", "1000", "--threads", "5", "--warmup", "0s", "--duration", "10s" });
    MasterBenchSummary summary = (MasterBenchSummary) JsonSerializable.fromJson(output);
    assertEquals(summary.getParameters().mOperation.toString(), operation);
    assertEquals(summary.getParameters().mBasePath, basePath);
    assertEquals(summary.getParameters().mStopCount, 100);
    assertEquals(summary.getParameters().mTargetThroughput, 1000);
    assertEquals(summary.getParameters().mThreads, 5);
    assertEquals(summary.getParameters().mWarmup, "0s");
    assertEquals(summary.getParameters().mDuration, "10s");
    assertTrue(summary.getEndTimeMs() > startTime);
    assertTrue(summary.getNodeResults().size() >= 1);
    assertTrue(summary.getDurationMs() > 0);
    assertTrue(summary.getThroughput() > 0);
    assertEquals(summary.getStatistics().mNumSuccess, 100);
    assertTrue(summary.collectErrorsFromAllNodes().isEmpty());
}
Also used : StressMasterBench(alluxio.stress.cli.StressMasterBench) MasterBenchSummary(alluxio.stress.master.MasterBenchSummary)

Example 4 with MasterBenchSummary

use of alluxio.stress.master.MasterBenchSummary in project alluxio by Alluxio.

the class StressMasterBenchIntegrationTest method writeTypeALLTaskTest.

@Test
public void writeTypeALLTaskTest() throws Exception {
    // redirect the output stream
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PrintStream originalOut = System.out;
    System.setOut(new PrintStream(out));
    new StressMasterBench().run(new String[] { "--in-process", "--base", sLocalAlluxioClusterResource.get().getMasterURI() + "/", "--operation", "CreateFile", "--fixed-count", "20", "--target-throughput", "300", "--threads", "5", "--warmup", "0s", "--duration", "3s", "--write-type", "ALL" });
    String printOutResult = out.toString();
    List<String> resultList = getJsonResult(printOutResult);
    assertEquals(resultList.size(), 4);
    // the possible write types
    List<String> writeTypes = ImmutableList.of("MUST_CACHE", "CACHE_THROUGH", "ASYNC_THROUGH", "THROUGH");
    for (int i = 0; i < resultList.size(); i++) {
        MasterBenchSummary summary = (MasterBenchSummary) JsonSerializable.fromJson(resultList.get(i));
        // confirm that the task was executed with certain write type and output no errors
        assertEquals(summary.getParameters().mWriteType, writeTypes.get(i));
        assertFalse(summary.getNodeResults().isEmpty());
        assertTrue(summary.collectErrorsFromAllNodes().isEmpty());
    }
    // reset the output to the console
    System.setOut(originalOut);
}
Also used : PrintStream(java.io.PrintStream) StressMasterBench(alluxio.stress.cli.StressMasterBench) MasterBenchSummary(alluxio.stress.master.MasterBenchSummary) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 5 with MasterBenchSummary

use of alluxio.stress.master.MasterBenchSummary in project alluxio by Alluxio.

the class MaxThroughput method createFiles.

/**
 * @param numFiles number of files to create with each task
 * @param args the args
 */
private void createFiles(long numFiles, List<String> args) throws Exception {
    List<String> newArgs = new ArrayList<>(args);
    updateArgValue(newArgs, "--operation", Operation.CREATE_FILE.toString());
    updateArgValue(newArgs, "--warmup", "0s");
    updateArgValue(newArgs, "--threads", "128");
    updateArgValue(newArgs, "--stop-count", Long.toString(numFiles));
    updateArgValue(newArgs, "--target-throughput", "10000");
    LOG.info(String.format("Preparing %d files. args: %s", numFiles, String.join(" ", newArgs)));
    Benchmark b = new StressMasterBench();
    String result = b.run(newArgs.toArray(new String[0]));
    MasterBenchSummary summary = JsonSerializable.fromJson(result, new MasterBenchSummary[0]);
    if (!summary.collectErrorsFromAllNodes().isEmpty()) {
        throw new IllegalStateException(String.format("Could not create files for operation (%s). error: %s", mParameters.mOperation, summary.collectErrorsFromAllNodes().iterator().next()));
    }
}
Also used : StressMasterBench(alluxio.stress.cli.StressMasterBench) ArrayList(java.util.ArrayList) Benchmark(alluxio.stress.cli.Benchmark) MasterBenchSummary(alluxio.stress.master.MasterBenchSummary)

Aggregations

MasterBenchSummary (alluxio.stress.master.MasterBenchSummary)5 StressMasterBench (alluxio.stress.cli.StressMasterBench)4 ArrayList (java.util.ArrayList)2 JobMasterClient (alluxio.client.job.JobMasterClient)1 InstancedConfiguration (alluxio.conf.InstancedConfiguration)1 Benchmark (alluxio.stress.cli.Benchmark)1 MaxThroughputSummary (alluxio.stress.master.MaxThroughputSummary)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 Test (org.junit.Test)1