@Override public void executeGraph(Graph graph, GraphProcessingObserver observer) throws GraphException { GraphProcessor processor = new GraphProcessor(); if (observer != null) { processor.addObserver(observer); } processor.executeGraph(graph, ProgressMonitor.NULL); }
fireProcessingStarted(graphContext); Map<Dimension, List<NodeContext>> tileDimMap = buildTileDimensionMap(outputNodeContexts); tileSize.width, tileSize.height); fireTileStarted(graphContext, tileRectangle); for (NodeContext nodeContext : nodeContextList) { Product targetProduct = nodeContext.getTargetProduct(); PlanarImage image = nodeContext.getTargetImage(band); if (image != null) { forceTileComputation(image, tileX, tileY, semaphore, tileScheduler, listeners, parallelism); break; if (image == null) { if (OperatorContext.isRegularBand(band) && band.isSourceImageSet()) { forceTileComputation(band.getSourceImage(), tileX, tileY, semaphore, tileScheduler, listeners, parallelism); PlanarImage image = nodeContext.getTargetImage(band); if (image != null) { forceTileComputation(image, tileX, tileY, semaphore, tileScheduler, listeners, parallelism); } else if (OperatorContext.isRegularBand(band) && band.isSourceImageSet()) { forceTileComputation(band.getSourceImage(), tileX, tileY, semaphore, tileScheduler, listeners, parallelism);
@SuppressWarnings("null") public void testTwoOpsExecutionOrder() throws Exception { GraphProcessor processor = new GraphProcessor(); Graph graph = new Graph("chain1"); Node node1 = new Node("node1", "Op1"); Node node2 = new Node("node2", "Op2"); node2.addSource(new NodeSource("input", "node1")); graph.addNode(node1); graph.addNode(node2); GraphContext graphContext = new GraphContext(graph); Product chainOut = processor.executeGraph(graphContext, ProgressMonitor.NULL)[0]; assertNotNull(chainOut); assertEquals("Op2Name", chainOut.getName()); assertEquals("Op1;Op2;", TestOps.getCalls()); TestOps.clearCalls(); }
public void testAddingOberserverToChain() throws GraphException { GraphProcessor processor = new GraphProcessor(); GraphProcessingObserver[] observers = processor.getObservers(); assertNotNull(observers); assertEquals(0, observers.length); GraphProcessingObserverMock observerMock = new GraphProcessingObserverMock(); processor.addObserver(observerMock); observers = processor.getObservers(); assertNotNull(observers); assertEquals(1, observers.length); assertSame(observerMock, observers[0]); Graph graph = new Graph("test-graph"); graph.addNode(new Node("a", OpMock.Spi.class.getName())); processor.executeGraph(graph, ProgressMonitor.NULL); assertEquals(6, observerMock.entries.size()); assertEquals("graph [test-graph] started", observerMock.entries.get(0)); assertEquals("tile java.awt.Rectangle[x=0,y=0,width=10,height=5] started", observerMock.entries.get(1)); assertEquals("tile java.awt.Rectangle[x=0,y=0,width=10,height=5] stopped", observerMock.entries.get(2)); assertEquals("tile java.awt.Rectangle[x=0,y=5,width=10,height=5] started", observerMock.entries.get(3)); assertEquals("tile java.awt.Rectangle[x=0,y=5,width=10,height=5] stopped", observerMock.entries.get(4)); assertEquals("graph [test-graph] stopped", observerMock.entries.get(5)); }
assertEquals("Op2", bazNode.getOperatorName()); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = null; try {
/** * Executes the graph using a new default {@link GraphContext}. * * @param graph the {@link Graph} * @param pm a progress monitor. Can be used to signal progress. * * @throws GraphException if any error occurs during execution * @see GraphProcessor#executeGraph(GraphContext, com.bc.ceres.core.ProgressMonitor) */ public void executeGraph(Graph graph, ProgressMonitor pm) throws GraphException { GraphContext graphContext; try { pm.beginTask("Executing processing graph", 100); graphContext = new GraphContext(graph); executeGraph(graphContext, SubProgressMonitor.create(pm, 90)); graphContext.dispose(); } finally { pm.done(); } }
private void forceTileComputation(PlanarImage image, int tileX, int tileY, Semaphore semaphore, TileScheduler tileScheduler, TileComputationListener[] listeners, int parallelism) { Point[] points = new Point[]{new Point(tileX, tileY)}; acquirePermits(semaphore, 1); if (error != null) { semaphore.release(parallelism); throw error; } ///////////////////////////////////////////////////////////////////// // // Note: GPF pull-processing is triggered here!!! // tileScheduler.scheduleTiles(image, points, listeners); // ///////////////////////////////////////////////////////////////////// }
graph.addNode(node2); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = new GraphContext(graph); Product[] targetProducts = processor.executeGraph(graphContext, ProgressMonitor.NULL);
assertEquals("Op4", bertNode.getOperatorName()); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = null; try {
Graph graph = GraphIO.read(reader); GraphProcessor processor = new GraphProcessor(); processor.executeGraph(graph, ProgressMonitor.NULL);
assertEquals("baz", sources3[1].getSourceNodeId()); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = null; try {
graph.addNode(node3); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = new GraphContext(graph); Product[] targetProducts = processor.executeGraph(graphContext, ProgressMonitor.NULL);
public void testThreeOpsExecutionOrder() throws Exception { VerbousTileCache.setVerbous(false); Graph graph = new Graph("graph"); Node node1 = new Node("node1", "Op1"); Node node2 = new Node("node2", "Op2"); Node node3 = new Node("node3", "Op3"); node2.addSource(new NodeSource("input", "node1")); node3.addSource(new NodeSource("input1", "node1")); node3.addSource(new NodeSource("input2", "node2")); graph.addNode(node1); graph.addNode(node2); graph.addNode(node3); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = new GraphContext(graph); Product chainOut = graphContext.getOutputProducts()[0]; assertNotNull(chainOut); assertEquals("Op3Name", chainOut.getName()); processor.executeGraph(graphContext, ProgressMonitor.NULL); // - Op3 requires the two bands of Op2 // - Op2 computes all bands // --> Op2 should only be called once assertEquals("Op1;Op2;Op3;", TestOps.getCalls()); TestOps.clearCalls(); VerbousTileCache.setVerbous(false); }
Graph graph = GraphIO.read(reader); GraphProcessor processor = new GraphProcessor(); processor.executeGraph(graph, ProgressMonitor.NULL);
graph.addNode(node6); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = new GraphContext(graph); Product[] outputProducts = processor.executeGraph(graphContext, ProgressMonitor.NULL);
graph.addNode(node5); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = new GraphContext(graph); Product[] outputProducts = processor.executeGraph(graphContext, ProgressMonitor.NULL);