Search in sources :

Example 11 with DataStatistics

use of org.apache.flink.optimizer.DataStatistics in project flink by apache.

the class ExecutionPlanCreationTest method testGetExecutionPlan.

@Test
public void testGetExecutionPlan() {
    try {
        PackagedProgram prg = new PackagedProgram(TestOptimizerPlan.class, "/dev/random", "/tmp");
        assertNotNull(prg.getPreviewPlan());
        InetAddress mockAddress = InetAddress.getLocalHost();
        InetSocketAddress mockJmAddress = new InetSocketAddress(mockAddress, 12345);
        Configuration config = new Configuration();
        config.setString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, mockJmAddress.getHostName());
        config.setInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, mockJmAddress.getPort());
        Optimizer optimizer = new Optimizer(new DataStatistics(), new DefaultCostEstimator(), config);
        OptimizedPlan op = (OptimizedPlan) ClusterClient.getOptimizedPlan(optimizer, prg, -1);
        assertNotNull(op);
        PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator();
        assertNotNull(dumper.getOptimizerPlanAsJSON(op));
        // test HTML escaping
        PlanJSONDumpGenerator dumper2 = new PlanJSONDumpGenerator();
        dumper2.setEncodeForHTML(true);
        String htmlEscaped = dumper2.getOptimizerPlanAsJSON(op);
        assertEquals(-1, htmlEscaped.indexOf('\\'));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : PlanJSONDumpGenerator(org.apache.flink.optimizer.plandump.PlanJSONDumpGenerator) Configuration(org.apache.flink.configuration.Configuration) InetSocketAddress(java.net.InetSocketAddress) Optimizer(org.apache.flink.optimizer.Optimizer) DataStatistics(org.apache.flink.optimizer.DataStatistics) DefaultCostEstimator(org.apache.flink.optimizer.costs.DefaultCostEstimator) InetAddress(java.net.InetAddress) OptimizedPlan(org.apache.flink.optimizer.plan.OptimizedPlan) Test(org.junit.Test)

Example 12 with DataStatistics

use of org.apache.flink.optimizer.DataStatistics in project flink by apache.

the class JarActionHandler method getJobGraphAndClassLoader.

protected Tuple2<JobGraph, ClassLoader> getJobGraphAndClassLoader(JarActionHandlerConfig config) throws Exception {
    // generate the graph
    JobGraph graph = null;
    PackagedProgram program = new PackagedProgram(new File(jarDir, config.getJarFile()), config.getEntryClass(), config.getProgramArgs());
    ClassLoader classLoader = program.getUserCodeClassLoader();
    Optimizer optimizer = new Optimizer(new DataStatistics(), new DefaultCostEstimator(), new Configuration());
    FlinkPlan plan = ClusterClient.getOptimizedPlan(optimizer, program, config.getParallelism());
    if (plan instanceof StreamingPlan) {
        graph = ((StreamingPlan) plan).getJobGraph();
    } else if (plan instanceof OptimizedPlan) {
        graph = new JobGraphGenerator().compileJobGraph((OptimizedPlan) plan);
    }
    if (graph == null) {
        throw new CompilerException("A valid job graph couldn't be generated for the jar.");
    }
    // Set the savepoint settings
    graph.setSavepointRestoreSettings(config.getSavepointRestoreSettings());
    for (URL jar : program.getAllLibraries()) {
        try {
            graph.addJar(new Path(jar.toURI()));
        } catch (URISyntaxException e) {
            throw new ProgramInvocationException("Invalid jar path. Unexpected error. :(");
        }
    }
    return Tuple2.of(graph, classLoader);
}
Also used : Path(org.apache.flink.core.fs.Path) Configuration(org.apache.flink.configuration.Configuration) StreamingPlan(org.apache.flink.optimizer.plan.StreamingPlan) Optimizer(org.apache.flink.optimizer.Optimizer) DataStatistics(org.apache.flink.optimizer.DataStatistics) FlinkPlan(org.apache.flink.optimizer.plan.FlinkPlan) URISyntaxException(java.net.URISyntaxException) URL(java.net.URL) OptimizedPlan(org.apache.flink.optimizer.plan.OptimizedPlan) PackagedProgram(org.apache.flink.client.program.PackagedProgram) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobGraphGenerator(org.apache.flink.optimizer.plantranslate.JobGraphGenerator) CompilerException(org.apache.flink.optimizer.CompilerException) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) DefaultCostEstimator(org.apache.flink.optimizer.costs.DefaultCostEstimator) File(java.io.File)

Example 13 with DataStatistics

use of org.apache.flink.optimizer.DataStatistics in project flink by apache.

the class TestEnvironment method compileProgram.

private OptimizedPlan compileProgram(String jobName) {
    Plan p = createProgramPlan(jobName);
    Optimizer pc = new Optimizer(new DataStatistics(), this.executor.configuration());
    return pc.compile(p);
}
Also used : Optimizer(org.apache.flink.optimizer.Optimizer) DataStatistics(org.apache.flink.optimizer.DataStatistics) Plan(org.apache.flink.api.common.Plan) OptimizedPlan(org.apache.flink.optimizer.plan.OptimizedPlan)

Aggregations

DataStatistics (org.apache.flink.optimizer.DataStatistics)13 Optimizer (org.apache.flink.optimizer.Optimizer)13 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)11 Configuration (org.apache.flink.configuration.Configuration)8 DefaultCostEstimator (org.apache.flink.optimizer.costs.DefaultCostEstimator)7 PlanJSONDumpGenerator (org.apache.flink.optimizer.plandump.PlanJSONDumpGenerator)6 JobGraphGenerator (org.apache.flink.optimizer.plantranslate.JobGraphGenerator)4 PackagedProgram (org.apache.flink.client.program.PackagedProgram)3 Test (org.junit.Test)3 URL (java.net.URL)2 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)2 CompilerException (org.apache.flink.optimizer.CompilerException)2 FlinkPlan (org.apache.flink.optimizer.plan.FlinkPlan)2 StreamingPlan (org.apache.flink.optimizer.plan.StreamingPlan)2 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 URISyntaxException (java.net.URISyntaxException)1