Example usage for org.apache.hadoop.hdfs.protocol LocatedBlock getCachedLocations

List of usage examples for org.apache.hadoop.hdfs.protocol LocatedBlock getCachedLocations

Introduction

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

Prototype

public DatanodeInfo[] getCachedLocations() 

Source Link

Usage

From source file:com.bigstep.datalake.JsonUtil.java

License:Apache License

/** Convert a LocatedBlock to a Json map. */
private static Map<String, Object> toJsonMap(final LocatedBlock locatedblock) throws IOException {
    if (locatedblock == null) {
        return null;
    }/* w ww.  j  a v  a 2s.c o m*/

    final Map<String, Object> m = new TreeMap<String, Object>();
    m.put("blockToken", toJsonMap(locatedblock.getBlockToken()));
    m.put("isCorrupt", locatedblock.isCorrupt());
    m.put("startOffset", locatedblock.getStartOffset());
    m.put("block", toJsonMap(locatedblock.getBlock()));
    m.put("locations", toJsonArray(locatedblock.getLocations()));
    m.put("cachedLocations", toJsonArray(locatedblock.getCachedLocations()));
    return m;
}