lock.lock(); try { checkDiskBalancerEnabled(); if ((this.future != null) && (!this.future.isDone())) { LOG.error("Disk Balancer - Executing another plan, submitPlan failed."); DiskBalancerException.Result.PLAN_ALREADY_IN_PROGRESS); NodePlan nodePlan = verifyPlan(planId, planVersion, planData, force); createWorkPlan(nodePlan); this.planID = planId; this.planFile = planFileName; this.currentResult = Result.PLAN_UNDER_PROGRESS; executePlan(); } finally { lock.unlock();
/** * Shutdown disk balancer. */ private void shutdownDiskBalancer() { if (this.diskBalancer != null) { this.diskBalancer.shutdown(); this.diskBalancer = null; } }
/** * Returns a volume ID to Volume base path map. * * @return Json string of the volume map. * @throws DiskBalancerException */ public String getVolumeNames() throws DiskBalancerException { lock.lock(); try { checkDiskBalancerEnabled(); return JsonUtil.toJsonString(getStorageIDToVolumeBasePathMap()); } catch (DiskBalancerException ex) { throw ex; } catch (IOException e) { throw new DiskBalancerException("Internal error, Unable to " + "create JSON string.", e, DiskBalancerException.Result.INTERNAL_ERROR); } finally { lock.unlock(); } }
boolean needShutdown = false; try { checkDiskBalancerEnabled(); if (this.planID == null || !this.planID.equals(planID) || shutdownExecutor();
/** * Gets a runtime configuration value from diskbalancer instance. For * example : DiskBalancer bandwidth. * * @param key - String that represents the run time key value. * @return value of the key as a string. * @throws IOException - Throws if there is no such key */ @Override public String getDiskBalancerSetting(String key) throws IOException { checkSuperuserPrivilege(); Preconditions.checkNotNull(key); switch (key) { case DiskBalancerConstants.DISKBALANCER_VOLUME_NAME: return getDiskBalancer().getVolumeNames(); case DiskBalancerConstants.DISKBALANCER_BANDWIDTH : return Long.toString(getDiskBalancer().getBandwidth()); default: LOG.error("Disk Balancer - Unknown key in get balancer setting. Key: {}", key); throw new DiskBalancerException("Unknown key", DiskBalancerException.Result.UNKNOWN_KEY); } }
getStorageIDToVolumeBasePathMap(); createWorkPlan(volumePair, step);
@Override // DataNodeMXBean public String getDiskBalancerStatus() { try { return getDiskBalancer().queryWorkStatus().toJsonString(); } catch (IOException ex) { LOG.debug("Reading diskbalancer Status failed. ex:{}", ex); return ""; } }
/** * Returns the current bandwidth. * * @return string representation of bandwidth. * @throws DiskBalancerException */ public long getBandwidth() throws DiskBalancerException { lock.lock(); try { checkDiskBalancerEnabled(); return this.bandwidth; } finally { lock.unlock(); } }
/** * Cancels a running plan. * @param planID - Hash string that identifies a plan */ @Override public void cancelDiskBalancePlan(String planID) throws IOException { checkSuperuserPrivilege(); getDiskBalancer().cancelPlan(planID); }
/** * Initilizes {@link DiskBalancer}. * @param data - FSDataSet * @param conf - Config */ private void initDiskBalancer(FsDatasetSpi data, Configuration conf) { if (this.diskBalancer != null) { return; } DiskBalancer.BlockMover mover = new DiskBalancer.DiskBalancerMover(data, conf); this.diskBalancer = new DiskBalancer(getDatanodeUuid(), conf, mover); }
/** * Returns the status of current or last executed work plan. * @return DiskBalancerWorkStatus. * @throws IOException */ @Override public DiskBalancerWorkStatus queryDiskBalancerPlan() throws IOException { checkSuperuserPrivilege(); return getDiskBalancer().queryWorkStatus(); }
lock.lock(); try { checkDiskBalancerEnabled();