public void setTarget(GraphManager graphManager, int stageId) { target = stageId; detected = false; if (null!=GraphManager.getNota(graphManager, stageId, GraphManager.PRODUCER, null)) { producerStageId = stageId; } else { producerStageId = -1; } }
@Override public boolean visit(GraphManager graphManager, int stageId, int depth) { if (null!=GraphManager.getNota(graphManager, stageId, GraphManager.PRODUCER, null)) { producerStageId = stageId; } detected |= (stageId == target); return !detected;//keep going if not found }
/** * Returns nota if one is found by this key on this stage, if nota is not found it returns the defaultValue * @param m * @param stage * @param key */ public static Object getNota(GraphManager m, PronghornStage stage, Object key, Object defaultValue) { return (null==stage) ? defaultValue : getNota(m, stage.stageId, key, defaultValue); }
private static boolean stageForMonitorData(GraphManager gm, PronghornStage stage) { if (!monitorAll) { return null != GraphManager.getNota(gm, stage, GraphManager.MONITOR, null); } return false; }
public static boolean hasNota(GraphManager m, int stageId, Object key) { return (null != getNota(m, stageId, key, null)); }
public static int countStagesWithNotaKey(GraphManager m, Object key) { int count = 0; int i = m.stageIdToStage.length; while (--i>=0) { PronghornStage stage = m.stageIdToStage[i]; if (null!=stage) { //count this stage if it has the required key if (null != getNota(m, stage, key, null)) { count++; } } } return count; }
public static PronghornStage getStageWithNotaKey(GraphManager m, Object key, int ordinal) { int i = m.stageIdToStage.length; while (--i>=0) { PronghornStage stage = m.stageIdToStage[i]; if (null!=stage) { //count this stage if it has the required key if (null != getNota(m, stage, key, null)) { if (--ordinal<=0) { return stage; } } } } throw new UnsupportedOperationException("Invalid configuration. Unable to find requested ordinal "+ordinal); }
@Override public void startup() { final Number rate = (Number)GraphManager.getNota(graphManager, this, GraphManager.SCHEDULE_RATE, null); this.maxBatchCount = Math.max(1, ( null==rate ? 16 : (int)(hardLimtNS/rate.longValue()))); //logger.info("server socket write batch count "+maxBatchCount+" cycle rate "+rate.longValue()); // 100_000; int c = input.length; writeToChannel = new SocketChannel[c]; writeToChannelId = new long[c]; writeToChannelMsg = new int[c]; writeToChannelBatchCountDown = new int[c]; workingBuffers = new ByteBuffer[c]; bufferChecked = new boolean[c]; activeTails = new long[c]; activeIds = new long[c]; activeMessageIds = new int[c]; Arrays.fill(activeTails, -1); }
@Override public void startup() { //processing can be very time critical so this thread needs to be on of the highest in priority. Thread.currentThread().setPriority(Thread.MAX_PRIORITY); connectionBlocker = new Blocker(MAX_DEVICES); activeCounts = new int[goPipe.length]; activeBlocks = new int[MAX_DEVICES]; Arrays.fill(activeCounts, -1); //0 indicates, need to ack, -1 indicates done and ready for more Arrays.fill(activeBlocks, -1); startLoopAt = activeCounts.length; rate = (Number)graphManager.getNota(graphManager, this.stageId, GraphManager.SCHEDULE_RATE, null); }
private static void populateRanks(GraphManager m, Map<Object, StringBuilder> ranks, PronghornStage stage, String stageId) { if (ranks!=null && m.cachedRanks==null) { //thes rank keys are cached Object rankKey = getNota(m, stage.stageId, GraphManager.DOT_RANK_NAME, null); if (rankKey!=null) { //{ rank=same, b, c, d } StringBuilder b = ranks.get(rankKey); if (null==b) { b = new StringBuilder("{ rank=same"); ranks.put(rankKey, b); } b.append(" \"").append(stageId).append("\","); } } }
@Override public void startup() { //selectedKeyHolder = new SelectedKeyHashMapHolder(); start = System.currentTimeMillis(); Number schedRate = ((Number)GraphManager.getNota(graphManger, this, GraphManager.SCHEDULE_RATE, new Long(-1))); long minimumTimeout = ClientCoordinator.minimumTimeout(); if (minimumTimeout < Long.MAX_VALUE && minimumTimeout>=0) { rateMask = (1 << (int)(Math.log((int)( minimumTimeout / schedRate.longValue() ))/Math.log(2)))-1; } else { rateMask = 0xFFF; } }
public String toString() { if (null == nameCache) { nameCache = Appendables.appendValue(new StringBuilder().append( GraphManager.getNota(graphManager, stageId, GraphManager.STAGE_NAME, getClass().getSimpleName()) ), "#", stageId).toString(); } return nameCache; }
private static byte[] buildStageDOTRate(GraphManager m, PronghornStage stage) { Object rate = getNota(m, stage.stageId, GraphManager.SCHEDULE_RATE, null); if (null!=rate) { StringBuilder builder = new StringBuilder(); builder.append("\n Rate:"); Appendables.appendNearestTimeUnit(builder, ((Number)rate).longValue()); return m.stageDOTRate[stage.stageId] = builder.toString().getBytes(); } return null; }
private static boolean ringHoldsMonitorData(GraphManager gm, Pipe ringBuffer) { if (!monitorAll) { return null != GraphManager.getNota(gm, GraphManager.getRingProducerStageId(gm, ringBuffer.id), GraphManager.MONITOR, null); } return false; }
private static byte[] buldStageDOTName(GraphManager m, PronghornStage stage) { //TODO: re-visit to eliminate GC. String stageDisplayName = stage.toString() .replace("Stage","").trim() .replace(" ", "\n")+"\n"; if (showThreadIdOnTelemetry) { Object group = GraphManager.getNota(m, stage.stageId, GraphManager.THREAD_GROUP, null); if (null!=group) { stageDisplayName+=(" Thread:"+group.toString()+"\n"); } } return m.stageDOTNames[stage.stageId] = stageDisplayName.getBytes(); }
protected void logStageScheduleRates() { int totalStages = GraphManager.countStages(gm); for(int i=1;i<=totalStages;i++) { PronghornStage s = GraphManager.getStage(gm, i); if (null != s) { Object rate = GraphManager.getNota(gm, i, GraphManager.SCHEDULE_RATE, null); if (null == rate) { logger.debug("{} is running without breaks",s); } else { logger.debug("{} is running at rate of {}",s,rate); } } } }
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]; }
public static void terminateInputStages(GraphManager m) { int i = m.stageIdToStage.length; while (--i>=0) { if (null!=m.stageIdToStage[i]) { //an input stage is one that has no input ring buffers if (-1 == m.multInputIds[m.stageIdToInputsBeginIdx[m.stageIdToStage[i].stageId]]) { //terminate all stages without any inputs m.stageIdToStage[i].requestShutdown(); } else if (null != getNota(m, m.stageIdToStage[i], PRODUCER, null)) { //also terminate all stages decorated as producers m.stageIdToStage[i].requestShutdown(); //producers with inputs must be forced to terminate or the input queue will prevent shutdown setStateToShutdown(m, m.stageIdToStage[i].stageId); } } } }
public static GraphManager cloneStagesWithNotaKeyValue(GraphManager m, Object key, Object value) { GraphManager clone = new GraphManager( new GraphManagerStageStateData(), m.recordTypeData, m.name); //register each stage int i = m.stageIdToStage.length; while (--i>=0) { PronghornStage stage = m.stageIdToStage[i]; if (null!=stage) { //copy this stage if it has the required key if (value.equals(getNota(m, stage, key, null))) { copyStage(m, clone, stage); copyNotasForStage(m, clone, stage); } } } return clone; }
public static GraphManager cloneStagesWithNotaKey(GraphManager m, Object key) { GraphManager clone = new GraphManager( new GraphManagerStageStateData(), m.recordTypeData, m.name); //register each stage int i = m.stageIdToStage.length; while (--i>=0) { PronghornStage stage = m.stageIdToStage[i]; if (null!=stage) { //copy this stage if it has the required key if (m != getNota(m, stage, key, m)) { copyStage(m, clone, stage); copyNotasForStage(m, clone, stage); } } } return clone; }