Java Code Examples for org.apache.hadoop.util.StringUtils#toLowerCase()
The following examples show how to use
org.apache.hadoop.util.StringUtils#toLowerCase() .
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: Configuration.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Return time duration in the given time unit. Valid units are encoded in * properties as suffixes: nanoseconds (ns), microseconds (us), milliseconds * (ms), seconds (s), minutes (m), hours (h), and days (d). * @param name Property name * @param vStr The string value with time unit suffix to be converted. * @param unit Unit to convert the stored property, if it exists. */ public long getTimeDurationHelper(String name, String vStr, TimeUnit unit) { vStr = vStr.trim(); vStr = StringUtils.toLowerCase(vStr); ParsedTimeDuration vUnit = ParsedTimeDuration.unitFor(vStr); if (null == vUnit) { logDeprecation("No unit for " + name + "(" + vStr + ") assuming " + unit); vUnit = ParsedTimeDuration.unitFor(unit); } else { vStr = vStr.substring(0, vStr.lastIndexOf(vUnit.suffix())); } long raw = Long.parseLong(vStr); long converted = unit.convert(raw, vUnit.unit()); if (vUnit.unit().convert(converted, unit) < raw) { logDeprecation("Possible loss of precision converting " + vStr + vUnit.suffix() + " to " + unit + " for " + name); } return converted; }
Example 2
Source File: TestSecurityUtil.java From big-c with Apache License 2.0 | 6 votes |
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); }
Example 3
Source File: Server.java From hadoop with Apache License 2.0 | 6 votes |
/** * 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; }
Example 4
Source File: Name.java From big-c with Apache License 2.0 | 5 votes |
@Override public Result apply(PathData item, int depth) throws IOException { String name = getPath(item).getName(); if (!caseSensitive) { name = StringUtils.toLowerCase(name); } if (globPattern.matches(name)) { return Result.PASS; } else { return Result.FAIL; } }
Example 5
Source File: LoggedTaskAttempt.java From hadoop with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: Name.java From hadoop with Apache License 2.0 | 5 votes |
@Override public void prepare() throws IOException { String argPattern = getArgument(1); if (!caseSensitive) { argPattern = StringUtils.toLowerCase(argPattern); } globPattern = new GlobPattern(argPattern); }
Example 7
Source File: TestSecurityUtil.java From big-c with Apache License 2.0 | 5 votes |
@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); }
Example 8
Source File: TestSecurityUtil.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testLocalHostNameForNullOrWild() throws Exception { String local = StringUtils.toLowerCase(SecurityUtil.getLocalHostName()); assertEquals("hdfs/" + local + "@REALM", SecurityUtil.getServerPrincipal("hdfs/_HOST@REALM", (String)null)); assertEquals("hdfs/" + local + "@REALM", SecurityUtil.getServerPrincipal("hdfs/_HOST@REALM", "0.0.0.0")); }
Example 9
Source File: SecurityUtil.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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()); }
Example 10
Source File: XAttrHelper.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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(); }
Example 11
Source File: CapableOzoneFSInputStream.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@Override public boolean hasCapability(String capability) { switch (StringUtils.toLowerCase(capability)) { case OzoneStreamCapabilities.READBYTEBUFFER: return true; default: return false; } }
Example 12
Source File: ParamFilter.java From hadoop with Apache License 2.0 | 5 votes |
/** Rebuild the URI query with lower case parameter names. */ private static URI rebuildQuery(final URI uri, final MultivaluedMap<String, String> parameters) { UriBuilder b = UriBuilder.fromUri(uri).replaceQuery(""); for(Map.Entry<String, List<String>> e : parameters.entrySet()) { final String key = StringUtils.toLowerCase(e.getKey()); for(String v : e.getValue()) { b = b.queryParam(key, v); } } return b.build(); }
Example 13
Source File: TestSecurityUtil.java From hadoop with Apache License 2.0 | 5 votes |
@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); }
Example 14
Source File: DistCpUtils.java From big-c with Apache License 2.0 | 5 votes |
/** * 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; }
Example 15
Source File: SecureClientLogin.java From ranger with Apache License 2.0 | 5 votes |
private static String replacePattern(String[] components, String hostname) throws IOException { String fqdn = hostname; if (fqdn == null || fqdn.isEmpty() || "0.0.0.0".equals(fqdn)) { fqdn = java.net.InetAddress.getLocalHost().getCanonicalHostName(); } return components[0] + "/" + StringUtils.toLowerCase(fqdn) + "@" + components[2]; }
Example 16
Source File: MetricsConfig.java From big-c with Apache License 2.0 | 4 votes |
MetricsConfig(Configuration c, String prefix) { super(c, StringUtils.toLowerCase(prefix), "."); }
Example 17
Source File: BlockStoragePolicySuite.java From big-c with Apache License 2.0 | 4 votes |
public static String buildXAttrName() { return StringUtils.toLowerCase(XAttrNS.toString()) + "." + STORAGE_POLICY_XATTR_NAME; }
Example 18
Source File: Constants.java From hadoop with Apache License 2.0 | 4 votes |
String lowerName() { return StringUtils.toLowerCase(this.name()); }
Example 19
Source File: CapacitySchedulerConfiguration.java From hadoop with Apache License 2.0 | 4 votes |
private static String getAclKey(QueueACL acl) { return "acl_" + StringUtils.toLowerCase(acl.toString()); }
Example 20
Source File: Environment.java From big-c with Apache License 2.0 | 4 votes |
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()); } }