use of org.apache.phoenix.pherf.configuration.XMLConfigParser in project phoenix by apache.
the class RuleGeneratorTest method testRuleOverrides.
@Test
public void testRuleOverrides() throws Exception {
XMLConfigParser parser = new XMLConfigParser(matcherScenario);
WriteWorkload loader = new WriteWorkload(parser);
RulesApplier rulesApplier = loader.getRulesApplier();
Scenario scenario = parser.getScenarios().get(0);
// We should be able to find the correct rule based only on Type and Name combination
// Test CHAR
Column simPhxCol = new Column();
simPhxCol.setName("OTHER_ID");
simPhxCol.setType(DataTypeMapping.CHAR);
// Get the rule we expect to match
Column rule = rulesApplier.getRule(simPhxCol);
assertEquals("Did not find the correct rule.", rule.getName(), simPhxCol.getName());
assertEquals("Did not find the matching rule type.", rule.getType(), simPhxCol.getType());
assertEquals("Rule contains incorrect length.", rule.getLength(), 8);
assertEquals("Rule contains incorrect prefix.", rule.getPrefix(), "z0Oxx00");
DataValue value = rulesApplier.getDataForRule(scenario, simPhxCol);
assertEquals("Value returned does not match rule.", value.getValue().length(), 8);
// Test VARCHAR with RANDOM and prefix
simPhxCol.setName("OLDVAL_STRING");
simPhxCol.setType(DataTypeMapping.VARCHAR);
// Get the rule we expect to match
rule = rulesApplier.getRule(simPhxCol);
assertEquals("Did not find the correct rule.", rule.getName(), simPhxCol.getName());
assertEquals("Did not find the matching rule type.", rule.getType(), simPhxCol.getType());
assertEquals("Rule contains incorrect length.", rule.getLength(), 10);
assertEquals("Rule contains incorrect prefix.", rule.getPrefix(), "MYPRFX");
value = rulesApplier.getDataForRule(scenario, simPhxCol);
assertEquals("Value returned does not match rule.", value.getValue().length(), 10);
assertTrue("Value returned start with prefix.", StringUtils.startsWith(value.getValue(), rule.getPrefix()));
}
use of org.apache.phoenix.pherf.configuration.XMLConfigParser in project phoenix by apache.
the class ResultBaseTestIT method setUp.
@BeforeClass
public static void setUp() throws Exception {
PherfConstants constants = PherfConstants.create();
properties = constants.getProperties(PherfConstants.PHERF_PROPERTIES, false);
String dir = properties.getProperty("pherf.default.results.dir");
resultUtil.ensureBaseDirExists(dir);
util.setZookeeper("localhost");
reader = new SchemaReader(util, matcherSchema);
parser = new XMLConfigParser(matcherScenario);
}
use of org.apache.phoenix.pherf.configuration.XMLConfigParser 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