@Override public boolean hasCapability(String capability) { switch (StringUtils.toLowerCase(capability)) { case StreamCapabilities.READAHEAD: case StreamCapabilities.DROPBEHIND: case StreamCapabilities.UNBUFFER: return true; default: return false; } } }
MetricsConfig(Configuration c, String prefix) { super(c, StringUtils.toLowerCase(prefix), "."); }
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(); }
public static boolean isLocalhost(String host) { host = host != null ? StringUtils.toLowerCase(host.trim()) : ""; if (host.startsWith("::1")) { int x = host.lastIndexOf('%'); if (x >= 0) { host = host.substring(0, x); } } int x = Arrays.binarySearch(LOCALHOSTS, host); return x >= 0; }
/** * Returns suffix of cipher suite configuration. * @return String configuration suffix */ public String getConfigSuffix() { String[] parts = name.split("/"); StringBuilder suffix = new StringBuilder(); for (String part : parts) { suffix.append(".").append(StringUtils.toLowerCase(part)); } return suffix.toString(); } }
private void addCodec(CompressionCodec codec) { String suffix = codec.getDefaultExtension(); codecs.put(new StringBuilder(suffix).reverse().toString(), codec); codecsByClassName.put(codec.getClass().getCanonicalName(), codec); String codecName = codec.getClass().getSimpleName(); codecsByName.put(StringUtils.toLowerCase(codecName), codec); if (codecName.endsWith("Codec")) { codecName = codecName.substring(0, codecName.length() - "Codec".length()); codecsByName.put(StringUtils.toLowerCase(codecName), codec); } }
public static void setAuthenticationMethod( AuthenticationMethod authenticationMethod, Configuration conf) { if (authenticationMethod == null) { authenticationMethod = AuthenticationMethod.SIMPLE; } conf.set(HADOOP_SECURITY_AUTHENTICATION, StringUtils.toLowerCase(authenticationMethod.toString())); }
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(null); } return components[0] + "/" + StringUtils.toLowerCase(fqdn) + "@" + components[2]; }
/** * Convert SOME_STUFF to SomeStuff * * @param s input string * @return camelized string */ public static String camelize(String s) { StringBuilder sb = new StringBuilder(); String[] words = split(StringUtils.toLowerCase(s), ESCAPE_CHAR, '_'); for (String word : words) sb.append(org.apache.commons.lang3.StringUtils.capitalize(word)); return sb.toString(); }
static MetricsConfig create(String prefix) { return loadFirst(prefix, "hadoop-metrics2-" + StringUtils.toLowerCase(prefix) + ".properties", DEFAULT_FILE_NAME); }
/** * Resolves a property name to its client/server version if applicable. * <p/> * NOTE: This method is public for testing purposes. * * @param mode client/server mode. * @param template property name template. * @return the resolved property name. */ @VisibleForTesting public static String resolvePropertyName(SSLFactory.Mode mode, String template) { return MessageFormat.format( template, StringUtils.toLowerCase(mode.toString())); }
/** * 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()); }
@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; } }
/** * Returns a string representation guaranteed to be stable across versions to * satisfy backward compatibility requirements, such as for shell command * output or serialization. The format of this string representation matches * what is expected by the {@link #parseAclSpec(String, boolean)} and * {@link #parseAclEntry(String, boolean)} methods. * * @return stable, backward compatible string representation */ public String toStringStable() { StringBuilder sb = new StringBuilder(); if (scope == AclEntryScope.DEFAULT) { sb.append("default:"); } if (type != null) { sb.append(StringUtils.toLowerCase(type.toStringStable())); } sb.append(':'); if (name != null) { sb.append(name); } sb.append(':'); if (permission != null) { sb.append(permission.SYMBOL); } return sb.toString(); }
/** * Find the relevant compression codec for the codec's canonical class name * or by codec alias. * <p/> * Codec aliases are case insensitive. * <p/> * The code alias is the short class name (without the package name). * If the short class name ends with 'Codec', then there are two aliases for * the codec, the complete short class name and the short class name without * the 'Codec' ending. For example for the 'GzipCodec' codec class name the * alias are 'gzip' and 'gzipcodec'. * * @param codecName the canonical class name of the codec * @return the codec object */ public CompressionCodec getCodecByName(String codecName) { if (codecsByClassName == null) { return null; } CompressionCodec codec = getCodecByClassName(codecName); if (codec == null) { // trying to get the codec by name in case the name was specified // instead a class codec = codecsByName.get(StringUtils.toLowerCase(codecName)); } return codec; }
@Override public void prepare() throws IOException { String argPattern = getArgument(1); if (!caseSensitive) { argPattern = StringUtils.toLowerCase(argPattern); } globPattern = new GlobPattern(argPattern); }
/** * 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; }
@Override public KeyVersion createKey(String name, byte[] material, Options options) throws IOException { Preconditions.checkArgument(name.equals(StringUtils.toLowerCase(name)), "Uppercase key names are unsupported: %s", name); writeLock.lock(); try { try { if (keyStore.containsAlias(name) || cache.containsKey(name)) { throw new IOException("Key " + name + " already exists in " + this); } } catch (KeyStoreException e) { throw new IOException("Problem looking up key " + name + " in " + this, e); } Metadata meta = new Metadata(options.getCipher(), options.getBitLength(), options.getDescription(), options.getAttributes(), new Date(), 1); if (options.getBitLength() != 8 * material.length) { throw new IOException("Wrong key length. Required " + options.getBitLength() + ", but got " + (8 * material.length)); } cache.put(name, meta); String versionName = buildVersionName(name, 0); return innerSetKeyVersion(name, versionName, material, meta.getCipher()); } finally { writeLock.unlock(); } }
String contentType = conn.getHeaderField(CONTENT_TYPE); contentType = (contentType != null) ? StringUtils.toLowerCase(contentType) : null; if (contentType != null && contentType.contains(APPLICATION_JSON_MIME)) {
/** * 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; }