private void distribute(Distribution[] distributionList, int iterationNum) {
        Distribution[] busy = null; //*TODO CONSIDER USE LIST WITH INITIAL CAP SIZE
        for (int inc = 0; inc < distributionList.length; inc++) {
            if (distributionList[inc] == null)
                continue;
            if (!distributionList[inc].getiStepDecorator().offerQueueSubjectUpdate(distributionList[inc].getData(), distributionList[inc].getSubject())) {
                if (busy == null) {
                    busy = new Distribution[distributionList.length];
                }
                busy[inc] = distributionList[inc];
                logger.debug("Distribution not succeeded. Moving to Deceleration Mode for Subject: "  + busy[inc].getSubject() + ". Iteration number - " + iterationNum + "/" + MAXIMUM_OFFERS_RETRIES);
            }
        }
        if (!isEmpty(busy)) {
            //* ***** Deceleration Mode *****
            if (iterationNum >= MAXIMUM_OFFERS_RETRIES) {
                logger.debug("Deceleration Mode failed after " + iterationNum + "/" + MAXIMUM_OFFERS_RETRIES + " retries. Moving back to normal distribution");
                for (Distribution dist : distributionList) {
                    if (dist == null)
                        continue;
                    dist.getiStepDecorator().queueSubjectUpdate(dist.getData(), dist.getSubject());
                }
            }
            try {
                logger.debug("Retarding the distribution for " + WAIT_PERIOD_MILLI * iterationNum + " milliseconds");
                Thread.sleep(WAIT_PERIOD_MILLI * iterationNum);
            } catch (InterruptedException e) {
                throw new SteppingSystemException("Distribution timeout failed");
            }
            distribute(busy, ++iterationNum);
        }
    }
private void distribute(Distribution[] distributionList, int iterationNum) {
        Distribution[] busy = null;
        for (int inc = 0; inc < distributionList.length; inc++) {
            if (distributionList[inc] == null)
                continue;
            if (!distributionList[inc].getiStepDecorator().offerQueueSubjectUpdate(distributionList[inc].getData(), distributionList[inc].getSubject())) {
                if (busy == null) {
                    busy = new Distribution[distributionList.length];
                }
                busy[inc] = distributionList[inc];
                logger.debug("Distribution not succeeded. Moving to Deceleration Mode for Subject: "  + busy[inc].getSubject() + ". Iteration number - " + iterationNum + "/" + MAXIMUM_OFFERS_RETRIES);
            }
        }
        if (!isEmpty(busy)) {
           
            if (iterationNum >= MAXIMUM_OFFERS_RETRIES) {
                logger.debug("Deceleration Mode failed after " + iterationNum + "/" + MAXIMUM_OFFERS_RETRIES + " retries. Moving back to normal distribution");
                for (Distribution dist : distributionList) {
                    if (dist == null)
                        continue;
                    dist.getiStepDecorator().queueSubjectUpdate(dist.getData(), dist.getSubject());
                }
            }
            try {
                logger.debug("Retarding the distribution for " + WAIT_PERIOD_MILLI * iterationNum + " milliseconds");
                Thread.sleep(WAIT_PERIOD_MILLI * iterationNum);
            } catch (InterruptedException e) {
                throw new SteppingSystemException("Distribution timeout failed");
            }
            distribute(busy, ++iterationNum);
        }
    }
private void distribute(distribution[] distributionlist, int iterationnum) { distribution[] busy = null; for (int inc = 0; inc < distributionlist.length; inc++) { if (distributionlist[inc] == null) continue; if (!distributionlist[inc].getistepdecorator().offerqueuesubjectupdate(distributionlist[inc].getdata(), distributionlist[inc].getsubject())) { if (busy == null) { busy = new distribution[distributionlist.length]; } busy[inc] = distributionlist[inc]; logger.debug("distribution not succeeded. moving to deceleration mode for subject: " + busy[inc].getsubject() + ". iteration number - " + iterationnum + "/" + maximum_offers_retries); } } if (!isempty(busy)) { if (iterationnum >= maximum_offers_retries) { logger.debug("deceleration mode failed after " + iterationnum + "/" + maximum_offers_retries + " retries. moving back to normal distribution"); for (distribution dist : distributionlist) { if (dist == null) continue; dist.getistepdecorator().queuesubjectupdate(dist.getdata(), dist.getsubject()); } } try { logger.debug("retarding the distribution for " + wait_period_milli * iterationnum + " milliseconds"); thread.sleep(wait_period_milli * iterationnum); } catch (interruptedexception e) { throw new steppingsystemexception("distribution timeout failed"); } distribute(busy, ++iterationnum); } }