Search in sources :

Example 1 with OCheckWorkload

use of com.orientechnologies.orient.stresstest.workload.OCheckWorkload in project orientdb by orientechnologies.

the class OStressTester method execute.

@SuppressWarnings("unchecked")
public int execute() throws Exception {
    int returnCode = 0;
    // we don't want logs from DB
    OLogManager.instance().setConsoleLevel("SEVERE");
    // creates the temporary DB where to execute the test
    ODatabaseUtils.createDatabase(databaseIdentifier);
    System.out.println(String.format("Created database [%s].", databaseIdentifier.getUrl()));
    try {
        for (OWorkload workload : workloads) {
            consoleProgressWriter = new OConsoleProgressWriter(workload);
            consoleProgressWriter.start();
            consoleProgressWriter.printMessage(String.format("\nStarting workload %s (concurrencyLevel=%d)...", workload.getName(), settings.concurrencyLevel));
            final long startTime = System.currentTimeMillis();
            workload.execute(settings, databaseIdentifier);
            final long endTime = System.currentTimeMillis();
            consoleProgressWriter.sendShutdown();
            System.out.println(String.format("\n- Total execution time: %.3f secs", ((float) (endTime - startTime) / 1000f)));
            System.out.println(workload.getFinalResult());
            dumpHaMetrics();
            if (settings.checkDatabase && workload instanceof OCheckWorkload) {
                System.out.println(String.format("- Checking database..."));
                ((OCheckWorkload) workload).check(databaseIdentifier);
                System.out.println(String.format("- Check completed"));
            }
        }
        if (settings.resultOutputFile != null)
            writeFile();
    } catch (Exception ex) {
        System.err.println("\nAn error has occurred while running the stress test: " + ex.getMessage());
        returnCode = 1;
    } finally {
        // we don't need to drop the in-memory DB
        if (settings.keepDatabaseAfterTest || databaseIdentifier.getMode() == OMode.MEMORY)
            consoleProgressWriter.printMessage(String.format("\nDatabase is available on [%s].", databaseIdentifier.getUrl()));
        else {
            ODatabaseUtils.dropDatabase(databaseIdentifier);
            consoleProgressWriter.printMessage(String.format("\nDropped database [%s].", databaseIdentifier.getUrl()));
        }
    }
    return returnCode;
}
Also used : OWorkload(com.orientechnologies.orient.stresstest.workload.OWorkload) OCheckWorkload(com.orientechnologies.orient.stresstest.workload.OCheckWorkload) IOException(java.io.IOException)

Aggregations

OCheckWorkload (com.orientechnologies.orient.stresstest.workload.OCheckWorkload)1 OWorkload (com.orientechnologies.orient.stresstest.workload.OWorkload)1 IOException (java.io.IOException)1