本文整理匯總了Java中org.apache.hadoop.util.StringUtils.toLowerCase方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.toLowerCase方法的具體用法?Java StringUtils.toLowerCase怎麽用?Java StringUtils.toLowerCase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.toLowerCase方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: verifyTokenService
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
private void
verifyTokenService(InetSocketAddress addr, String host, String ip, int port, boolean useIp) {
//LOG.info("address:"+addr+" host:"+host+" ip:"+ip+" port:"+port);
SecurityUtil.setTokenServiceUseIp(useIp);
String serviceHost = useIp ? ip : StringUtils.toLowerCase(host);
Token<?> token = new Token<TokenIdentifier>();
Text service = new Text(serviceHost+":"+port);
assertEquals(service, SecurityUtil.buildTokenService(addr));
SecurityUtil.setTokenService(token, addr);
assertEquals(service, token.getService());
InetSocketAddress serviceAddr = SecurityUtil.getTokenServiceAddr(token);
assertNotNull(serviceAddr);
verifyValues(serviceAddr, serviceHost, ip, port);
}
示例2: Server
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a server instance.
* <p>
* It uses the provided configuration instead loading it from the config dir.
*
* @param name server name.
* @param homeDir server home directory.
* @param configDir config directory.
* @param logDir log directory.
* @param tempDir temp directory.
* @param config server configuration.
*/
public Server(String name, String homeDir, String configDir, String logDir, String tempDir, Configuration config) {
this.name = StringUtils.toLowerCase(Check.notEmpty(name, "name").trim());
this.homeDir = Check.notEmpty(homeDir, "homeDir");
this.configDir = Check.notEmpty(configDir, "configDir");
this.logDir = Check.notEmpty(logDir, "logDir");
this.tempDir = Check.notEmpty(tempDir, "tempDir");
checkAbsolutePath(homeDir, "homeDir");
checkAbsolutePath(configDir, "configDir");
checkAbsolutePath(logDir, "logDir");
checkAbsolutePath(tempDir, "tempDir");
if (config != null) {
this.config = new Configuration(false);
ConfigurationUtils.copy(config, this.config);
}
status = Status.UNDEF;
}
示例3: canonicalizeCounterName
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
private static String canonicalizeCounterName(String nonCanonicalName) {
String result = StringUtils.toLowerCase(nonCanonicalName);
result = result.replace(' ', '|');
result = result.replace('-', '|');
result = result.replace('_', '|');
result = result.replace('.', '|');
return result;
}
示例4: prepare
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
@Override
public void prepare() throws IOException {
String argPattern = getArgument(1);
if (!caseSensitive) {
argPattern = StringUtils.toLowerCase(argPattern);
}
globPattern = new GlobPattern(argPattern);
}
示例5: toCopyListingFileStatus
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
* Converts a FileStatus to a CopyListingFileStatus. If preserving ACLs,
* populates the CopyListingFileStatus with the ACLs. If preserving XAttrs,
* populates the CopyListingFileStatus with the XAttrs.
*
* @param fileSystem FileSystem containing the file
* @param fileStatus FileStatus of file
* @param preserveAcls boolean true if preserving ACLs
* @param preserveXAttrs boolean true if preserving XAttrs
* @param preserveRawXAttrs boolean true if preserving raw.* XAttrs
* @throws IOException if there is an I/O error
*/
public static CopyListingFileStatus toCopyListingFileStatus(
FileSystem fileSystem, FileStatus fileStatus, boolean preserveAcls,
boolean preserveXAttrs, boolean preserveRawXAttrs) throws IOException {
CopyListingFileStatus copyListingFileStatus =
new CopyListingFileStatus(fileStatus);
if (preserveAcls) {
FsPermission perm = fileStatus.getPermission();
if (perm.getAclBit()) {
List<AclEntry> aclEntries = fileSystem.getAclStatus(
fileStatus.getPath()).getEntries();
copyListingFileStatus.setAclEntries(aclEntries);
}
}
if (preserveXAttrs || preserveRawXAttrs) {
Map<String, byte[]> srcXAttrs = fileSystem.getXAttrs(fileStatus.getPath());
if (preserveXAttrs && preserveRawXAttrs) {
copyListingFileStatus.setXAttrs(srcXAttrs);
} else {
Map<String, byte[]> trgXAttrs = Maps.newHashMap();
final String rawNS =
StringUtils.toLowerCase(XAttr.NameSpace.RAW.name());
for (Map.Entry<String, byte[]> ent : srcXAttrs.entrySet()) {
final String xattrName = ent.getKey();
if (xattrName.startsWith(rawNS)) {
if (preserveRawXAttrs) {
trgXAttrs.put(xattrName, ent.getValue());
}
} else if (preserveXAttrs) {
trgXAttrs.put(xattrName, ent.getValue());
}
}
copyListingFileStatus.setXAttrs(trgXAttrs);
}
}
return copyListingFileStatus;
}
示例6: testPrincipalsWithLowerCaseHosts
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
@Test
public void testPrincipalsWithLowerCaseHosts() throws IOException {
String service = "xyz/";
String realm = "@REALM";
String principalInConf = service + SecurityUtil.HOSTNAME_PATTERN + realm;
String hostname = "FooHost";
String principal =
service + StringUtils.toLowerCase(hostname) + realm;
verify(principalInConf, hostname, principal);
}
示例7: testLocalHostNameForNullOrWild
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
@Test
public void testLocalHostNameForNullOrWild() throws Exception {
String local = StringUtils.toLowerCase(SecurityUtil.getLocalHostName(null));
assertEquals("hdfs/" + local + "@REALM",
SecurityUtil.getServerPrincipal("hdfs/[email protected]", (String)null));
assertEquals("hdfs/" + local + "@REALM",
SecurityUtil.getServerPrincipal("hdfs/[email protected]", "0.0.0.0"));
}
示例8: parse
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
* Returns {@link SchedulingPolicy} instance corresponding to the
* {@link SchedulingPolicy} passed as a string. The policy can be "fair" for
* FairSharePolicy, "fifo" for FifoPolicy, or "drf" for
* DominantResourceFairnessPolicy. For a custom
* {@link SchedulingPolicy}s in the RM classpath, the policy should be
* canonical class name of the {@link SchedulingPolicy}.
*
* @param policy canonical class name or "drf" or "fair" or "fifo"
* @throws AllocationConfigurationException
*/
@SuppressWarnings("unchecked")
public static SchedulingPolicy parse(String policy)
throws AllocationConfigurationException {
@SuppressWarnings("rawtypes")
Class clazz;
String text = StringUtils.toLowerCase(policy);
if (text.equalsIgnoreCase(FairSharePolicy.NAME)) {
clazz = FairSharePolicy.class;
} else if (text.equalsIgnoreCase(FifoPolicy.NAME)) {
clazz = FifoPolicy.class;
} else if (text.equalsIgnoreCase(DominantResourceFairnessPolicy.NAME)) {
clazz = DominantResourceFairnessPolicy.class;
} else {
try {
clazz = Class.forName(policy);
} catch (ClassNotFoundException cnfe) {
throw new AllocationConfigurationException(policy
+ " SchedulingPolicy class not found!");
}
}
if (!SchedulingPolicy.class.isAssignableFrom(clazz)) {
throw new AllocationConfigurationException(policy
+ " does not extend SchedulingPolicy");
}
return getInstance(clazz);
}
示例9: replacePattern
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
private static String replacePattern(String[] components, String hostname)
throws IOException {
String fqdn = hostname;
if (fqdn == null || fqdn.isEmpty() || fqdn.equals("0.0.0.0")) {
fqdn = getLocalHostName();
}
return components[0] + "/" +
StringUtils.toLowerCase(fqdn) + "@" + components[2];
}
示例10: testLocalHostNameForNullOrWild
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
@Test
public void testLocalHostNameForNullOrWild() throws Exception {
String local = StringUtils.toLowerCase(SecurityUtil.getLocalHostName());
assertEquals("hdfs/" + local + "@REALM",
SecurityUtil.getServerPrincipal("hdfs/[email protected]", (String)null));
assertEquals("hdfs/" + local + "@REALM",
SecurityUtil.getServerPrincipal("hdfs/[email protected]", "0.0.0.0"));
}
示例11: buildTokenService
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
* Construct the service key for a token
* @param addr InetSocketAddress of remote connection with a token
* @return "ip:port" or "host:port" depending on the value of
* hadoop.security.token.service.use_ip
*/
public static Text buildTokenService(InetSocketAddress addr) {
String host = null;
if (useIpForTokenService) {
if (addr.isUnresolved()) { // host has no ip address
throw new IllegalArgumentException(
new UnknownHostException(addr.getHostName())
);
}
host = addr.getAddress().getHostAddress();
} else {
host = StringUtils.toLowerCase(addr.getHostName());
}
return new Text(host + ":" + addr.getPort());
}
示例12: Key
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
Key(URI uri, Configuration conf, long unique) throws IOException {
scheme = uri.getScheme()==null ?
"" : StringUtils.toLowerCase(uri.getScheme());
authority = uri.getAuthority()==null ?
"" : StringUtils.toLowerCase(uri.getAuthority());
this.unique = unique;
this.ugi = UserGroupInformation.getCurrentUser();
}
示例13: getPrefixName
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
* Get name with prefix from <code>XAttr</code>
*/
public static String getPrefixName(XAttr xAttr) {
if (xAttr == null) {
return null;
}
String namespace = xAttr.getNameSpace().toString();
return StringUtils.toLowerCase(namespace) + "." + xAttr.getName();
}
示例14: Environment
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
public Environment() throws IOException {
// Extend this code to fit all operating
// environments that you expect to run in
// http://lopica.sourceforge.net/os.html
String command = null;
String OS = System.getProperty("os.name");
String lowerOs = StringUtils.toLowerCase(OS);
if (OS.indexOf("Windows") > -1) {
command = "cmd /C set";
} else if (lowerOs.indexOf("ix") > -1 || lowerOs.indexOf("linux") > -1
|| lowerOs.indexOf("freebsd") > -1 || lowerOs.indexOf("sunos") > -1
|| lowerOs.indexOf("solaris") > -1 || lowerOs.indexOf("hp-ux") > -1) {
command = "env";
} else if (lowerOs.startsWith("mac os x") || lowerOs.startsWith("darwin")) {
command = "env";
} else {
// Add others here
}
if (command == null) {
throw new RuntimeException("Operating system " + OS + " not supported by this class");
}
// Read the environment variables
Process pid = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(
new InputStreamReader(pid.getInputStream(), Charset.forName("UTF-8")));
try {
while (true) {
String line = in.readLine();
if (line == null)
break;
int p = line.indexOf("=");
if (p != -1) {
String name = line.substring(0, p);
String value = line.substring(p + 1);
setProperty(name, value);
}
}
in.close();
in = null;
} finally {
IOUtils.closeStream(in);
}
try {
pid.waitFor();
} catch (InterruptedException e) {
throw new IOException(e.getMessage());
}
}
示例15: lowerName
import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
String lowerName() {
return StringUtils.toLowerCase(this.name());
}