Search in sources :

Example 1 with CSVFileResultHandler

use of org.apache.phoenix.pherf.result.impl.CSVFileResultHandler in project phoenix by apache.

the class MonitorManager method readResults.

/**
     * This method should really only be used for testing
     *
     * @return List < {@link org.apache.phoenix.pherf.result.Result} >
     * @throws IOException
     */
public synchronized List<Result> readResults() throws Exception {
    ResultHandler handler = null;
    try {
        if (resultHandler.isClosed()) {
            handler = new CSVFileResultHandler();
            handler.setResultFileDetails(ResultFileDetails.CSV);
            handler.setResultFileName(PherfConstants.MONITOR_FILE_NAME);
            return handler.read();
        } else {
            return resultHandler.read();
        }
    } catch (Exception e) {
        throw new FileLoaderRuntimeException("Could not close monitor results.", e);
    } finally {
        if (handler != null) {
            handler.close();
        }
    }
}
Also used : CSVFileResultHandler(org.apache.phoenix.pherf.result.impl.CSVFileResultHandler) FileLoaderRuntimeException(org.apache.phoenix.pherf.exception.FileLoaderRuntimeException) ResultHandler(org.apache.phoenix.pherf.result.ResultHandler) CSVFileResultHandler(org.apache.phoenix.pherf.result.impl.CSVFileResultHandler) IOException(java.io.IOException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) FileLoaderRuntimeException(org.apache.phoenix.pherf.exception.FileLoaderRuntimeException)

Example 2 with CSVFileResultHandler

use of org.apache.phoenix.pherf.result.impl.CSVFileResultHandler in project phoenix by apache.

the class ResultManager method write.

/**
     * Write a combined set of results for each result in the list.
     *
     * @param dataModelResults List<{@link DataModelResult > </>}
     * @throws Exception
     */
public synchronized void write(List<DataModelResult> dataModelResults) throws Exception {
    util.ensureBaseResultDirExists();
    CSVFileResultHandler detailsCSVWriter = null;
    try {
        detailsCSVWriter = new CSVFileResultHandler();
        detailsCSVWriter.setResultFileDetails(ResultFileDetails.CSV_DETAILED_PERFORMANCE);
        detailsCSVWriter.setResultFileName(PherfConstants.COMBINED_FILE_NAME);
        for (DataModelResult dataModelResult : dataModelResults) {
            util.write(detailsCSVWriter, dataModelResult);
        }
    } finally {
        if (detailsCSVWriter != null) {
            detailsCSVWriter.flush();
            detailsCSVWriter.close();
        }
    }
}
Also used : CSVFileResultHandler(org.apache.phoenix.pherf.result.impl.CSVFileResultHandler)

Example 3 with CSVFileResultHandler

use of org.apache.phoenix.pherf.result.impl.CSVFileResultHandler in project phoenix by apache.

the class ResultUtil method write.

/**
     * Write data load time details
     *
     * @param dataLoadThreadTime {@link DataLoadThreadTime}
     * @throws IOException
     */
public synchronized void write(DataLoadThreadTime dataLoadThreadTime) throws IOException {
    ensureBaseResultDirExists();
    CSVResultHandler writer = null;
    try {
        if (!dataLoadThreadTime.getThreadTime().isEmpty()) {
            writer = new CSVFileResultHandler();
            writer.setResultFileDetails(ResultFileDetails.CSV);
            writer.setResultFileName("Data_Load_Details");
            for (WriteThreadTime writeThreadTime : dataLoadThreadTime.getThreadTime()) {
                List<ResultValue> rowValues = new ArrayList<>();
                rowValues.add(new ResultValue(PhoenixUtil.getZookeeper()));
                rowValues.addAll(writeThreadTime.getCsvRepresentation(this));
                Result result = new Result(ResultFileDetails.CSV_DETAILED_PERFORMANCE, "ZK," + dataLoadThreadTime.getCsvTitle(), rowValues);
                writer.write(result);
            }
        }
    } finally {
        if (writer != null) {
            writer.flush();
            writer.close();
        }
    }
}
Also used : CSVFileResultHandler(org.apache.phoenix.pherf.result.impl.CSVFileResultHandler) ArrayList(java.util.ArrayList) CSVResultHandler(org.apache.phoenix.pherf.result.impl.CSVResultHandler)

Example 4 with CSVFileResultHandler

use of org.apache.phoenix.pherf.result.impl.CSVFileResultHandler in project phoenix by apache.

the class ResultUtil method write.

/**
     * Write data load time summary
     *
     * @param dataLoadTime
     * @throws IOException
     */
public synchronized void write(DataLoadTimeSummary dataLoadTime) throws IOException {
    ensureBaseResultDirExists();
    CSVResultHandler writer = null;
    ResultFileDetails resultFileDetails;
    if (PhoenixUtil.isThinDriver()) {
        resultFileDetails = ResultFileDetails.CSV_THIN_AGGREGATE_DATA_LOAD;
    } else {
        resultFileDetails = ResultFileDetails.CSV_AGGREGATE_DATA_LOAD;
    }
    try {
        writer = new CSVFileResultHandler();
        writer.setResultFileDetails(resultFileDetails);
        writer.setResultFileName("Data_Load_Summary");
        for (TableLoadTime loadTime : dataLoadTime.getTableLoadTime()) {
            List<ResultValue> rowValues = new ArrayList<>();
            if (PhoenixUtil.isThinDriver()) {
                rowValues.add(new ResultValue(PhoenixUtil.getQueryServerUrl()));
            } else {
                rowValues.add(new ResultValue(PhoenixUtil.getZookeeper()));
            }
            rowValues.addAll(loadTime.getCsvRepresentation(this));
            Result result = new Result(resultFileDetails, resultFileDetails.getHeader().toString(), rowValues);
            writer.write(result);
        }
    } finally {
        if (writer != null) {
            writer.flush();
            writer.close();
        }
    }
}
Also used : ResultFileDetails(org.apache.phoenix.pherf.result.file.ResultFileDetails) CSVFileResultHandler(org.apache.phoenix.pherf.result.impl.CSVFileResultHandler) ArrayList(java.util.ArrayList) CSVResultHandler(org.apache.phoenix.pherf.result.impl.CSVResultHandler)

Example 5 with CSVFileResultHandler

use of org.apache.phoenix.pherf.result.impl.CSVFileResultHandler in project phoenix by apache.

the class ResultTest method testMonitorWriter.

@Test
public void testMonitorWriter() throws Exception {
    String[] row = "org.apache.phoenix.pherf:type=PherfWriteThreads,6,Mon Jan 05 15:14:00 PST 2015".split(PherfConstants.RESULT_FILE_DELIMETER);
    ResultHandler resultMonitorWriter = null;
    List<ResultValue> resultValues = new ArrayList<>();
    for (String val : row) {
        resultValues.add(new ResultValue(val));
    }
    try {
        resultMonitorWriter = new CSVFileResultHandler();
        resultMonitorWriter.setResultFileDetails(ResultFileDetails.CSV_MONITOR);
        resultMonitorWriter.setResultFileName(PherfConstants.MONITOR_FILE_NAME);
        Result result = new Result(ResultFileDetails.CSV_MONITOR, ResultFileDetails.CSV_MONITOR.getHeader().toString(), resultValues);
        resultMonitorWriter.write(result);
        resultMonitorWriter.write(result);
        resultMonitorWriter.write(result);
        resultMonitorWriter.close();
        List<Result> results = resultMonitorWriter.read();
        assertEquals("Results did not contain row.", results.size(), 3);
    } finally {
        if (resultMonitorWriter != null) {
            resultMonitorWriter.flush();
            resultMonitorWriter.close();
        }
    }
}
Also used : CSVFileResultHandler(org.apache.phoenix.pherf.result.impl.CSVFileResultHandler) XMLResultHandler(org.apache.phoenix.pherf.result.impl.XMLResultHandler) CSVFileResultHandler(org.apache.phoenix.pherf.result.impl.CSVFileResultHandler) Test(org.junit.Test)

Aggregations

CSVFileResultHandler (org.apache.phoenix.pherf.result.impl.CSVFileResultHandler)5 ArrayList (java.util.ArrayList)2 CSVResultHandler (org.apache.phoenix.pherf.result.impl.CSVResultHandler)2 IOException (java.io.IOException)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 FileLoaderRuntimeException (org.apache.phoenix.pherf.exception.FileLoaderRuntimeException)1 ResultHandler (org.apache.phoenix.pherf.result.ResultHandler)1 ResultFileDetails (org.apache.phoenix.pherf.result.file.ResultFileDetails)1 XMLResultHandler (org.apache.phoenix.pherf.result.impl.XMLResultHandler)1 Test (org.junit.Test)1