private static Map<String, Object> toJsonMap( final BlockLocation blockLocation) throws IOException { if (blockLocation == null) { return null; } final Map<String, Object> m = new HashMap<>(); m.put("length", blockLocation.getLength()); m.put("offset", blockLocation.getOffset()); m.put("corrupt", blockLocation.isCorrupt()); m.put("storageTypes", toJsonArray(blockLocation.getStorageTypes())); m.put("cachedHosts", blockLocation.getCachedHosts()); m.put("hosts", blockLocation.getHosts()); m.put("names", blockLocation.getNames()); m.put("topologyPaths", blockLocation.getTopologyPaths()); return m; }
protected FileMetadata toMetadata(LocatedFileStatus fileStatus) { List<FileMetadata.BlockInfo> blocks = new ArrayList<>(); blocks.addAll(Arrays.stream(fileStatus.getBlockLocations()) .map(block -> new FileMetadata.BlockInfo(block.getOffset(), block.getLength(), block.isCorrupt())) .collect(Collectors.toList())); return new FileMetadata(fileStatus.getPath().toString(), fileStatus.getLen(), blocks); }
public BlockStorageLocation(BlockLocation loc, VolumeId[] volumeIds) throws IOException { // Initialize with data from passed in BlockLocation super(loc.getNames(), loc.getHosts(), loc.getTopologyPaths(), loc .getOffset(), loc.getLength(), loc.isCorrupt()); this.volumeIds = volumeIds; }
public BlockStorageLocation(BlockLocation loc, VolumeId[] volumeIds) throws IOException { // Initialize with data from passed in BlockLocation super(loc.getNames(), loc.getHosts(), loc.getTopologyPaths(), loc .getOffset(), loc.getLength(), loc.isCorrupt()); this.volumeIds = volumeIds; }
if (b.isCorrupt()) { corruptCount++;
if (b.isCorrupt()) { corruptCount++;
private static void checkBlockLocation(final BlockLocation loc, String[] names, String[] hosts, String[] cachedHosts, String[] topologyPaths, final long offset, final long length, final boolean corrupt) throws Exception { assertNotNull(loc.getHosts()); assertNotNull(loc.getCachedHosts()); assertNotNull(loc.getNames()); assertNotNull(loc.getTopologyPaths()); assertArrayEquals(hosts, loc.getHosts()); assertArrayEquals(cachedHosts, loc.getCachedHosts()); assertArrayEquals(names, loc.getNames()); assertArrayEquals(topologyPaths, loc.getTopologyPaths()); assertEquals(offset, loc.getOffset()); assertEquals(length, loc.getLength()); assertEquals(corrupt, loc.isCorrupt()); }
private static void checkBlockLocation(final BlockLocation loc, String[] names, String[] hosts, String[] cachedHosts, String[] topologyPaths, final long offset, final long length, final boolean corrupt) throws Exception { assertNotNull(loc.getHosts()); assertNotNull(loc.getCachedHosts()); assertNotNull(loc.getNames()); assertNotNull(loc.getTopologyPaths()); assertArrayEquals(hosts, loc.getHosts()); assertArrayEquals(cachedHosts, loc.getCachedHosts()); assertArrayEquals(names, loc.getNames()); assertArrayEquals(topologyPaths, loc.getTopologyPaths()); assertEquals(offset, loc.getOffset()); assertEquals(length, loc.getLength()); assertEquals(corrupt, loc.isCorrupt()); }