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

The following examples show how to use org.apache.hadoop.util.StringUtils#getStringCollection() . 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: Groups.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void parseStaticMapping(Configuration conf) {
  String staticMapping = conf.get(
      CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES,
      CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES_DEFAULT);
  Collection<String> mappings = StringUtils.getStringCollection(
      staticMapping, ";");
  for (String users : mappings) {
    Collection<String> userToGroups = StringUtils.getStringCollection(users,
        "=");
    if (userToGroups.size() < 1 || userToGroups.size() > 2) {
      throw new HadoopIllegalArgumentException("Configuration "
          + CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES
          + " is invalid");
    }
    String[] userToGroupsArray = userToGroups.toArray(new String[userToGroups
        .size()]);
    String user = userToGroupsArray[0];
    List<String> groups = Collections.emptyList();
    if (userToGroupsArray.length == 2) {
      groups = (List<String>) StringUtils
          .getStringCollection(userToGroupsArray[1]);
    }
    staticUserToGroupsMap.put(user, groups);
  }
}
 
Example 2
Source File: AbstractHiveBinding.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<String> getColumns(final String columns) {
  final List<String> result = (List<String>) StringUtils.getStringCollection(columns);
  result.removeAll(virtualColumns);
  return result;
}
 
Example 3
Source File: Groups.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private Map<String, List<String>> parseStaticMapping(Configuration conf) {

    Map<String, List<String>> staticUserToGroups =
        new HashMap<String, List<String>>();

    String staticMapping = conf.get(
        CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES,
        CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES_DEFAULT);
    Collection<String> mappings = StringUtils.getStringCollection(
        staticMapping, ";");
    for (String users : mappings) {
      Collection<String> userToGroups = StringUtils.getStringCollection(users,
          "=");
      if (userToGroups.size() < 1 || userToGroups.size() > 2) {
        throw new HadoopIllegalArgumentException("Configuration "
            + CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES
            + " is invalid");
      }
      String[] userToGroupsArray = userToGroups.toArray(new String[userToGroups
          .size()]);
      String user = userToGroupsArray[0];
      List<String> groups = Collections.emptyList();
      if (userToGroupsArray.length == 2) {
        groups = (List<String>) StringUtils
            .getStringCollection(userToGroupsArray[1]);
      }
      staticUserToGroups.put(user, groups);
    }

    return staticUserToGroups;
  }
 
Example 4
Source File: AuthorizationHeaderV4.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Validate Signed headers.
 * */
private void validateSignedHeaders() throws OS3Exception {
  if (isNotEmpty(signedHeadersStr)
      && signedHeadersStr.startsWith(SIGNEDHEADERS)) {
    signedHeadersStr = signedHeadersStr.substring(SIGNEDHEADERS.length());
    signedHeaders = StringUtils.getStringCollection(signedHeadersStr, ";");
    if (signedHeaders.size() == 0) {
      LOG.error("No signed headers found. Authheader:{}", authHeader);
      throw S3ErrorTable.newError(MALFORMED_HEADER, authHeader);
    }
  } else {
    LOG.error("No signed headers found. Authheader:{}", authHeader);
    throw S3ErrorTable.newError(MALFORMED_HEADER, authHeader);
  }
}
 
Example 5
Source File: TrafficController.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * Bootstrap tc configuration
 */
public void bootstrap(String device, int rootBandwidthMbit, int
    yarnBandwidthMbit, int containerBandwidthMbit, boolean strictMode)
    throws ResourceHandlerException {
  if (device == null) {
    throw new ResourceHandlerException("device cannot be null!");
  }

  String tmpDirBase = conf.get("hadoop.tmp.dir");
  if (tmpDirBase == null) {
    throw new ResourceHandlerException("hadoop.tmp.dir not set!");
  }
  tmpDirPath = tmpDirBase + "/nm-tc-rules";

  File tmpDir = new File(tmpDirPath);
  if (!(tmpDir.exists() || tmpDir.mkdirs())) {
    LOG.warn("Unable to create directory: " + tmpDirPath);
    throw new ResourceHandlerException("Unable to create directory: " +
        tmpDirPath);
  }

  this.device = StringUtils.getStringCollection(device);
  this.rootBandwidthMbit = rootBandwidthMbit;
  this.yarnBandwidthMbit = yarnBandwidthMbit;
  defaultClassBandwidthMbit = (rootBandwidthMbit - yarnBandwidthMbit) <= 0
      ? rootBandwidthMbit : (rootBandwidthMbit - yarnBandwidthMbit);

  boolean recoveryEnabled = conf.getBoolean(YarnConfiguration
      .NM_RECOVERY_ENABLED, YarnConfiguration.DEFAULT_NM_RECOVERY_ENABLED);
  String state = null;

  if (!recoveryEnabled) {
    LOG.info("NM recovery is not enabled. We'll wipe tc state before proceeding.");
  } else {
    //NM recovery enabled - run a state check
    state = readState();
    if (checkIfAlreadyBootstrapped(state)) {
      LOG.info("TC configuration is already in place. Not wiping state.");

      //We already have the list of existing container classes, if any
      //that were created after bootstrapping
      reacquireContainerClasses(state);
      wipeState(); //start over in case preview bootstrap was incomplete
      initializeState();
      recoverAcquireContainerClasses(containerBandwidthMbit, strictMode);
      return;
    } else {
      LOG.info("TC configuration is incomplete. Wiping tc state before proceeding");
    }
  }

  wipeState(); //start over in case preview bootstrap was incomplete
  initializeState();
}
 
Example 6
Source File: AclEntry.java    From hadoop with Apache License 2.0 3 votes vote down vote up
/**
 * Parses a string representation of an ACL spec into a list of AclEntry
 * objects. Example: "user::rwx,user:foo:rw-,group::r--,other::---"
 * 
 * @param aclSpec
 *          String representation of an ACL spec.
 * @param includePermission
 *          for setAcl operations this will be true. i.e. AclSpec should
 *          include permissions.<br>
 *          But for removeAcl operation it will be false. i.e. AclSpec should
 *          not contain permissions.<br>
 *          Example: "user:foo,group:bar"
 * @return Returns list of {@link AclEntry} parsed
 */
public static List<AclEntry> parseAclSpec(String aclSpec,
    boolean includePermission) {
  List<AclEntry> aclEntries = new ArrayList<AclEntry>();
  Collection<String> aclStrings = StringUtils.getStringCollection(aclSpec,
      ",");
  for (String aclStr : aclStrings) {
    AclEntry aclEntry = parseAclEntry(aclStr, includePermission);
    aclEntries.add(aclEntry);
  }
  return aclEntries;
}
 
Example 7
Source File: AclEntry.java    From big-c with Apache License 2.0 3 votes vote down vote up
/**
 * Parses a string representation of an ACL spec into a list of AclEntry
 * objects. Example: "user::rwx,user:foo:rw-,group::r--,other::---"
 * 
 * @param aclSpec
 *          String representation of an ACL spec.
 * @param includePermission
 *          for setAcl operations this will be true. i.e. AclSpec should
 *          include permissions.<br>
 *          But for removeAcl operation it will be false. i.e. AclSpec should
 *          not contain permissions.<br>
 *          Example: "user:foo,group:bar"
 * @return Returns list of {@link AclEntry} parsed
 */
public static List<AclEntry> parseAclSpec(String aclSpec,
    boolean includePermission) {
  List<AclEntry> aclEntries = new ArrayList<AclEntry>();
  Collection<String> aclStrings = StringUtils.getStringCollection(aclSpec,
      ",");
  for (String aclStr : aclStrings) {
    AclEntry aclEntry = parseAclEntry(aclStr, includePermission);
    aclEntries.add(aclEntry);
  }
  return aclEntries;
}
 
Example 8
Source File: Configuration.java    From hadoop with Apache License 2.0 2 votes vote down vote up
/** 
 * Get the comma delimited values of the <code>name</code> property as 
 * a collection of <code>String</code>s.  
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 * 
 * @param name property name.
 * @return property value as a collection of <code>String</code>s. 
 */
public Collection<String> getStringCollection(String name) {
  String valueString = get(name);
  return StringUtils.getStringCollection(valueString);
}
 
Example 9
Source File: Configuration.java    From hadoop-gpu with Apache License 2.0 2 votes vote down vote up
/** 
 * Get the comma delimited values of the <code>name</code> property as 
 * a collection of <code>String</code>s.  
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 * 
 * @param name property name.
 * @return property value as a collection of <code>String</code>s. 
 */
public Collection<String> getStringCollection(String name) {
  String valueString = get(name);
  return StringUtils.getStringCollection(valueString);
}
 
Example 10
Source File: Configuration.java    From RDFS with Apache License 2.0 2 votes vote down vote up
/** 
 * Get the comma delimited values of the <code>name</code> property as 
 * a collection of <code>String</code>s.  
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 * 
 * @param name property name.
 * @return property value as a collection of <code>String</code>s. 
 */
public Collection<String> getStringCollection(String name) {
  String valueString = get(name);
  return StringUtils.getStringCollection(valueString);
}
 
Example 11
Source File: Configuration.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Get the comma delimited values of the <code>name</code> property as
 * a collection of <code>String</code>s.
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 *
 * @param name property name.
 * @return property value as a collection of <code>String</code>s.
 */
public Collection<String> getStringCollection(String name) {
	String valueString = get(name);
	return StringUtils.getStringCollection(valueString);
}
 
Example 12
Source File: Configuration.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Get the comma delimited values of the <code>name</code> property as
 * a collection of <code>String</code>s.
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 *
 * @param name property name.
 * @return property value as a collection of <code>String</code>s.
 */
public Collection<String> getStringCollection(String name) {
  String valueString = get(name);
  return StringUtils.getStringCollection(valueString);
}
 
Example 13
Source File: Configuration.java    From big-c with Apache License 2.0 2 votes vote down vote up
/** 
 * Get the comma delimited values of the <code>name</code> property as 
 * a collection of <code>String</code>s.  
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 * 
 * @param name property name.
 * @return property value as a collection of <code>String</code>s. 
 */
public Collection<String> getStringCollection(String name) {
  String valueString = get(name);
  return StringUtils.getStringCollection(valueString);
}
 
Example 14
Source File: Configuration.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Get the comma delimited values of the <code>name</code> property as
 * a collection of <code>String</code>s.
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 *
 * @param name property name.
 * @return property value as a collection of <code>String</code>s.
 */
public Collection<String> getStringCollection(String name) {
	String valueString = get(name);
	return StringUtils.getStringCollection(valueString);
}
 
Example 15
Source File: Configuration.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Get the comma delimited values of the <code>name</code> property as
 * a collection of <code>String</code>s.
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 *
 * @param name property name.
 * @return property value as a collection of <code>String</code>s.
 */
public Collection<String> getStringCollection(String name) {
  String valueString = get(name);
  return StringUtils.getStringCollection(valueString);
}
 
Example 16
Source File: Configuration.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Get the comma delimited values of the <code>name</code> property as
 * a collection of <code>String</code>s.
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 *
 * @param name property name.
 * @return property value as a collection of <code>String</code>s.
 */
public Collection<String> getStringCollection(String name) {
	String valueString = get(name);
	return StringUtils.getStringCollection(valueString);
}
 
Example 17
Source File: Configuration.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Get the comma delimited values of the <code>name</code> property as
 * a collection of <code>String</code>s.
 * If no such property is specified then empty collection is returned.
 * <p>
 * This is an optimized version of {@link #getStrings(String)}
 *
 * @param name property name.
 * @return property value as a collection of <code>String</code>s.
 */
public Collection<String> getStringCollection(String name) {
  String valueString = get(name);
  return StringUtils.getStringCollection(valueString);
}