@Override // DataNodeMXBean public String getDiskBalancerStatus() { try { return getDiskBalancer().queryWorkStatus().toJsonString(); } catch (IOException ex) { LOG.debug("Reading diskbalancer Status failed. ex:{}", ex); return ""; } }
/** * Cancels a running plan. * @param planID - Hash string that identifies a plan */ @Override public void cancelDiskBalancePlan(String planID) throws IOException { checkSuperuserPrivilege(); getDiskBalancer().cancelPlan(planID); }
/** * Returns the status of current or last executed work plan. * @return DiskBalancerWorkStatus. * @throws IOException */ @Override public DiskBalancerWorkStatus queryDiskBalancerPlan() throws IOException { checkSuperuserPrivilege(); return getDiskBalancer().queryWorkStatus(); }
/** * 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); } }
/** * Allows submission of a disk balancer Job. * @param planID - Hash value of the plan. * @param planVersion - Plan version, reserved for future use. We have only * version 1 now. * @param planFile - Plan file name * @param planData - Actual plan data in json format * @throws IOException */ @Override public void submitDiskBalancerPlan(String planID, long planVersion, String planFile, String planData, boolean skipDateCheck) throws IOException { checkSuperuserPrivilege(); if (getStartupOption(getConf()) != StartupOption.REGULAR) { throw new DiskBalancerException( "Datanode is in special state, e.g. Upgrade/Rollback etc." + " Disk balancing not permitted.", DiskBalancerException.Result.DATANODE_STATUS_NOT_REGULAR); } getDiskBalancer().submitPlan(planID, planVersion, planFile, planData, skipDateCheck); }