/** * Returns disk bandwidth associated with this plan, if none is specified * returns the global default. * * @param item DiskBalancerWorkItem. * @return MB/s - long */ private long getDiskBandwidth(DiskBalancerWorkItem item) { return item.getBandwidth() <= 0 ? this.diskBandwidth : item .getBandwidth(); }
/** * Inflates bytesCopied and returns true or false. This allows us to stop * copying if we have reached close enough. * * @param item DiskBalancerWorkItem * @return -- false if we need to copy more, true if we are done */ private boolean isCloseEnough(DiskBalancerWorkItem item) { long temp = item.getBytesCopied() + ((item.getBytesCopied() * getBlockTolerancePercentage(item)) / 100); return (item.getBytesToCopy() >= temp) ? false : true; }
/** * Returns maximum errors to tolerate for the specific plan or the default. * * @param item - DiskBalancerWorkItem * @return maximum error counts to tolerate. */ private long getMaxError(DiskBalancerWorkItem item) { return item.getMaxDiskErrors() <= 0 ? this.maxDiskErrors : item.getMaxDiskErrors(); }
+ pair.getDestVolBasePath(); LOG.error(errMsg); item.setErrMsg(errMsg); return; + pair.getDestVolBasePath(); LOG.error(errMsg); item.setErrMsg(errMsg); return; "transient storage type."; LOG.error(errMsg); item.setErrMsg(errMsg); return; item.setStartTime(startTime); secondsElapsed = 0; if (item.getErrorCount() > getMaxError(item)) { LOG.error("Exceeded the max error count. source {}, dest: {} " + "error count: {}", source.getBaseURI(), dest.getBaseURI(), item.getErrorCount()); break; "blocks.", source.getBaseURI(), dest.getBaseURI(), item.getBytesCopied(), item.getBlocksCopied()); this.setExitFlag(); continue;
/** * Insert work items to work map. * @param volumePair - VolumePair * @param step - Move Step */ private void createWorkPlan(final VolumePair volumePair, Step step) throws DiskBalancerException { if (volumePair.getSourceVolUuid().equals(volumePair.getDestVolUuid())) { final String errMsg = "Disk Balancer - Source and destination volumes " + "are same: " + volumePair.getSourceVolUuid(); LOG.warn(errMsg); throw new DiskBalancerException(errMsg, DiskBalancerException.Result.INVALID_MOVE); } long bytesToMove = step.getBytesToMove(); // In case we have a plan with more than // one line of same VolumePair // we compress that into one work order. if (workMap.containsKey(volumePair)) { bytesToMove += workMap.get(volumePair).getBytesToCopy(); } DiskBalancerWorkItem work = new DiskBalancerWorkItem(bytesToMove, 0); // all these values can be zero, if so we will use // values from configuration. work.setBandwidth(step.getBandwidth()); work.setTolerancePercent(step.getTolerancePercent()); work.setMaxDiskErrors(step.getMaxDiskErrors()); workMap.put(volumePair, work); }
while (!iter.atEnd() && item.getErrorCount() < getMaxError(item)) { try { ExtendedBlock block = iter.nextBlock(); item.incErrorCount(); if (item.getErrorCount() >= getMaxError(item)) { item.setErrMsg("Error count exceeded."); LOG.info("Maximum error count exceeded. Error count: {} Max error:{} ", item.getErrorCount(), item.getMaxDiskErrors());
/** * Returns the default block tolerance if the plan does not have value of * tolerance specified. * * @param item - DiskBalancerWorkItem * @return long */ private long getBlockTolerancePercentage(DiskBalancerWorkItem item) { return item.getTolerancePercent() <= 0 ? this.blockTolerance : item.getTolerancePercent(); }
/** * Checks if a given block is less than needed size to meet our goal. * * @param blockSize - block len * @param item - Work item * @return true if this block meets our criteria, false otherwise. */ private boolean isLessThanNeeded(long blockSize, DiskBalancerWorkItem item) { long bytesToCopy = item.getBytesToCopy() - item.getBytesCopied(); bytesToCopy = bytesToCopy + ((bytesToCopy * getBlockTolerancePercentage(item)) / 100); return (blockSize <= bytesToCopy) ? true : false; }