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; }
String[] hosts = blockLocation.getHosts(); String[] names = blockLocation.getNames(); String[] topologyPaths = blockLocation.getTopologyPaths(); for (int i = 0; i < topologyPaths.length; i++) { int diskId = volumeIds != null ? DistributedFileSystemMetadata.getDiskId(volumeIds[i]) : -1;
locations[i].getLength(), locations[i].getHosts(), locations[i].getTopologyPaths()); blocks[i] = oneblock;
locations[i].getLength(), locations[i].getHosts(), locations[i].getTopologyPaths()); blocks[i] = oneblock;
OneBlockInfo oneblock = new OneBlockInfo(path, locations[i].getOffset(), locations[i].getLength(), locations[i].getHosts(), locations[i].getTopologyPaths()); blocks[i] = oneblock;
OneBlockInfo oneblock = new OneBlockInfo(path, locations[i].getOffset(), locations[i].getLength(), locations[i].getHosts(), locations[i].getTopologyPaths()); blocks[i] = oneblock;
fileSize = stat.getLen(); blocks[0] = new OneBlockInfo(stat.getPath(), 0, fileSize, locations[0].getHosts(), locations[0].getTopologyPaths()); } else { ArrayList<OneBlockInfo> blocksList = new ArrayList<OneBlockInfo>( locations[i].getTopologyPaths()); left -= myLength; myOffset += myLength;
fileSize = stat.getLen(); blocks[0] = new OneBlockInfo(stat.getPath(), 0, fileSize, locations[0].getHosts(), locations[0].getTopologyPaths()); } else { ArrayList<OneBlockInfo> blocksList = new ArrayList<OneBlockInfo>( locations[i].getTopologyPaths()); left -= myLength; myOffset += myLength;
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; }
for (String top : locs[0].getTopologyPaths()) { if (!top.startsWith("/rack2")) { String name = top.substring("/rack1".length()+1);
LocatedBlock blk = locations.get(i); DatanodeInfo[] datanodes = blk.getLocations(); String[] topologyPaths = blockLocations[i].getTopologyPaths(); assertTrue(topologyPaths.length == datanodes.length); for (int j = 0; j < topologyPaths.length; j++) {
allTopos = blkLocations[index].getTopologyPaths();
allTopos = blkLocations[index].getTopologyPaths();
verifyDeserialization(bl2.getTopologyPaths(), topologyPaths); assertEquals(bl2.getOffset(), offset); assertEquals(bl2.getLength(), length);
public void testGetFileBlockLocations() throws IOException { final String f = "/test/testGetFileBlockLocations"; createFile(path(f)); final BlockLocation[] computed = fs.getFileBlockLocations(new Path(f), 0L, 1L); final BlockLocation[] expected = cluster.getFileSystem().getFileBlockLocations( new Path(f), 0L, 1L); assertEquals(expected.length, computed.length); for (int i = 0; i < computed.length; i++) { assertEquals(expected[i].toString(), computed[i].toString()); // Check names String names1[] = expected[i].getNames(); String names2[] = computed[i].getNames(); Arrays.sort(names1); Arrays.sort(names2); Assert.assertArrayEquals("Names differ", names1, names2); // Check topology String topos1[] = expected[i].getTopologyPaths(); String topos2[] = computed[i].getTopologyPaths(); Arrays.sort(topos1); Arrays.sort(topos2); Assert.assertArrayEquals("Topology differs", topos1, topos2); } }
for (String top : locs[0].getTopologyPaths()) { if (!top.startsWith("/rack2")) { String name = top.substring("/rack1".length()+1);
LocatedBlock blk = locations.get(i); DatanodeInfo[] datanodes = blk.getLocations(); String[] topologyPaths = blockLocations[i].getTopologyPaths(); assertTrue(topologyPaths.length == datanodes.length); for (int j = 0; j < topologyPaths.length; j++) {
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()); }