Java Code Examples for org.apache.hadoop.hdfs.DFSClient#isMetaInfoSuppoted()

The following examples show how to use org.apache.hadoop.hdfs.DFSClient#isMetaInfoSuppoted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlacementMonitor.java    From RDFS with Apache License 2.0 6 votes vote down vote up
private VersionedLocatedBlocks getLocatedBlocks(Path file, FileSystem fs)
    throws IOException {
  if (!(fs instanceof DistributedFileSystem)) {
    throw new IOException("Cannot obtain " + LocatedBlocks.class +
        " from " + fs.getClass().getSimpleName());
  }
  DistributedFileSystem dfs = (DistributedFileSystem) fs;
  if (DFSClient.isMetaInfoSuppoted(dfs.getClient().namenodeProtocolProxy)) {
    LocatedBlocksWithMetaInfo lbwmi = 
    dfs.getClient().namenode.openAndFetchMetaInfo(
        file.toUri().getPath(), 0, Long.MAX_VALUE);
    dfs.getClient().getNewNameNodeIfNeeded(lbwmi.getMethodFingerPrint());
    return lbwmi;
  }
  return dfs.getClient().namenode.open(
      file.toUri().getPath(), 0, Long.MAX_VALUE);
}
 
Example 2
Source File: BlockReconstructor.java    From RDFS with Apache License 2.0 5 votes vote down vote up
List<LocatedBlockWithMetaInfo> lostBlocksInFile(
		DistributedFileSystem fs, String uriPath, FileStatus stat)
		throws IOException {

	List<LocatedBlockWithMetaInfo> corrupt = 
			new LinkedList<LocatedBlockWithMetaInfo>();
	VersionedLocatedBlocks locatedBlocks;
	int namespaceId = 0;
	int methodFingerprint = 0;
	if (DFSClient
			.isMetaInfoSuppoted(fs.getClient().namenodeProtocolProxy)) {
		LocatedBlocksWithMetaInfo lbksm = fs.getClient().namenode
				.openAndFetchMetaInfo(uriPath, 0, stat.getLen());
		namespaceId = lbksm.getNamespaceID();
		locatedBlocks = lbksm;
		methodFingerprint = lbksm.getMethodFingerPrint();
		fs.getClient().getNewNameNodeIfNeeded(methodFingerprint);
	} else {
		locatedBlocks = fs.getClient().namenode.open(uriPath, 0,
				stat.getLen());
	}
	final int dataTransferVersion = locatedBlocks
			.getDataProtocolVersion();
	for (LocatedBlock b : locatedBlocks.getLocatedBlocks()) {
		if (b.isCorrupt()
				|| (b.getLocations().length == 0 && b.getBlockSize() > 0)) {
			corrupt.add(new LocatedBlockWithMetaInfo(b.getBlock(), b
					.getLocations(), b.getStartOffset(),
					dataTransferVersion, namespaceId, methodFingerprint));
		}
	}
	return corrupt;
}
 
Example 3
Source File: TestBlockCopier.java    From RDFS with Apache License 2.0 5 votes vote down vote up
@Override
List<LocatedBlockWithMetaInfo> lostBlocksInFile(DistributedFileSystem fs,
                                       String uriPath,
                                       FileStatus stat)
    throws IOException {
  
  List<LocatedBlockWithMetaInfo> blocks = 
    new ArrayList<LocatedBlockWithMetaInfo>();
  
  VersionedLocatedBlocks locatedBlocks;
  int namespaceId = 0;
  int methodsFingerprint = 0;
  if (DFSClient.isMetaInfoSuppoted(fs.getClient().namenodeProtocolProxy)) {
    LocatedBlocksWithMetaInfo lbksm = fs.getClient().namenode.
              openAndFetchMetaInfo(uriPath, 0, stat.getLen());
    namespaceId = lbksm.getNamespaceID();
    locatedBlocks = lbksm;
    methodsFingerprint = lbksm.getMethodFingerPrint();
  } else {
    locatedBlocks = fs.getClient().namenode.open(uriPath, 0, stat.getLen());
  }
  final int dataTransferVersion = locatedBlocks.getDataProtocolVersion();

  List<LocatedBlock> lb = locatedBlocks.getLocatedBlocks();
  
  for (LocatedBlock b : lb) {
    if (decomBlockHashes.get(b.getBlock().hashCode()) != null) {
      blocks.add(new LocatedBlockWithMetaInfo(b.getBlock(),
          b.getLocations(), b.getStartOffset(),
          dataTransferVersion, namespaceId, methodsFingerprint));
    }
  }
  
  return blocks;
}
 
Example 4
Source File: BlockReconstructor.java    From RDFS with Apache License 2.0 4 votes vote down vote up
List<LocatedBlockWithMetaInfo> lostBlocksInFile(
		DistributedFileSystem fs, String uriPath, FileStatus stat)
		throws IOException {

	List<LocatedBlockWithMetaInfo> decommissioning = new LinkedList<LocatedBlockWithMetaInfo>();
	VersionedLocatedBlocks locatedBlocks;
	int namespaceId = 0;
	int methodFingerprint = 0;
	if (DFSClient
			.isMetaInfoSuppoted(fs.getClient().namenodeProtocolProxy)) {
		LocatedBlocksWithMetaInfo lbksm = fs.getClient().namenode
				.openAndFetchMetaInfo(uriPath, 0, stat.getLen());
		namespaceId = lbksm.getNamespaceID();
		locatedBlocks = lbksm;
		methodFingerprint = lbksm.getMethodFingerPrint();
		fs.getClient().getNewNameNodeIfNeeded(methodFingerprint);
	} else {
		locatedBlocks = fs.getClient().namenode.open(uriPath, 0,
				stat.getLen());
	}
	final int dataTransferVersion = locatedBlocks
			.getDataProtocolVersion();

	for (LocatedBlock b : locatedBlocks.getLocatedBlocks()) {
		if (b.isCorrupt()
				|| (b.getLocations().length == 0 && b.getBlockSize() > 0)) {
			// If corrupt, this block is the responsibility of the
			// CorruptBlockReconstructor
			continue;
		}

		// Copy this block iff all good copies are being decommissioned
		boolean allDecommissioning = true;
		for (DatanodeInfo i : b.getLocations()) {
			allDecommissioning &= i.isDecommissionInProgress();
		}
		if (allDecommissioning) {
			decommissioning
					.add(new LocatedBlockWithMetaInfo(b.getBlock(), b
							.getLocations(), b.getStartOffset(),
							dataTransferVersion, namespaceId,
							methodFingerprint));
		}
	}
	return decommissioning;
}