private void logPhase( ProcessLogger logger, boolean logAsInfo, String message, Object... items ) { if( logAsInfo ) logger.logInfo( message, items ); else logger.logDebug( message, items ); }
@Override public void logInfo( String message, Object... arguments ) { getLogger().logInfo( message, arguments ); }
@Override public void logInfo( String message, Object... arguments ) { getLogger().logInfo( message, arguments ); }
public void writeTracePlan( String registryName, String fileName, FlowStepGraph stepGraph ) { Path path = getPlanTracePath(); if( path == null ) return; if( stepGraph == null ) { processLogger.logInfo( "cannot write step plan, stepGraph is null" ); return; } if( registryName != null ) path = path.resolve( registryName ); Path filePath = path.resolve( String.format( "%s.dot", fileName ) ); File file = filePath.toFile(); processLogger.logInfo( "writing trace step plan: {}", file ); stepGraph.writeDOT( file.toString() ); }
public void writeTransformPlan( String registryName, FlowElementGraph flowElementGraph, String name ) { if( isTransformTraceDisabled() ) return; if( flowElementGraph == null ) { processLogger.logInfo( "cannot write phase assembly trace, flowElementGraph is null" ); return; } Path file = getFullTransformTracePath( registryName ).resolve( name ).normalize(); processLogger.logInfo( "writing phase assembly trace: {}, to: {}", name, file ); flowElementGraph.writeDOT( file.toString() ); }
public void writeTracePlanSteps( String directoryName, FlowStepGraph stepGraph ) { if( stepGraph == null ) { processLogger.logInfo( "cannot write trace step plan, stepGraph is null" ); return; } Iterator<FlowStep> iterator = stepGraph.getTopologicalIterator(); while( iterator.hasNext() ) writePlan( iterator.next(), directoryName ); }
public void writeTracePlan( String registryName, String fileName, ElementGraph elementGraph ) { Path path = getPlanTracePath(); if( path == null ) return; if( elementGraph == null ) { processLogger.logInfo( "cannot write trace element plan, elementGraph is null" ); return; } if( registryName != null ) path = path.resolve( registryName ); Path filePath = path.resolve( String.format( "%s-%s.dot", fileName, canonicalHash( elementGraph ) ) ); File file = filePath.toFile(); processLogger.logInfo( "writing trace element plan: {}", file ); String filename = file.toString(); elementGraph.writeDOT( filename ); }
public void writeTransformPlan( String registryName, List<? extends ElementGraph> flowElementGraphs, PlanPhase phase, String subName ) { if( isTransformTraceDisabled() ) return; if( flowElementGraphs == null || flowElementGraphs.isEmpty() ) { processLogger.logInfo( "cannot write phase step trace, flowElementGraphs is empty" ); return; } for( int i = 0; i < flowElementGraphs.size(); i++ ) { ElementGraph flowElementGraph = flowElementGraphs.get( i ); String name = String.format( "%02d-%s-%s-%04d.dot", phase.ordinal(), phase, subName, i ); Path file = getFullTransformTracePath( registryName ).resolve( name ).normalize(); processLogger.logInfo( "writing phase step trace: {}, to: {}", name, file ); flowElementGraph.writeDOT( file.toString() ); } }
protected void logInfo( String message, Object... arguments ) { getProcessLogger().logInfo( getPrefix() + message, arguments ); }
public void writeTransformPlan( String registryName, Map<ElementGraph, List<? extends ElementGraph>> subGraphsMap, PlanPhase phase, String subName ) { if( isTransformTraceDisabled() ) return; if( subGraphsMap == null || subGraphsMap.isEmpty() ) { processLogger.logInfo( "cannot write phase node trace, subGraphs is empty" ); return; } int stepCount = 0; for( Map.Entry<ElementGraph, List<? extends ElementGraph>> entry : subGraphsMap.entrySet() ) { List<? extends ElementGraph> flowElementGraphs = entry.getValue(); for( int i = 0; i < flowElementGraphs.size(); i++ ) { ElementGraph flowElementGraph = flowElementGraphs.get( i ); String name = String.format( "%02d-%s-%s-%04d-%04d.dot", phase.ordinal(), phase, subName, stepCount, i ); Path file = getFullTransformTracePath( registryName ).resolve( name ); processLogger.logInfo( "writing phase node trace: {}, to: {}", name, file ); flowElementGraph.writeDOT( file.toString() ); } stepCount++; } }
public void writeFinal( String fileName, RuleResult ruleResult ) { Path path = getPlanTracePath(); if( path == null ) return; Path filePath = path.resolve( String.format( "%s-%s.txt", fileName, ruleResult.getRegistry().getName() ) ); File file = filePath.toFile(); processLogger.logInfo( "writing final registry: {}", file ); try( PrintWriter writer = new PrintWriter( file ) ) { writer.println( "filename names winning rule registry" ); } catch( IOException exception ) { processLogger.logError( "could not write final registry", exception ); } }
private void notifyUnsupported() { if( unsupported.isEmpty() ) return; for( RuleResult ruleResult : unsupported ) getFlowLogger().logInfo( "rule registry: {}, does not support assembly", ruleResult.getRegistry().getName() ); if( !registrySet.isIgnoreFailed() || success.isEmpty() && illegal.isEmpty() && interrupted.isEmpty() ) rethrow( unsupported.get( 0 ).getPlannerException() ); }
private void notifyIllegal() { if( illegal.isEmpty() ) return; for( RuleResult ruleResult : illegal ) getFlowLogger().logInfo( "rule registry: {}, found assembly to be malformed", ruleResult.getRegistry().getName() ); if( !registrySet.isIgnoreFailed() || success.isEmpty() ) rethrow( illegal.get( 0 ).getPlannerException() ); }
private RuleResult selectSuccess() { if( success.isEmpty() ) throw new IllegalStateException( "no planner results from registry set" ); for( RuleResult ruleResult : success ) getFlowLogger().logInfo( "rule registry: {}, supports assembly with steps: {}, nodes: {}", ruleResult.getRegistry().getName(), ruleResult.getNumSteps(), ruleResult.getNumNodes() ); if( success.size() != 1 ) { // sort is stable Collections.sort( success, getOrderComparator() ); Collections.sort( success, getPlanComparator() ); } RuleResult ruleResult = success.get( 0 ); if( registrySet.getSelect() == RuleRegistrySet.Select.FIRST ) getFlowLogger().logInfo( "rule registry: {}, result was selected as first successful", ruleResult.getRegistry().getName() ); else if( registrySet.getSelect() == RuleRegistrySet.Select.COMPARED ) getFlowLogger().logInfo( "rule registry: {}, result was selected using: \'{}\'", ruleResult.getRegistry().getName(), getPlanComparator().toString() ); return ruleResult; }
private void notifyInterrupted() { if( interrupted.isEmpty() ) return; for( RuleResult ruleResult : interrupted ) getFlowLogger().logInfo( "rule registry: {}, planned longer than default duration, was cancelled", ruleResult.getRegistry().getName() ); if( interrupted.size() == registrySet.size() ) throw new PlannerException( "planner registry timeout exceeded for all registries: " + formatDurationFromMillis( registrySet.getPlannerTimeoutSec() * 1000 ) ); if( !registrySet.isIgnoreFailed() || success.isEmpty() ) rethrow( interrupted.get( 0 ).getPlannerException() ); }
public void writeStats( PlannerContext plannerContext, RuleResult ruleResult ) { Path path = getPlanStatsPath(); if( path == null ) return; File file = path.resolve( String.format( "planner-stats-%s-%s.txt", ruleResult.getRegistry().getName(), ruleResult.getResultStatus() ) ).toFile(); processLogger.logInfo( "writing planner stats to: {}", file ); file.getParentFile().mkdirs(); try( PrintWriter writer = new PrintWriter( file ) ) { Flow flow = plannerContext.getFlow(); Map<Object, Object> configAsProperties = flow.getConfigAsProperties(); writer.format( "cascading version: %s, build: %s\n", emptyOrValue( Version.getReleaseFull() ), emptyOrValue( Version.getReleaseBuild() ) ); writer.format( "application id: %s\n", emptyOrValue( AppProps.getApplicationID( configAsProperties ) ) ); writer.format( "application name: %s\n", emptyOrValue( AppProps.getApplicationName( configAsProperties ) ) ); writer.format( "application version: %s\n", emptyOrValue( AppProps.getApplicationVersion( configAsProperties ) ) ); writer.format( "platform: %s\n", emptyOrValue( flow.getPlatformInfo() ) ); writer.format( "frameworks: %s\n", emptyOrValue( AppProps.getApplicationFrameworks( configAsProperties ) ) ); writer.println(); ruleResult.writeStats( writer ); } catch( IOException exception ) { processLogger.logError( "could not write stats", exception ); } }
processLogger.logInfo( "!!! transform recursion ending, reached depth: {}", currentDepth ); return graph;
public RuleResult exec( PlannerContext plannerContext, FlowElementGraph flowElementGraph ) { RuleResult ruleResult = new RuleResult( registry, flowElementGraph ); ProcessLogger logger = plannerContext.getLogger(); int size = flowElementGraph.vertexSet().size(); boolean logAsInfo = size >= ELEMENT_THRESHOLD; if( logAsInfo ) logger.logInfo( "elements in graph: {}, info logging threshold: {}, logging planner execution status", size, ELEMENT_THRESHOLD ); long beginExec = System.currentTimeMillis(); try { planPhases( plannerContext, logAsInfo, ruleResult ); } catch( Exception exception ) { ruleResult.setPlannerException( exception ); } finally { long endExec = System.currentTimeMillis(); ruleResult.setDuration( beginExec, endExec ); RuleResult.ResultStatus status = ruleResult.getResultStatus(); String duration = formatDurationFromMillis( endExec - beginExec ); logPhase( logger, logAsInfo, "rule registry completed: {}, with status: {}, and duration: {}", registry.getName(), status, duration ); } return ruleResult; }
protected RuleResult execPlannerFor( RuleRegistry ruleRegistry ) { flowPlanner.configRuleRegistryDefaults( ruleRegistry ); String registryName = ruleRegistry.getName(); RuleExec ruleExec = new RuleExec( traceWriter, ruleRegistry ); PlannerContext plannerContext = new PlannerContext( ruleRegistry, flowPlanner, flowDef, flow, traceWriter.isTransformTraceEnabled() ); RuleResult ruleResult = ruleExec.exec( plannerContext, flowElementGraph ); getFlowLogger().logInfo( "executed rule registry: {}, completed as: {}, in: {}", registryName, ruleResult.getResultStatus(), formatDurationFromMillis( ruleResult.getDuration() ) ); traceWriter.writeTracePlan( registryName, "completed-flow-element-graph", ruleResult.getAssemblyGraph() ); traceWriter.writeStats( plannerContext, ruleResult ); Exception plannerException; if( ruleResult.isSuccess() ) plannerException = flowPlanner.verifyResult( ruleResult ); else plannerException = ruleResult.getPlannerException(); // will be re-thrown below if( plannerException != null && plannerException instanceof PlannerException && ( (PlannerException) plannerException ).getElementGraph() != null ) traceWriter.writeTracePlan( registryName, "failed-source-element-graph", ( (PlannerException) plannerException ).getElementGraph() ); if( ruleResult.isSuccess() && plannerException != null ) rethrow( plannerException ); return ruleResult; }