private static int[] buildProducersList(int count, int idx, final GraphManager graphManager, PronghornStage[] stages) { //skip over the non producers while (idx<stages.length) { if (null!=GraphManager.getNota(graphManager, stages[idx].stageId, GraphManager.PRODUCER, null) || (0==GraphManager.getInputPipeCount(graphManager, stages[idx])) ) { int[] result = buildProducersList(count+1, idx+1, graphManager, stages); result[count] = idx; return result; } idx++; } return new int[count]; }
@Override public void startup() { shutdownRequested = new AtomicBoolean(false); final int stageCount = stages.length; //TODO: we need to re-order the stages to ensure we run these in order? This will be important. //System.err.println("beging stage startup "+this.hashCode()); startupAllStages(stageCount); //System.err.println("done stage startup "+this.hashCode()); int i; producersIdx = buildProducersList(0, 0, graphManager, stages); producerInputPipes = buildProducersPipes(0, 0, 1, producersIdx, stages, graphManager); producerInputPipeHeads = new long[producerInputPipes.length]; inputPipes = buildInputPipes(0, 0, 1, stages, graphManager); inputPipeHeads = new long[inputPipes.length]; syncInputHeadValues(producerInputPipes, producerInputPipeHeads); syncInputHeadValues(inputPipes, inputPipeHeads); internalPipes = buildInternalPipes(0, 0, 1, stages, graphManager); }