Search in sources :

Example 1 with SchemaReader

use of org.apache.phoenix.pherf.schema.SchemaReader 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);
}
Also used : SchemaReader(org.apache.phoenix.pherf.schema.SchemaReader) XMLConfigParser(org.apache.phoenix.pherf.configuration.XMLConfigParser) BeforeClass(org.junit.BeforeClass)

Example 2 with SchemaReader

use of org.apache.phoenix.pherf.schema.SchemaReader in project phoenix by apache.

the class SchemaReaderIT method assertApplySchemaTest.

private void assertApplySchemaTest() {
    try {
        util.setZookeeper("localhost");
        SchemaReader reader = new SchemaReader(util, ".*datamodel/.*test.*sql");
        List<Path> resources = new ArrayList<>(reader.getResourceList());
        assertTrue("Could not pull list of schema files.", resources.size() > 0);
        assertNotNull("Could not read schema file.", this.getClass().getResourceAsStream(PherfConstants.RESOURCE_DATAMODEL + "/" + resources.get(0).getFileName().toString()));
        assertNotNull("Could not read schema file.", reader.resourceToString(resources.get(0)));
        try {
            reader.applySchema();
        } catch (SQLException e) {
            fail("Failed to apply schema " + e.getMessage());
        }
        Connection connection = null;
        URL resourceUrl = getClass().getResource("/scenario/test_scenario.xml");
        assertNotNull("Test data XML file is missing", resourceUrl);
        connection = util.getConnection();
        Path resourcePath = Paths.get(resourceUrl.toURI());
        DataModel data = XMLConfigParser.readDataModel(resourcePath);
        List<Scenario> scenarioList = data.getScenarios();
        Scenario scenario = scenarioList.get(0);
        List<Column> columnList = util.getColumnsFromPhoenix(scenario.getSchemaName(), scenario.getTableNameWithoutSchemaName(), connection);
        assertTrue("Could not retrieve Metadata from Phoenix", columnList.size() > 0);
    } catch (Exception e) {
        fail("Could not initialize SchemaReader");
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) SchemaReader(org.apache.phoenix.pherf.schema.SchemaReader) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) URL(java.net.URL) SQLException(java.sql.SQLException) Scenario(org.apache.phoenix.pherf.configuration.Scenario) Column(org.apache.phoenix.pherf.configuration.Column) DataModel(org.apache.phoenix.pherf.configuration.DataModel)

Example 3 with SchemaReader

use of org.apache.phoenix.pherf.schema.SchemaReader 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();
        }
    }
}
Also used : Path(java.nio.file.Path) SchemaReader(org.apache.phoenix.pherf.schema.SchemaReader) WriteWorkload(org.apache.phoenix.pherf.workload.WriteWorkload) ArrayList(java.util.ArrayList) XMLConfigParser(org.apache.phoenix.pherf.configuration.XMLConfigParser) WorkloadExecutor(org.apache.phoenix.pherf.workload.WorkloadExecutor) Workload(org.apache.phoenix.pherf.workload.Workload) WriteWorkload(org.apache.phoenix.pherf.workload.WriteWorkload) MonitorManager(org.apache.phoenix.pherf.jmx.MonitorManager) ResourceList(org.apache.phoenix.pherf.util.ResourceList) GoogleChartGenerator(org.apache.phoenix.pherf.util.GoogleChartGenerator) QueryExecutor(org.apache.phoenix.pherf.workload.QueryExecutor)

Aggregations

SchemaReader (org.apache.phoenix.pherf.schema.SchemaReader)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 XMLConfigParser (org.apache.phoenix.pherf.configuration.XMLConfigParser)2 URL (java.net.URL)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 Column (org.apache.phoenix.pherf.configuration.Column)1 DataModel (org.apache.phoenix.pherf.configuration.DataModel)1 Scenario (org.apache.phoenix.pherf.configuration.Scenario)1 MonitorManager (org.apache.phoenix.pherf.jmx.MonitorManager)1 GoogleChartGenerator (org.apache.phoenix.pherf.util.GoogleChartGenerator)1 ResourceList (org.apache.phoenix.pherf.util.ResourceList)1 QueryExecutor (org.apache.phoenix.pherf.workload.QueryExecutor)1 Workload (org.apache.phoenix.pherf.workload.Workload)1 WorkloadExecutor (org.apache.phoenix.pherf.workload.WorkloadExecutor)1 WriteWorkload (org.apache.phoenix.pherf.workload.WriteWorkload)1 BeforeClass (org.junit.BeforeClass)1