Example usage for org.apache.hadoop.hdfs.protocol DatanodeInfo getName

List of usage examples for org.apache.hadoop.hdfs.protocol DatanodeInfo getName

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.protocol DatanodeInfo getName.

Prototype

@Override
public String getName() 

Source Link

Document

Network location name.

Usage

From source file:org.openflamingo.remote.thrift.thriftfs.ThriftUtils.java

License:Apache License

public static DatanodeInfo toThrift(org.apache.hadoop.hdfs.protocol.DatanodeInfo node,
        Map<DatanodeID, Integer> thriftPorts) {
    if (node == null) {
        return new DatanodeInfo();
    }/*from  ww w  . j a  v a 2 s. co m*/

    DatanodeInfo ret = new DatanodeInfo();
    ret.name = node.getName();
    ret.storageID = node.storageID;
    ret.host = node.getHost();
    Integer p = thriftPorts.get(node);
    if (p == null) {
        LOG.warn("Unknown Thrift port for datanode " + node.name);
        ret.thriftPort = Constants.UNKNOWN_THRIFT_PORT;
    } else {
        ret.thriftPort = p.intValue();
    }

    ret.capacity = node.getCapacity();
    ret.dfsUsed = node.getDfsUsed();
    ret.remaining = node.getRemaining();
    ret.xceiverCount = node.getXceiverCount();
    ret.state = node.isDecommissioned() ? DatanodeState.DECOMMISSIONED
            : node.isDecommissionInProgress() ? DatanodeState.DECOMMISSION_INPROGRESS
                    : DatanodeState.NORMAL_STATE;
    ret.httpPort = node.getInfoPort();

    long timestamp = node.getLastUpdate();
    long currentTime = System.currentTimeMillis();
    ret.millisSinceUpdate = currentTime - timestamp;

    return ret;
}