Java Code Examples for org.apache.hadoop.util.StringUtils#toUpperCase()

The following examples show how to use org.apache.hadoop.util.StringUtils#toUpperCase() . 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: TestDFSIO.java    From hadoop with Apache License 2.0 6 votes vote down vote up
static ByteMultiple parseString(String sMultiple) {
  if(sMultiple == null || sMultiple.isEmpty()) // MB by default
    return MB;
  String sMU = StringUtils.toUpperCase(sMultiple);
  if(StringUtils.toUpperCase(B.name()).endsWith(sMU))
    return B;
  if(StringUtils.toUpperCase(KB.name()).endsWith(sMU))
    return KB;
  if(StringUtils.toUpperCase(MB.name()).endsWith(sMU))
    return MB;
  if(StringUtils.toUpperCase(GB.name()).endsWith(sMU))
    return GB;
  if(StringUtils.toUpperCase(TB.name()).endsWith(sMU))
    return TB;
  throw new IllegalArgumentException("Unsupported ByteMultiple "+sMultiple);
}
 
Example 2
Source File: DBInputFormat.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
public void setConf(Configuration conf) {

  dbConf = new DBConfiguration(conf);

  try {
    this.connection = createConnection();

    DatabaseMetaData dbMeta = connection.getMetaData();
    this.dbProductName =
        StringUtils.toUpperCase(dbMeta.getDatabaseProductName());
  }
  catch (Exception ex) {
    throw new RuntimeException(ex);
  }

  tableName = dbConf.getInputTableName();
  fieldNames = dbConf.getInputFieldNames();
  conditions = dbConf.getInputConditions();
}
 
Example 3
Source File: TestDFSIO.java    From big-c with Apache License 2.0 6 votes vote down vote up
static ByteMultiple parseString(String sMultiple) {
  if(sMultiple == null || sMultiple.isEmpty()) // MB by default
    return MB;
  String sMU = StringUtils.toUpperCase(sMultiple);
  if(StringUtils.toUpperCase(B.name()).endsWith(sMU))
    return B;
  if(StringUtils.toUpperCase(KB.name()).endsWith(sMU))
    return KB;
  if(StringUtils.toUpperCase(MB.name()).endsWith(sMU))
    return MB;
  if(StringUtils.toUpperCase(GB.name()).endsWith(sMU))
    return GB;
  if(StringUtils.toUpperCase(TB.name()).endsWith(sMU))
    return TB;
  throw new IllegalArgumentException("Unsupported ByteMultiple "+sMultiple);
}
 
Example 4
Source File: DBInputFormat.java    From big-c with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
public void setConf(Configuration conf) {

  dbConf = new DBConfiguration(conf);

  try {
    this.connection = createConnection();

    DatabaseMetaData dbMeta = connection.getMetaData();
    this.dbProductName =
        StringUtils.toUpperCase(dbMeta.getDatabaseProductName());
  }
  catch (Exception ex) {
    throw new RuntimeException(ex);
  }

  tableName = dbConf.getInputTableName();
  fieldNames = dbConf.getInputFieldNames();
  conditions = dbConf.getInputConditions();
}
 
Example 5
Source File: TimelineWebServices.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static EnumSet<Field> parseFieldsStr(String str, String delimiter) {
  if (str == null) {
    return null;
  }
  String[] strs = str.split(delimiter);
  List<Field> fieldList = new ArrayList<Field>();
  for (String s : strs) {
    s = StringUtils.toUpperCase(s.trim());
    if (s.equals("EVENTS")) {
      fieldList.add(Field.EVENTS);
    } else if (s.equals("LASTEVENTONLY")) {
      fieldList.add(Field.LAST_EVENT_ONLY);
    } else if (s.equals("RELATEDENTITIES")) {
      fieldList.add(Field.RELATED_ENTITIES);
    } else if (s.equals("PRIMARYFILTERS")) {
      fieldList.add(Field.PRIMARY_FILTERS);
    } else if (s.equals("OTHERINFO")) {
      fieldList.add(Field.OTHER_INFO);
    } else {
      throw new IllegalArgumentException("Requested nonexistent field " + s);
    }
  }
  if (fieldList.size() == 0) {
    return null;
  }
  Field f1 = fieldList.remove(fieldList.size() - 1);
  if (fieldList.size() == 0) {
    return EnumSet.of(f1);
  } else {
    return EnumSet.of(f1, fieldList.toArray(new Field[fieldList.size()]));
  }
}
 
Example 6
Source File: FileSystemCounterGroup.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private String checkScheme(String scheme) {
  String fixed = StringUtils.toUpperCase(scheme);
  String interned = schemes.putIfAbsent(fixed, fixed);
  if (schemes.size() > MAX_NUM_SCHEMES) {
    // mistakes or abuses
    throw new IllegalArgumentException("too many schemes? "+ schemes.size() +
                                       " when process scheme: "+ scheme);
  }
  return interned == null ? fixed : interned;
}
 
Example 7
Source File: TimelineWebServices.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static EnumSet<Field> parseFieldsStr(String str, String delimiter) {
  if (str == null) {
    return null;
  }
  String[] strs = str.split(delimiter);
  List<Field> fieldList = new ArrayList<Field>();
  for (String s : strs) {
    s = StringUtils.toUpperCase(s.trim());
    if (s.equals("EVENTS")) {
      fieldList.add(Field.EVENTS);
    } else if (s.equals("LASTEVENTONLY")) {
      fieldList.add(Field.LAST_EVENT_ONLY);
    } else if (s.equals("RELATEDENTITIES")) {
      fieldList.add(Field.RELATED_ENTITIES);
    } else if (s.equals("PRIMARYFILTERS")) {
      fieldList.add(Field.PRIMARY_FILTERS);
    } else if (s.equals("OTHERINFO")) {
      fieldList.add(Field.OTHER_INFO);
    } else {
      throw new IllegalArgumentException("Requested nonexistent field " + s);
    }
  }
  if (fieldList.size() == 0) {
    return null;
  }
  Field f1 = fieldList.remove(fieldList.size() - 1);
  if (fieldList.size() == 0) {
    return EnumSet.of(f1);
  } else {
    return EnumSet.of(f1, fieldList.toArray(new Field[fieldList.size()]));
  }
}
 
Example 8
Source File: FileSystemCounterGroup.java    From big-c with Apache License 2.0 5 votes vote down vote up
private String checkScheme(String scheme) {
  String fixed = StringUtils.toUpperCase(scheme);
  String interned = schemes.putIfAbsent(fixed, fixed);
  if (schemes.size() > MAX_NUM_SCHEMES) {
    // mistakes or abuses
    throw new IllegalArgumentException("too many schemes? "+ schemes.size() +
                                       " when process scheme: "+ scheme);
  }
  return interned == null ? fixed : interned;
}
 
Example 9
Source File: FSEditLogOp.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public RollingUpgradeOp(FSEditLogOpCodes code, String name) {
  super(code);
  this.name = StringUtils.toUpperCase(name);
}
 
Example 10
Source File: FSImageHandler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private static String getOp(QueryStringDecoder decoder) {
  Map<String, List<String>> parameters = decoder.parameters();
  return parameters.containsKey("op")
      ? StringUtils.toUpperCase(parameters.get("op").get(0)) : null;
}
 
Example 11
Source File: FSEditLogOp.java    From big-c with Apache License 2.0 4 votes vote down vote up
public RollingUpgradeOp(FSEditLogOpCodes code, String name) {
  super(code);
  this.name = StringUtils.toUpperCase(name);
}
 
Example 12
Source File: FSImageHandler.java    From big-c with Apache License 2.0 4 votes vote down vote up
private static String getOp(QueryStringDecoder decoder) {
  Map<String, List<String>> parameters = decoder.parameters();
  return parameters.containsKey("op")
      ? StringUtils.toUpperCase(parameters.get("op").get(0)) : null;
}
 
Example 13
Source File: Task.java    From hadoop with Apache License 2.0 2 votes vote down vote up
/**
 * Counters to measure the usage of the different file systems.
 * Always return the String array with two elements. First one is the name of  
 * BYTES_READ counter and second one is of the BYTES_WRITTEN counter.
 */
protected static String[] getFileSystemCounterNames(String uriScheme) {
  String scheme = StringUtils.toUpperCase(uriScheme);
  return new String[]{scheme+"_BYTES_READ", scheme+"_BYTES_WRITTEN"};
}
 
Example 14
Source File: Task.java    From big-c with Apache License 2.0 2 votes vote down vote up
/**
 * Counters to measure the usage of the different file systems.
 * Always return the String array with two elements. First one is the name of  
 * BYTES_READ counter and second one is of the BYTES_WRITTEN counter.
 */
protected static String[] getFileSystemCounterNames(String uriScheme) {
  String scheme = StringUtils.toUpperCase(uriScheme);
  return new String[]{scheme+"_BYTES_READ", scheme+"_BYTES_WRITTEN"};
}