當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.getTrimmedStringCollection方法代碼示例

本文整理匯總了Java中org.apache.hadoop.util.StringUtils.getTrimmedStringCollection方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.getTrimmedStringCollection方法的具體用法?Java StringUtils.getTrimmedStringCollection怎麽用?Java StringUtils.getTrimmedStringCollection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.util.StringUtils的用法示例。


在下文中一共展示了StringUtils.getTrimmedStringCollection方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildACL

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
 * Build ACL from the given two Strings.
 * The Strings contain comma separated values.
 *
 * @param aclString build ACL from array of Strings
 */
private void buildACL(String[] userGroupStrings) {
  users = new HashSet<String>();
  groups = new HashSet<String>();
  for (String aclPart : userGroupStrings) {
    if (aclPart != null && isWildCardACLValue(aclPart)) {
      allAllowed = true;
      break;
    }
  }
  if (!allAllowed) {      
    if (userGroupStrings.length >= 1 && userGroupStrings[0] != null) {
      users = StringUtils.getTrimmedStringCollection(userGroupStrings[0]);
    } 
    
    if (userGroupStrings.length == 2 && userGroupStrings[1] != null) {
      groups = StringUtils.getTrimmedStringCollection(userGroupStrings[1]);
      groupsMapping.cacheGroupsAdd(new LinkedList<String>(groups));
    }
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:27,代碼來源:AccessControlList.java

示例2: setRenameReservedMapInternal

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
private static void setRenameReservedMapInternal(String renameReserved) {
  Collection<String> pairs =
      StringUtils.getTrimmedStringCollection(renameReserved);
  for (String p : pairs) {
    String[] pair = StringUtils.split(p, '/', '=');
    Preconditions.checkArgument(pair.length == 2,
        "Could not parse key-value pair " + p);
    String key = pair[0];
    String value = pair[1];
    Preconditions.checkArgument(DFSUtil.isReservedPathComponent(key),
        "Unknown reserved path " + key);
    Preconditions.checkArgument(DFSUtil.isValidNameForComponent(value),
        "Invalid rename path for " + key + ": " + value);
    LOG.info("Will rename reserved path " + key + " to " + value);
    renameReservedMap.put(key, value);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:FSImageFormat.java

示例3: getTrimmedStringCollection

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/** 
 * Get the comma delimited values of the <code>name</code> property as 
 * a collection of <code>String</code>s, trimmed of the leading and trailing whitespace.  
 * If no such property is specified then empty <code>Collection</code> is returned.
 *
 * @param name property name.
 * @return property value as a collection of <code>String</code>s, or empty <code>Collection</code> 
 */
public Collection<String> getTrimmedStringCollection(String name) {
  String valueString = get(name);
  if (null == valueString) {
    Collection<String> empty = new ArrayList<String>();
    return empty;
  }
  return StringUtils.getTrimmedStringCollection(valueString);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:17,代碼來源:Configuration.java

示例4: chooseDatanode

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
@VisibleForTesting
static DatanodeInfo chooseDatanode(final NameNode namenode,
    final String path, final HttpOpParam.Op op, final long openOffset,
    final long blocksize, final String excludeDatanodes) throws IOException {
  final BlockManager bm = namenode.getNamesystem().getBlockManager();
  
  HashSet<Node> excludes = new HashSet<Node>();
  if (excludeDatanodes != null) {
    for (String host : StringUtils
        .getTrimmedStringCollection(excludeDatanodes)) {
      int idx = host.indexOf(":");
      if (idx != -1) {          
        excludes.add(bm.getDatanodeManager().getDatanodeByXferAddr(
            host.substring(0, idx), Integer.parseInt(host.substring(idx + 1))));
      } else {
        excludes.add(bm.getDatanodeManager().getDatanodeByHost(host));
      }
    }
  }

  if (op == PutOpParam.Op.CREATE) {
    //choose a datanode near to client 
    final DatanodeDescriptor clientNode = bm.getDatanodeManager(
        ).getDatanodeByHost(getRemoteAddress());
    if (clientNode != null) {
      final DatanodeStorageInfo[] storages = bm.chooseTarget4WebHDFS(
          path, clientNode, excludes, blocksize);
      if (storages.length > 0) {
        return storages[0].getDatanodeDescriptor();
      }
    }
  } else if (op == GetOpParam.Op.OPEN
      || op == GetOpParam.Op.GETFILECHECKSUM
      || op == PostOpParam.Op.APPEND) {
    //choose a datanode containing a replica 
    final NamenodeProtocols np = getRPCServer(namenode);
    final HdfsFileStatus status = np.getFileInfo(path);
    if (status == null) {
      throw new FileNotFoundException("File " + path + " not found.");
    }
    final long len = status.getLen();
    if (op == GetOpParam.Op.OPEN) {
      if (openOffset < 0L || (openOffset >= len && len > 0)) {
        throw new IOException("Offset=" + openOffset
            + " out of the range [0, " + len + "); " + op + ", path=" + path);
      }
    }

    if (len > 0) {
      final long offset = op == GetOpParam.Op.OPEN? openOffset: len - 1;
      final LocatedBlocks locations = np.getBlockLocations(path, offset, 1);
      final int count = locations.locatedBlockCount();
      if (count > 0) {
        return bestNode(locations.get(0).getLocations(), excludes);
      }
    }
  } 

  return (DatanodeDescriptor)bm.getDatanodeManager().getNetworkTopology(
      ).chooseRandom(NodeBase.ROOT);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:62,代碼來源:NamenodeWebHdfsMethods.java


注:本文中的org.apache.hadoop.util.StringUtils.getTrimmedStringCollection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。