/// <exception cref="System.IO.IOException"/> public virtual HdfsBlocksMetadata GetHdfsBlocksMetadata(string blockPoolId, long[] blockIds, IList <Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> > tokens ) { IList <SecurityProtos.TokenProto> tokensProtos = new AList <SecurityProtos.TokenProto >(tokens.Count); foreach (Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> t in tokens) { tokensProtos.AddItem(PBHelper.Convert(t)); } // Build the request ClientDatanodeProtocolProtos.GetHdfsBlockLocationsRequestProto request = ((ClientDatanodeProtocolProtos.GetHdfsBlockLocationsRequestProto )ClientDatanodeProtocolProtos.GetHdfsBlockLocationsRequestProto.NewBuilder().SetBlockPoolId (blockPoolId).AddAllBlockIds(Longs.AsList(blockIds)).AddAllTokens(tokensProtos). Build()); // Send the RPC ClientDatanodeProtocolProtos.GetHdfsBlockLocationsResponseProto response; try { response = rpcProxy.GetHdfsBlockLocations(NullController, request); } catch (ServiceException e) { throw ProtobufHelper.GetRemoteException(e); } // List of volumes in the response IList <ByteString> volumeIdsByteStrings = response.GetVolumeIdsList(); IList <byte[]> volumeIds = new AList <byte[]>(volumeIdsByteStrings.Count); foreach (ByteString bs in volumeIdsByteStrings) { volumeIds.AddItem(bs.ToByteArray()); } // Array of indexes into the list of volumes, one per block IList <int> volumeIndexes = response.GetVolumeIndexesList(); // Parsed HdfsVolumeId values, one per block return(new HdfsBlocksMetadata(blockPoolId, blockIds, volumeIds, volumeIndexes)); }
public override string ToString() { return("Metadata for " + blockIds.Length + " blocks in " + blockPoolId + ": " + Joiner .On(",").Join(Longs.AsList(blockIds))); }