org.apache.hadoop.hdfs
Class DFSUtil

java.lang.Object
  extended by org.apache.hadoop.hdfs.DFSUtil

@InterfaceAudience.Private
public class DFSUtil
extends Object


Nested Class Summary
static class DFSUtil.ErrorSimulator
          Utility class to facilitate junit test error simulation.
 
Constructor Summary
DFSUtil()
           
 
Method Summary
static String byteArray2String(byte[][] pathComponents)
          Given a list of path components returns a path as a UTF8 String
static byte[][] bytes2byteArray(byte[] bytes, byte separator)
          Splits the array of bytes into array of arrays of bytes on byte separator
static byte[][] bytes2byteArray(byte[] bytes, int len, byte separator)
          Splits first len bytes in bytes to array of arrays of bytes on byte separator
static String bytes2String(byte[] bytes)
          Converts a byte array to a string using UTF8 encoding.
static boolean isValidName(String src)
          Whether the pathname is valid.
static org.apache.hadoop.fs.BlockLocation[] locatedBlocks2Locations(LocatedBlocks blocks)
          Convert a LocatedBlocks to BlockLocations[]
static byte[] string2Bytes(String str)
          Converts a string to a byte array using UTF8 encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DFSUtil

public DFSUtil()
Method Detail

isValidName

public static boolean isValidName(String src)
Whether the pathname is valid. Currently prohibits relative paths, and names which contain a ":" or "/"


bytes2String

public static String bytes2String(byte[] bytes)
Converts a byte array to a string using UTF8 encoding.


string2Bytes

public static byte[] string2Bytes(String str)
Converts a string to a byte array using UTF8 encoding.


byteArray2String

public static String byteArray2String(byte[][] pathComponents)
Given a list of path components returns a path as a UTF8 String


bytes2byteArray

public static byte[][] bytes2byteArray(byte[] bytes,
                                       byte separator)
Splits the array of bytes into array of arrays of bytes on byte separator

Parameters:
bytes - the array of bytes to split
separator - the delimiting byte

bytes2byteArray

public static byte[][] bytes2byteArray(byte[] bytes,
                                       int len,
                                       byte separator)
Splits first len bytes in bytes to array of arrays of bytes on byte separator

Parameters:
bytes - the byte array to split
len - the number of bytes to split
separator - the delimiting byte

locatedBlocks2Locations

public static org.apache.hadoop.fs.BlockLocation[] locatedBlocks2Locations(LocatedBlocks blocks)
Convert a LocatedBlocks to BlockLocations[]

Parameters:
blocks - a LocatedBlocks
Returns:
an array of BlockLocations


Copyright © 2009 The Apache Software Foundation