org.apache.flink.optimizer.dag.DataSinkNode Java Examples
The following examples show how to use
org.apache.flink.optimizer.dag.DataSinkNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PreviewPlanDumpTest.java From flink with Apache License 2.0 | 6 votes |
private static void verifyPlanDump(Class<?> entrypoint, String... args) throws Exception { final PackagedProgram program = PackagedProgram .newBuilder() .setEntryPointClassName(entrypoint.getName()) .setArguments(args) .build(); final Pipeline pipeline = PackagedProgramUtils.getPipelineFromProgram(program, new Configuration(), 1, true); assertTrue(pipeline instanceof Plan); final Plan plan = (Plan) pipeline; final List<DataSinkNode> sinks = Optimizer.createPreOptimizedPlan(plan); final PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator(); final String json = dumper.getPactPlanAsJSON(sinks); try (JsonParser parser = new JsonFactory().createParser(json)) { while (parser.nextToken() != null) { } } }
Example #2
Source File: SinkPlanNode.java From flink with Apache License 2.0 | 5 votes |
public DataSinkNode getSinkNode() { if (this.template instanceof DataSinkNode) { return (DataSinkNode) this.template; } else { throw new RuntimeException(); } }
Example #3
Source File: SinkPlanNode.java From flink with Apache License 2.0 | 5 votes |
/** * Constructs a new sink candidate node that uses <i>NONE</i> as its local strategy. Note that * local sorting and range partitioning are handled by the incoming channel already. * * @param template The template optimizer node that this candidate is created for. */ public SinkPlanNode(DataSinkNode template, String nodeName, Channel input) { super(template, nodeName, input, DriverStrategy.NONE); this.globalProps = input.getGlobalProperties().clone(); this.localProps = input.getLocalProperties().clone(); }
Example #4
Source File: GraphCreatingVisitor.java From flink with Apache License 2.0 | 5 votes |
private GraphCreatingVisitor(GraphCreatingVisitor parent, boolean forceParallelism, int defaultParallelism, ExecutionMode dataExchangeMode, HashMap<Operator<?>, OptimizerNode> closure) { if (closure == null){ con2node = new HashMap<Operator<?>, OptimizerNode>(); } else { con2node = closure; } this.sinks = new ArrayList<DataSinkNode>(2); this.defaultParallelism = defaultParallelism; this.parent = parent; this.defaultDataExchangeMode = dataExchangeMode; this.forceParallelism = forceParallelism; }
Example #5
Source File: GraphCreatingVisitor.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private GraphCreatingVisitor(GraphCreatingVisitor parent, boolean forceParallelism, int defaultParallelism, ExecutionMode dataExchangeMode, HashMap<Operator<?>, OptimizerNode> closure) { if (closure == null){ con2node = new HashMap<Operator<?>, OptimizerNode>(); } else { con2node = closure; } this.sinks = new ArrayList<DataSinkNode>(2); this.defaultParallelism = defaultParallelism; this.parent = parent; this.defaultDataExchangeMode = dataExchangeMode; this.forceParallelism = forceParallelism; }
Example #6
Source File: SinkPlanNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Constructs a new sink candidate node that uses <i>NONE</i> as its local strategy. Note that * local sorting and range partitioning are handled by the incoming channel already. * * @param template The template optimizer node that this candidate is created for. */ public SinkPlanNode(DataSinkNode template, String nodeName, Channel input) { super(template, nodeName, input, DriverStrategy.NONE); this.globalProps = input.getGlobalProperties().clone(); this.localProps = input.getLocalProperties().clone(); }
Example #7
Source File: SinkPlanNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public DataSinkNode getSinkNode() { if (this.template instanceof DataSinkNode) { return (DataSinkNode) this.template; } else { throw new RuntimeException(); } }
Example #8
Source File: SinkPlanNode.java From flink with Apache License 2.0 | 5 votes |
public DataSinkNode getSinkNode() { if (this.template instanceof DataSinkNode) { return (DataSinkNode) this.template; } else { throw new RuntimeException(); } }
Example #9
Source File: SinkPlanNode.java From flink with Apache License 2.0 | 5 votes |
/** * Constructs a new sink candidate node that uses <i>NONE</i> as its local strategy. Note that * local sorting and range partitioning are handled by the incoming channel already. * * @param template The template optimizer node that this candidate is created for. */ public SinkPlanNode(DataSinkNode template, String nodeName, Channel input) { super(template, nodeName, input, DriverStrategy.NONE); this.globalProps = input.getGlobalProperties().clone(); this.localProps = input.getLocalProperties().clone(); }
Example #10
Source File: GraphCreatingVisitor.java From flink with Apache License 2.0 | 5 votes |
private GraphCreatingVisitor(GraphCreatingVisitor parent, boolean forceParallelism, int defaultParallelism, ExecutionMode dataExchangeMode, HashMap<Operator<?>, OptimizerNode> closure) { if (closure == null){ con2node = new HashMap<Operator<?>, OptimizerNode>(); } else { con2node = closure; } this.sinks = new ArrayList<DataSinkNode>(2); this.defaultParallelism = defaultParallelism; this.parent = parent; this.defaultDataExchangeMode = dataExchangeMode; this.forceParallelism = forceParallelism; }
Example #11
Source File: PackagedProgram.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Returns the analyzed plan without any optimizations. * * @return * the analyzed plan without any optimizations. * @throws ProgramInvocationException Thrown if an error occurred in the * user-provided pact assembler. This may indicate * missing parameters for generation. */ public String getPreviewPlan() throws ProgramInvocationException { Thread.currentThread().setContextClassLoader(this.getUserCodeClassLoader()); List<DataSinkNode> previewPlan; if (isUsingProgramEntryPoint()) { previewPlan = Optimizer.createPreOptimizedPlan(getPlan()); } else if (isUsingInteractiveMode()) { // temporary hack to support the web client PreviewPlanEnvironment env = new PreviewPlanEnvironment(); env.setAsContext(); try { invokeInteractiveModeForExecution(); } catch (ProgramInvocationException e) { throw e; } catch (Throwable t) { // the invocation gets aborted with the preview plan if (env.previewPlan == null) { if (env.preview != null) { return env.preview; } else { throw new ProgramInvocationException("The program caused an error: ", getPlan().getJobId(), t); } } } finally { env.unsetAsContext(); } if (env.previewPlan != null) { previewPlan = env.previewPlan; } else { throw new ProgramInvocationException( "The program plan could not be fetched. The program silently swallowed the control flow exceptions.", getPlan().getJobId()); } } else { throw new RuntimeException(); } PlanJSONDumpGenerator jsonGen = new PlanJSONDumpGenerator(); StringWriter string = new StringWriter(1024); try (PrintWriter pw = new PrintWriter(string)) { jsonGen.dumpPactPlanAsJSON(previewPlan, pw); } return string.toString(); }
Example #12
Source File: GraphCreatingVisitor.java From flink with Apache License 2.0 | 4 votes |
public List<DataSinkNode> getSinks() { return sinks; }
Example #13
Source File: PlanJSONDumpGenerator.java From flink with Apache License 2.0 | 4 votes |
public String getPactPlanAsJSON(List<DataSinkNode> nodes) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); dumpPactPlanAsJSON(nodes, pw); return sw.toString(); }
Example #14
Source File: PlanJSONDumpGenerator.java From flink with Apache License 2.0 | 4 votes |
public void dumpPactPlanAsJSON(List<DataSinkNode> nodes, PrintWriter writer) { @SuppressWarnings("unchecked") List<DumpableNode<?>> n = (List<DumpableNode<?>>) (List<?>) nodes; compilePlanToJSON(n, writer); }
Example #15
Source File: GraphCreatingVisitor.java From flink with Apache License 2.0 | 4 votes |
public List<DataSinkNode> getSinks() { return sinks; }
Example #16
Source File: PlanJSONDumpGenerator.java From flink with Apache License 2.0 | 4 votes |
public String getPactPlanAsJSON(List<DataSinkNode> nodes) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); dumpPactPlanAsJSON(nodes, pw); return sw.toString(); }
Example #17
Source File: PlanJSONDumpGenerator.java From flink with Apache License 2.0 | 4 votes |
public void dumpPactPlanAsJSON(List<DataSinkNode> nodes, PrintWriter writer) { @SuppressWarnings("unchecked") List<DumpableNode<?>> n = (List<DumpableNode<?>>) (List<?>) nodes; compilePlanToJSON(n, writer); }
Example #18
Source File: PackagedProgram.java From flink with Apache License 2.0 | 4 votes |
/** * Returns the analyzed plan without any optimizations. * * @return * the analyzed plan without any optimizations. * @throws ProgramInvocationException Thrown if an error occurred in the * user-provided pact assembler. This may indicate * missing parameters for generation. */ public String getPreviewPlan() throws ProgramInvocationException { Thread.currentThread().setContextClassLoader(this.getUserCodeClassLoader()); List<DataSinkNode> previewPlan; if (isUsingProgramEntryPoint()) { previewPlan = Optimizer.createPreOptimizedPlan(getPlan()); } else if (isUsingInteractiveMode()) { // temporary hack to support the web client PreviewPlanEnvironment env = new PreviewPlanEnvironment(); env.setAsContext(); try { invokeInteractiveModeForExecution(); } catch (ProgramInvocationException e) { throw e; } catch (Throwable t) { // the invocation gets aborted with the preview plan if (env.previewPlan == null) { if (env.preview != null) { return env.preview; } else { throw new ProgramInvocationException("The program caused an error: ", getPlan().getJobId(), t); } } } finally { env.unsetAsContext(); } if (env.previewPlan != null) { previewPlan = env.previewPlan; } else { throw new ProgramInvocationException( "The program plan could not be fetched. The program silently swallowed the control flow exceptions.", getPlan().getJobId()); } } else { throw new RuntimeException(); } PlanJSONDumpGenerator jsonGen = new PlanJSONDumpGenerator(); StringWriter string = new StringWriter(1024); try (PrintWriter pw = new PrintWriter(string)) { jsonGen.dumpPactPlanAsJSON(previewPlan, pw); } return string.toString(); }
Example #19
Source File: GraphCreatingVisitor.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public List<DataSinkNode> getSinks() { return sinks; }
Example #20
Source File: PlanJSONDumpGenerator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public String getPactPlanAsJSON(List<DataSinkNode> nodes) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); dumpPactPlanAsJSON(nodes, pw); return sw.toString(); }
Example #21
Source File: PlanJSONDumpGenerator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public void dumpPactPlanAsJSON(List<DataSinkNode> nodes, PrintWriter writer) { @SuppressWarnings("unchecked") List<DumpableNode<?>> n = (List<DumpableNode<?>>) (List<?>) nodes; compilePlanToJSON(n, writer); }
Example #22
Source File: Optimizer.java From flink with Apache License 2.0 | 2 votes |
/** * This function performs only the first step to the compilation process - the creation of the optimizer * representation of the plan. No estimations or enumerations of alternatives are done here. * * @param program The plan to generate the optimizer representation for. * @return The optimizer representation of the plan, as a collection of all data sinks * from the plan can be traversed. */ public static List<DataSinkNode> createPreOptimizedPlan(Plan program) { GraphCreatingVisitor graphCreator = new GraphCreatingVisitor(1, null); program.accept(graphCreator); return graphCreator.getSinks(); }
Example #23
Source File: LocalExecutor.java From flink with Apache License 2.0 | 2 votes |
/** * Creates a JSON representation of the given dataflow plan. * * @param plan The dataflow plan. * @return The dataflow plan (prior to optimization) as a JSON string. */ public static String getPlanAsJSON(Plan plan) { List<DataSinkNode> sinks = Optimizer.createPreOptimizedPlan(plan); return new PlanJSONDumpGenerator().getPactPlanAsJSON(sinks); }
Example #24
Source File: Optimizer.java From flink with Apache License 2.0 | 2 votes |
/** * This function performs only the first step to the compilation process - the creation of the optimizer * representation of the plan. No estimations or enumerations of alternatives are done here. * * @param program The plan to generate the optimizer representation for. * @return The optimizer representation of the plan, as a collection of all data sinks * from the plan can be traversed. */ public static List<DataSinkNode> createPreOptimizedPlan(Plan program) { GraphCreatingVisitor graphCreator = new GraphCreatingVisitor(1, null); program.accept(graphCreator); return graphCreator.getSinks(); }
Example #25
Source File: Optimizer.java From Flink-CEPplus with Apache License 2.0 | 2 votes |
/** * This function performs only the first step to the compilation process - the creation of the optimizer * representation of the plan. No estimations or enumerations of alternatives are done here. * * @param program The plan to generate the optimizer representation for. * @return The optimizer representation of the plan, as a collection of all data sinks * from the plan can be traversed. */ public static List<DataSinkNode> createPreOptimizedPlan(Plan program) { GraphCreatingVisitor graphCreator = new GraphCreatingVisitor(1, null); program.accept(graphCreator); return graphCreator.getSinks(); }
Example #26
Source File: LocalExecutor.java From Flink-CEPplus with Apache License 2.0 | 2 votes |
/** * Creates a JSON representation of the given dataflow plan. * * @param plan The dataflow plan. * @return The dataflow plan (prior to optimization) as a JSON string. */ public static String getPlanAsJSON(Plan plan) { List<DataSinkNode> sinks = Optimizer.createPreOptimizedPlan(plan); return new PlanJSONDumpGenerator().getPactPlanAsJSON(sinks); }