private static int beginStageRegister(GraphManager gm, PronghornStage stage) { assert(gm.enableMutation): "Can not mutate graph, mutation has been disabled"; int stageId = stage.stageId; assert(stageId>=gm.stageIdToStage.length || null==gm.stageIdToStage[stageId]) : "Can only register the same stage once"; //now store the stage gm.stageIdToStage = setValue(gm.stageIdToStage, stageId, stage); gm.stageIdToInputsBeginIdx = setValue(gm.stageIdToInputsBeginIdx, stageId, gm.topInput, stage); gm.stageIdToOutputsBeginIdx = setValue(gm.stageIdToOutputsBeginIdx, stageId, gm.topOutput, stage); gm.stageIdToNotasBeginIdx = setValue(gm.stageIdToNotasBeginIdx, stageId, gm.topNota, stage); gm.stageRunNS = setValue(gm.stageRunNS, stageId, 0); gm.stageShutdownTimeNs = setValue(gm.stageShutdownTimeNs, stageId, 0); gm.stageStartTimeNs = setValue(gm.stageStartTimeNs, stageId, 0); gm.stageLastTimeNs = setValue(gm.stageLastTimeNs, stageId, 0); gm.stageWrkPct = setValue(gm.stageWrkPct, stageId, 0); //add defaults if a value is not already present int d = gm.defaultsCount; while(--d >= 0) { //stage does not have the default value so set it GraphManager.addNota(gm, gm.defaultNotaKeys[d], gm.defaultNotaValues[d], stage); } return stageId; }
private static void setStateToNew(GraphManager gm, int stageId) { synchronized(gm.stageStateData.lock) { gm.stageStateData.stageStateArray = setValue(stageStateArray(gm), stageId, GraphManagerStageStateData.STAGE_NEW); } }
public static void setStateToStopping(GraphManager gm, int stageId) { synchronized(gm.stageStateData.lock) { gm.stageStateData.stageStateArray = setValue(stageStateArray(gm), stageId, GraphManagerStageStateData.STAGE_STOPPING); } }
public static void setStateToStarted(GraphManager gm, int stageId) { synchronized(gm.stageStateData.lock) { gm.stageStateData.stageStateArray = setValue(stageStateArray(gm), stageId, GraphManagerStageStateData.STAGE_STARTED); gm.stageStartTimeNs[stageId] = System.nanoTime(); } }
public static void setStateToShutdown(GraphManager gm, int stageId) { synchronized(gm.stageStateData.lock) { gm.stageStateData.stageStateArray = setValue(stageStateArray(gm), stageId, GraphManagerStageStateData.STAGE_TERMINATED); // assert(recordInputsAndOutputValuesForValidation(gm, stage.stageId)); gm.stageShutdownTimeNs[stageId] = System.nanoTime(); } }
private static void regOutput(GraphManager gm, Pipe output, int stageId) { if (null!=output) { int outputId = output.id; Pipe.structRegistry(output,gm.recordTypeData); try { gm.ringIdToStages = setValue(gm.ringIdToStages, (outputId*2) , stageId, gm.stageIdToStage[stageId]); //source +0 then target +1 gm.pipeIdToPipe = setValue(gm.pipeIdToPipe, outputId, output); gm.multOutputIds = setValue(gm.multOutputIds, gm.topOutput++, outputId, output); } catch (UnsupportedOperationException uoe) { output.creationStack(); logger.info("\nRegister: "+output); throw uoe; } assert(stageId == getRingProducerId(gm, outputId)); } }
private static void regInput(GraphManager gm, Pipe input, int stageId) { if (null!=input) { int inputId = input.id; Pipe.structRegistry(input,gm.recordTypeData); try { gm.ringIdToStages = setValue(gm.ringIdToStages, (inputId*2)+1, stageId, gm.stageIdToStage[stageId]); //source +0 then target +1 gm.pipeIdToPipe = setValue(gm.pipeIdToPipe, inputId, input); gm.multInputIds = setValue(gm.multInputIds, gm.topInput++, inputId, input); } catch (UnsupportedOperationException uoe) { input.creationStack(); logger.info("\nRegister: "+input); throw uoe; } assert(stageId == getRingConsumerId(gm, inputId)); } }