@Override public void afterPropertiesSet() throws Exception { flow = createFlow(); if (skipStrategy != null) { flow.setFlowSkipStrategy(skipStrategy); } if (stepStrategy != null) { flow.setFlowStepStrategy(stepStrategy); } if (listeners != null) { for (FlowListener listener : listeners) { flow.addListener(listener); } } if (StringUtils.hasText(writeDOT)) { flow.writeDOT(writeDOT); } if (StringUtils.hasText(writeStepsDOT)) { flow.writeStepsDOT(writeStepsDOT); } if (priority != null) { flow.setSubmitPriority(priority); } }
@Test public void testSkipStrategiesReplace() throws Exception { getPlatform().copyFromLocal( inputFileApache ); Tap source = getPlatform().getTextFile( inputFileApache ); // !!! enable replace Tap sink = getPlatform().getTextFile( getOutputPath( "replace" ), SinkMode.REPLACE ); Pipe pipe = new Pipe( "test" ); pipe = new Each( pipe, new Fields( "line" ), new RegexParser( new Fields( "ip" ), "^[^ ]*" ), new Fields( "ip" ) ); Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe ); sink.deleteResource( flow.getConfig() ); assertTrue( "default skip", !flow.getFlowSkipStrategy().skipFlow( flow ) ); assertTrue( "exist skip", !new FlowSkipIfSinkExists().skipFlow( flow ) ); flow.complete(); assertTrue( "default skip", !flow.getFlowSkipStrategy().skipFlow( flow ) ); assertTrue( "exist skip", !new FlowSkipIfSinkExists().skipFlow( flow ) ); FlowSkipStrategy old = flow.getFlowSkipStrategy(); FlowSkipStrategy replaced = flow.setFlowSkipStrategy( new FlowSkipIfSinkExists() ); assertTrue( "not same instance", old == replaced ); validateLength( flow.openSource(), 10 ); // validate source, this once, as a sanity check validateLength( flow, 10, null ); }
@Test public void testSkipStrategiesReplace() throws Exception { getPlatform().copyFromLocal( inputFileApache ); Tap source = getPlatform().getTextFile( inputFileApache ); // !!! enable replace Tap sink = getPlatform().getTextFile( getOutputPath( "replace" ), SinkMode.REPLACE ); Pipe pipe = new Pipe( "test" ); pipe = new Each( pipe, new Fields( "line" ), new RegexParser( new Fields( "ip" ), "^[^ ]*" ), new Fields( "ip" ) ); Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe ); sink.deleteResource( flow.getConfig() ); assertTrue( "default skip", !flow.getFlowSkipStrategy().skipFlow( flow ) ); assertTrue( "exist skip", !new FlowSkipIfSinkExists().skipFlow( flow ) ); flow.complete(); assertTrue( "default skip", !flow.getFlowSkipStrategy().skipFlow( flow ) ); assertTrue( "exist skip", !new FlowSkipIfSinkExists().skipFlow( flow ) ); FlowSkipStrategy old = flow.getFlowSkipStrategy(); FlowSkipStrategy replaced = flow.setFlowSkipStrategy( new FlowSkipIfSinkExists() ); assertTrue( "not same instance", old == replaced ); validateLength( flow.openSource(), 10 ); // validate source, this once, as a sanity check validateLength( flow, 10, null ); }
secondFlow.setFlowSkipStrategy( skipStrategy );
secondFlow.setFlowSkipStrategy( skipStrategy );