Search in sources :

Example 6 with DiskBalancerWorkStatus

use of org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus in project hadoop by apache.

the class ClientDatanodeProtocolTranslatorPB method queryDiskBalancerPlan.

/**
   * Gets the status of an executing diskbalancer Plan.
   */
@Override
public DiskBalancerWorkStatus queryDiskBalancerPlan() throws IOException {
    try {
        QueryPlanStatusRequestProto request = QueryPlanStatusRequestProto.newBuilder().build();
        QueryPlanStatusResponseProto response = rpcProxy.queryDiskBalancerPlan(NULL_CONTROLLER, request);
        DiskBalancerWorkStatus.Result result = Result.NO_PLAN;
        if (response.hasResult()) {
            result = DiskBalancerWorkStatus.Result.values()[response.getResult()];
        }
        return new DiskBalancerWorkStatus(result, response.hasPlanID() ? response.getPlanID() : null, response.hasPlanFile() ? response.getPlanFile() : null, response.hasCurrentStatus() ? response.getCurrentStatus() : null);
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
}
Also used : Result(org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus.Result) ServiceException(com.google.protobuf.ServiceException) QueryPlanStatusRequestProto(org.apache.hadoop.hdfs.protocol.proto.ClientDatanodeProtocolProtos.QueryPlanStatusRequestProto) DiskBalancerWorkStatus(org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus) QueryPlanStatusResponseProto(org.apache.hadoop.hdfs.protocol.proto.ClientDatanodeProtocolProtos.QueryPlanStatusResponseProto)

Example 7 with DiskBalancerWorkStatus

use of org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus in project hadoop by apache.

the class QueryCommand method execute.

/**
   * Executes the Client Calls.
   *
   * @param cmd - CommandLine
   */
@Override
public void execute(CommandLine cmd) throws Exception {
    LOG.info("Executing \"query plan\" command.");
    Preconditions.checkState(cmd.hasOption(DiskBalancerCLI.QUERY));
    verifyCommandOptions(DiskBalancerCLI.QUERY, cmd);
    String nodeName = cmd.getOptionValue(DiskBalancerCLI.QUERY);
    Preconditions.checkNotNull(nodeName);
    nodeName = nodeName.trim();
    String nodeAddress = nodeName;
    // if the string is not name:port format use the default port.
    if (!nodeName.matches("[^\\:]+:[0-9]{2,5}")) {
        int defaultIPC = NetUtils.createSocketAddr(getConf().getTrimmed(DFSConfigKeys.DFS_DATANODE_IPC_ADDRESS_KEY, DFSConfigKeys.DFS_DATANODE_IPC_ADDRESS_DEFAULT)).getPort();
        nodeAddress = nodeName + ":" + defaultIPC;
        LOG.debug("Using default data node port :  {}", nodeAddress);
    }
    ClientDatanodeProtocol dataNode = getDataNodeProxy(nodeAddress);
    try {
        DiskBalancerWorkStatus workStatus = dataNode.queryDiskBalancerPlan();
        System.out.printf("Plan File: %s%nPlan ID: %s%nResult: %s%n", workStatus.getPlanFile(), workStatus.getPlanID(), workStatus.getResult().toString());
        if (cmd.hasOption(DiskBalancerCLI.VERBOSE)) {
            System.out.printf("%s", workStatus.currentStateString());
        }
    } catch (DiskBalancerException ex) {
        LOG.error("Query plan failed. ex: {}", ex);
        throw ex;
    }
}
Also used : DiskBalancerWorkStatus(org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus) ClientDatanodeProtocol(org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol) DiskBalancerException(org.apache.hadoop.hdfs.server.diskbalancer.DiskBalancerException)

Aggregations

DiskBalancerWorkStatus (org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus)7 Test (org.junit.Test)5 DiskBalancer (org.apache.hadoop.hdfs.server.datanode.DiskBalancer)3 NodePlan (org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan)3 DataNode (org.apache.hadoop.hdfs.server.datanode.DataNode)2 DiskBalancerDataNode (org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerDataNode)2 ServiceException (com.google.protobuf.ServiceException)1 Configuration (org.apache.hadoop.conf.Configuration)1 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)1 ClientDatanodeProtocol (org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol)1 QueryPlanStatusRequestProto (org.apache.hadoop.hdfs.protocol.proto.ClientDatanodeProtocolProtos.QueryPlanStatusRequestProto)1 QueryPlanStatusResponseProto (org.apache.hadoop.hdfs.protocol.proto.ClientDatanodeProtocolProtos.QueryPlanStatusResponseProto)1 Result (org.apache.hadoop.hdfs.server.datanode.DiskBalancerWorkStatus.Result)1 DiskBalancerException (org.apache.hadoop.hdfs.server.diskbalancer.DiskBalancerException)1 MoveStep (org.apache.hadoop.hdfs.server.diskbalancer.planner.MoveStep)1 Step (org.apache.hadoop.hdfs.server.diskbalancer.planner.Step)1