use of org.apache.phoenix.pherf.util.ResourceList in project phoenix by apache.
the class ResourceTest method assertResources.
private Collection<Path> assertResources(String pattern, String rootDir, String assertStr) throws Exception {
ResourceList list = new ResourceList(rootDir);
Collection<Path> paths = list.getResourceList(pattern);
assertTrue("Resource file list was empty", paths.size() > 0);
for (Path path : paths) {
assertThat(path.toString(), containsString(assertStr));
}
return paths;
}
use of org.apache.phoenix.pherf.util.ResourceList in project phoenix by apache.
the class XMLConfigParser method init.
private void init(String pattern) throws Exception {
if (dataModels != null) {
return;
}
this.filePattern = pattern;
this.dataModels = new ArrayList<>();
this.resourceList = new ResourceList(PherfConstants.RESOURCE_SCENARIO);
this.paths = getResources(this.filePattern);
if (this.paths.isEmpty()) {
throw new FileLoaderException("Could not load the resource files using the pattern: " + pattern);
}
for (Path path : this.paths) {
System.out.println("Adding model for path:" + path.toString());
this.dataModels.add(XMLConfigParser.readDataModel(path));
}
}
use of org.apache.phoenix.pherf.util.ResourceList in project phoenix by apache.
the class Pherf method run.
public void run() throws Exception {
MonitorManager monitorManager = null;
List<Workload> workloads = new ArrayList<>();
WorkloadExecutor workloadExecutor = new WorkloadExecutor(properties, workloads, !isFunctional);
try {
if (listFiles) {
ResourceList list = new ResourceList(PherfConstants.RESOURCE_DATAMODEL);
Collection<Path> schemaFiles = list.getResourceList(PherfConstants.SCHEMA_ROOT_PATTERN + ".sql");
System.out.println("Schema Files:");
for (Path path : schemaFiles) {
System.out.println(path);
}
list = new ResourceList(PherfConstants.RESOURCE_SCENARIO);
Collection<Path> scenarioFiles = list.getResourceList(PherfConstants.SCENARIO_ROOT_PATTERN + ".xml");
System.out.println("Scenario Files:");
for (Path path : scenarioFiles) {
System.out.println(path);
}
return;
}
// Compare results and exit
if (null != compareResults) {
logger.info("\nStarting to compare results and exiting for " + compareResults);
new GoogleChartGenerator(compareResults, compareType).readAndRender();
return;
}
XMLConfigParser parser = new XMLConfigParser(scenarioFile);
// Drop tables with PHERF schema and regex comparison
if (null != dropPherfTablesRegEx) {
logger.info("\nDropping existing table with PHERF namename and " + dropPherfTablesRegEx + " regex expression.");
phoenixUtil.deleteTables(dropPherfTablesRegEx);
}
if (monitor) {
monitorManager = new MonitorManager(Integer.parseInt(properties.getProperty("pherf.default.monitorFrequency")));
workloadExecutor.add(monitorManager);
}
if (applySchema) {
logger.info("\nStarting to apply schema...");
SchemaReader reader = (schemaFile == null) ? new SchemaReader(".*.sql") : new SchemaReader(schemaFile);
reader.applySchema();
}
// Schema and Data Load
if (preLoadData) {
logger.info("\nStarting Data Load...");
Workload workload = new WriteWorkload(parser, generateStatistics);
try {
workloadExecutor.add(workload);
// Wait for dataLoad to complete
workloadExecutor.get(workload);
} finally {
if (null != workload) {
workload.complete();
}
}
} else {
logger.info("\nSKIPPED: Data Load and schema creation as -l argument not specified");
}
// Execute multi-threaded query sets
if (executeQuerySets) {
logger.info("\nStarting to apply Execute Queries...");
workloadExecutor.add(new QueryExecutor(parser, phoenixUtil, workloadExecutor, parser.getDataModels(), queryHint, isFunctional, writeRuntimeResults));
} else {
logger.info("\nSKIPPED: Multithreaded query set execution as -q argument not specified");
}
// Clean up the monitor explicitly
if (monitorManager != null) {
logger.info("Run completed. Shutting down Monitor.");
monitorManager.complete();
}
// Collect any final jobs
workloadExecutor.get();
} finally {
if (workloadExecutor != null) {
logger.info("Run completed. Shutting down thread pool.");
workloadExecutor.shutdown();
}
}
}
Aggregations