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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
Aggregations