public class DFSUtilClient extends Object
Modifier and Type | Field and Description |
---|---|
static byte[] |
EMPTY_BYTES |
Constructor and Description |
---|
DFSUtilClient() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
byteArray2bytes(byte[][] pathComponents)
Given a list of path components returns a byte array
|
static String |
bytes2String(byte[] bytes)
Converts a byte array to a string using UTF8 encoding.
|
static int |
compareBytes(byte[] left,
byte[] right)
Compare two byte arrays by lexicographical order.
|
static org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol |
createClientDatanodeProtocolProxy(org.apache.hadoop.hdfs.protocol.DatanodeID datanodeid,
org.apache.hadoop.conf.Configuration conf,
int socketTimeout,
boolean connectToDnViaHostname)
Create
ClientDatanodeProtocol proxy using kerberos ticket |
static org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol |
createClientDatanodeProtocolProxy(org.apache.hadoop.hdfs.protocol.DatanodeID datanodeid,
org.apache.hadoop.conf.Configuration conf,
int socketTimeout,
boolean connectToDnViaHostname,
org.apache.hadoop.hdfs.protocol.LocatedBlock locatedBlock)
Create a
ClientDatanodeProtocol proxy |
static org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol |
createClientDatanodeProtocolProxy(InetSocketAddress addr,
org.apache.hadoop.security.UserGroupInformation ticket,
org.apache.hadoop.conf.Configuration conf,
SocketFactory factory)
Create a
ClientDatanodeProtocol proxy |
static org.apache.hadoop.hdfs.protocol.ReconfigurationProtocol |
createReconfigurationProtocolProxy(InetSocketAddress addr,
org.apache.hadoop.security.UserGroupInformation ticket,
org.apache.hadoop.conf.Configuration conf,
SocketFactory factory) |
static URI |
createUri(String scheme,
InetSocketAddress address)
Create a URI from the scheme and address
|
static String |
dateToIso8601String(Date date)
Converts a Date into an ISO-8601 formatted datetime string.
|
static String |
durationToString(long durationMs)
Converts a time duration in milliseconds into DDD:HH:MM:SS format.
|
static Map<String,Map<String,InetSocketAddress>> |
getAddresses(org.apache.hadoop.conf.Configuration conf,
String defaultAddress,
String... keys)
Returns the configured address for all NameNodes in the cluster.
|
static Map<String,Map<String,InetSocketAddress>> |
getHaNnRpcAddresses(org.apache.hadoop.conf.Configuration conf)
Returns list of InetSocketAddress corresponding to HA NN RPC addresses from
the configuration.
|
static Map<String,Map<String,InetSocketAddress>> |
getHaNnWebHdfsAddresses(org.apache.hadoop.conf.Configuration conf,
String scheme)
Returns list of InetSocketAddress corresponding to HA NN HTTP addresses from
the configuration.
|
static int |
getIoFileBufferSize(org.apache.hadoop.conf.Configuration conf) |
static Collection<String> |
getNameNodeIds(org.apache.hadoop.conf.Configuration conf,
String nsId)
Namenode HighAvailability related configuration.
|
static Collection<String> |
getNameServiceIds(org.apache.hadoop.conf.Configuration conf)
Returns collection of nameservice Ids from the configuration.
|
static InetSocketAddress |
getNNAddress(org.apache.hadoop.conf.Configuration conf) |
static InetSocketAddress |
getNNAddress(String address) |
static InetSocketAddress |
getNNAddress(URI filesystemURI) |
static InetSocketAddress |
getNNAddressCheckLogical(org.apache.hadoop.conf.Configuration conf,
URI filesystemURI)
Get the NN address from the URI.
|
static URI |
getNNUri(InetSocketAddress namenode) |
static float |
getPercentRemaining(long remaining,
long capacity)
Return remaining as percentage of capacity
|
static float |
getPercentUsed(long used,
long capacity)
Return used as percentage of capacity
|
static int |
getSmallBufferSize(org.apache.hadoop.conf.Configuration conf) |
static boolean |
isHDFSEncryptionEnabled(org.apache.hadoop.conf.Configuration conf)
Probe for HDFS Encryption being enabled; this uses the value of the option
CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH
, returning true if that property contains a non-empty, non-whitespace
string. |
static boolean |
isLocalAddress(InetSocketAddress targetAddr) |
static boolean |
isValidName(String src)
Whether the pathname is valid.
|
static org.apache.hadoop.fs.BlockLocation[] |
locatedBlocks2Locations(List<org.apache.hadoop.hdfs.protocol.LocatedBlock> blocks)
Convert a List
|
static org.apache.hadoop.fs.BlockLocation[] |
locatedBlocks2Locations(org.apache.hadoop.hdfs.protocol.LocatedBlocks blocks)
Convert a LocatedBlocks to BlockLocations[]
|
static org.apache.hadoop.hdfs.net.Peer |
peerFromSocket(Socket socket) |
static org.apache.hadoop.hdfs.net.Peer |
peerFromSocketAndKey(org.apache.hadoop.hdfs.protocol.datatransfer.sasl.SaslDataTransferClient saslClient,
Socket s,
org.apache.hadoop.hdfs.protocol.datatransfer.sasl.DataEncryptionKeyFactory keyFactory,
org.apache.hadoop.security.token.Token<org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier> blockToken,
org.apache.hadoop.hdfs.protocol.DatanodeID datanodeId,
int socketTimeoutMs) |
static String |
percent2String(double percentage)
Convert percentage to a string.
|
static byte[] |
string2Bytes(String str)
Converts a string to a byte array using UTF8 encoding.
|
static InterruptedIOException |
toInterruptedIOException(String message,
InterruptedException e) |
public static byte[] string2Bytes(String str)
public static String bytes2String(byte[] bytes)
public static float getPercentUsed(long used, long capacity)
public static float getPercentRemaining(long remaining, long capacity)
public static String percent2String(double percentage)
public static Collection<String> getNameServiceIds(org.apache.hadoop.conf.Configuration conf)
conf
- configurationpublic static Collection<String> getNameNodeIds(org.apache.hadoop.conf.Configuration conf, String nsId)
conf
- configurationnsId
- the nameservice ID to look at, or null for non-federatedpublic static Map<String,Map<String,InetSocketAddress>> getHaNnRpcAddresses(org.apache.hadoop.conf.Configuration conf)
conf
- configurationpublic static Map<String,Map<String,InetSocketAddress>> getHaNnWebHdfsAddresses(org.apache.hadoop.conf.Configuration conf, String scheme)
public static org.apache.hadoop.fs.BlockLocation[] locatedBlocks2Locations(org.apache.hadoop.hdfs.protocol.LocatedBlocks blocks)
blocks
- a LocatedBlockspublic static org.apache.hadoop.fs.BlockLocation[] locatedBlocks2Locations(List<org.apache.hadoop.hdfs.protocol.LocatedBlock> blocks)
blocks
- A Listpublic static int compareBytes(byte[] left, byte[] right)
public static byte[] byteArray2bytes(byte[][] pathComponents)
public static Map<String,Map<String,InetSocketAddress>> getAddresses(org.apache.hadoop.conf.Configuration conf, String defaultAddress, String... keys)
conf
- configurationdefaultAddress
- default address to return in case key is not found.keys
- Set of keys to look for in the order of preferencepublic static boolean isValidName(String src)
public static String durationToString(long durationMs)
public static String dateToIso8601String(Date date)
public static boolean isLocalAddress(InetSocketAddress targetAddr)
public static org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol createClientDatanodeProtocolProxy(org.apache.hadoop.hdfs.protocol.DatanodeID datanodeid, org.apache.hadoop.conf.Configuration conf, int socketTimeout, boolean connectToDnViaHostname, org.apache.hadoop.hdfs.protocol.LocatedBlock locatedBlock) throws IOException
ClientDatanodeProtocol
proxyIOException
public static org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol createClientDatanodeProtocolProxy(org.apache.hadoop.hdfs.protocol.DatanodeID datanodeid, org.apache.hadoop.conf.Configuration conf, int socketTimeout, boolean connectToDnViaHostname) throws IOException
ClientDatanodeProtocol
proxy using kerberos ticketIOException
public static org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol createClientDatanodeProtocolProxy(InetSocketAddress addr, org.apache.hadoop.security.UserGroupInformation ticket, org.apache.hadoop.conf.Configuration conf, SocketFactory factory) throws IOException
ClientDatanodeProtocol
proxyIOException
public static org.apache.hadoop.hdfs.protocol.ReconfigurationProtocol createReconfigurationProtocolProxy(InetSocketAddress addr, org.apache.hadoop.security.UserGroupInformation ticket, org.apache.hadoop.conf.Configuration conf, SocketFactory factory) throws IOException
IOException
public static org.apache.hadoop.hdfs.net.Peer peerFromSocket(Socket socket) throws IOException
IOException
public static org.apache.hadoop.hdfs.net.Peer peerFromSocketAndKey(org.apache.hadoop.hdfs.protocol.datatransfer.sasl.SaslDataTransferClient saslClient, Socket s, org.apache.hadoop.hdfs.protocol.datatransfer.sasl.DataEncryptionKeyFactory keyFactory, org.apache.hadoop.security.token.Token<org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier> blockToken, org.apache.hadoop.hdfs.protocol.DatanodeID datanodeId, int socketTimeoutMs) throws IOException
IOException
public static int getIoFileBufferSize(org.apache.hadoop.conf.Configuration conf)
public static int getSmallBufferSize(org.apache.hadoop.conf.Configuration conf)
public static boolean isHDFSEncryptionEnabled(org.apache.hadoop.conf.Configuration conf)
CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH
, returning true if that property contains a non-empty, non-whitespace
string.conf
- configuration to probepublic static InetSocketAddress getNNAddress(String address)
public static InetSocketAddress getNNAddress(org.apache.hadoop.conf.Configuration conf)
public static InetSocketAddress getNNAddress(URI filesystemURI)
public static InetSocketAddress getNNAddressCheckLogical(org.apache.hadoop.conf.Configuration conf, URI filesystemURI)
conf
- configurationfilesystemURI
- URI of the file systempublic static URI getNNUri(InetSocketAddress namenode)
public static URI createUri(String scheme, InetSocketAddress address)
public static InterruptedIOException toInterruptedIOException(String message, InterruptedException e)
Copyright © 2018 Apache Software Foundation. All Rights Reserved.