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


Java StringUtils.split方法代碼示例

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


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

示例1: 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

示例2: getLoggerAddresses

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
private static List<InetSocketAddress> getLoggerAddresses(URI uri)
    throws IOException {
  String authority = uri.getAuthority();
  Preconditions.checkArgument(authority != null && !authority.isEmpty(),
      "URI has no authority: " + uri);
  
  String[] parts = StringUtils.split(authority, ';');
  for (int i = 0; i < parts.length; i++) {
    parts[i] = parts[i].trim();
  }

  if (parts.length % 2 == 0) {
    LOG.warn("Quorum journal URI '" + uri + "' has an even number " +
        "of Journal Nodes specified. This is not recommended!");
  }
  
  List<InetSocketAddress> addrs = Lists.newArrayList();
  for (String addr : parts) {
    addrs.add(NetUtils.createSocketAddr(
        addr, DFSConfigKeys.DFS_JOURNALNODE_RPC_PORT_DEFAULT));
  }
  return addrs;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:24,代碼來源:QuorumJournalManager.java

示例3: anonymize

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
private void anonymize(StatePool statePool, Configuration conf) {
  FileNameState fState = (FileNameState) statePool.getState(getClass());
  if (fState == null) {
    fState = new FileNameState();
    statePool.addState(getClass(), fState);
  }
  
  String[] files = StringUtils.split(fileName);
  String[] anonymizedFileNames = new String[files.length];
  int i = 0;
  for (String f : files) {
    anonymizedFileNames[i++] = 
      anonymize(statePool, conf, fState, f);
  }

  anonymizedFileName = StringUtils.arrayToString(anonymizedFileNames);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:FileName.java

示例4: getInputPaths

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
public static Path[] getInputPaths(JobContext context) {
  String dirs = context.getConfiguration().get(INPUT_DIR, "");
  // LOG.info(System.getProperty("user.dir"));
  LOG.info("dirs=" + dirs);
  String[] list = StringUtils.split(dirs);
  Path[] result = new Path[list.length];
  for (int i = 0; i < list.length; i++) {
    result[i] = new Path(StringUtils.unEscapeString(list[i]));
  }
  return result;
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:12,代碼來源:HdfsUtil.java

示例5: isValidName

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
 * Whether the pathname is valid.  Currently prohibits relative paths,
 * names which contain a ":" or "//", or other non-canonical paths.
 */
public static boolean isValidName(String src) {
  // Path must be absolute.
  if (!src.startsWith(Path.SEPARATOR)) {
    return false;
  }

  // Check for ".." "." ":" "/"
  String[] components = StringUtils.split(src, '/');
  for (int i = 0; i < components.length; i++) {
    String element = components[i];
    if (element.equals(".")  ||
        (element.contains(":"))  ||
        (element.contains("/"))) {
      return false;
    }
    // ".." is allowed in path starting with /.reserved/.inodes
    if (element.equals("..")) {
      if (components.length > 4
          && components[1].equals(".reserved")
          && components[2].equals(".inodes")) {
        continue;
      }
      return false;
    }
    // The string may start or end with a /, but not have
    // "//" in the middle.
    if (element.isEmpty() && i != components.length - 1 &&
        i != 0) {
      return false;
    }
  }
  return true;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:38,代碼來源:NuCypherExtUtilClient.java

示例6: serviceInit

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
@Override
protected void serviceInit(Configuration conf) throws Exception {
  String auth =  conf.get(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION);
  if (auth == null || "simple".equals(auth)) {
    isSecurityEnabled = false;
  } else if ("kerberos".equals(auth)) {
    isSecurityEnabled = true;
  } else {
    LOG.warn("Unrecongized attribute value for " +
        CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION +
        " of " + auth);
  }
  String proxy = WebAppUtils.getProxyHostAndPort(conf);
  String[] proxyParts = proxy.split(":");
  proxyHost = proxyParts[0];

  fetcher = new AppReportFetcher(conf);
  bindAddress = conf.get(YarnConfiguration.PROXY_ADDRESS);
  if(bindAddress == null || bindAddress.isEmpty()) {
    throw new YarnRuntimeException(YarnConfiguration.PROXY_ADDRESS + 
        " is not set so the proxy will not run.");
  }
  LOG.info("Instantiating Proxy at " + bindAddress);
  String[] parts = StringUtils.split(bindAddress, ':');
  port = 0;
  if (parts.length == 2) {
    bindAddress = parts[0];
    port = Integer.parseInt(parts[1]);
  }
  acl = new AccessControlList(conf.get(YarnConfiguration.YARN_ADMIN_ACL, 
      YarnConfiguration.DEFAULT_YARN_ADMIN_ACL));
  super.serviceInit(conf);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:34,代碼來源:WebAppProxy.java

示例7: serviceStart

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
@Override
protected void serviceStart() throws Exception {
  Configuration conf = getConfig();
  String bindAddress = conf.get(YarnConfiguration.PROXY_ADDRESS);
  bindAddress = StringUtils.split(bindAddress, ':')[0];
  AccessControlList acl = new AccessControlList(
      conf.get(YarnConfiguration.YARN_ADMIN_ACL, 
      YarnConfiguration.DEFAULT_YARN_ADMIN_ACL));
  proxyServer = new HttpServer2.Builder()
      .setName("proxy")
      .addEndpoint(
          URI.create(WebAppUtils.getHttpSchemePrefix(conf) + bindAddress
              + ":0")).setFindPort(true)
      .setConf(conf)
      .setACL(acl)
      .build();
  proxyServer.addServlet(ProxyUriUtils.PROXY_SERVLET_NAME,
      ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class);

  appReportFetcher = new AppReportFetcherForTest(conf);
  proxyServer.setAttribute(FETCHER_ATTRIBUTE,
      appReportFetcher );
  proxyServer.setAttribute(IS_SECURITY_ENABLED_ATTRIBUTE, Boolean.TRUE);
  
  String proxy = WebAppUtils.getProxyHostAndPort(conf);
  String[] proxyParts = proxy.split(":");
  String proxyHost = proxyParts[0];
  
  proxyServer.setAttribute(PROXY_HOST_ATTRIBUTE, proxyHost);
  proxyServer.start();
  LOG.info("Proxy server is started at port {}",
      proxyServer.getConnectorAddress(0).getPort());
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:34,代碼來源:TestWebAppProxyServlet.java

示例8: getInputPaths

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
 * Get the list of input {@link Path}s for the map-reduce job.
 * 
 * @param conf The configuration of the job 
 * @return the list of input {@link Path}s for the map-reduce job.
 */
public static Path[] getInputPaths(JobConf conf) {
  String dirs = conf.get(org.apache.hadoop.mapreduce.lib.input.
    FileInputFormat.INPUT_DIR, "");
  String [] list = StringUtils.split(dirs);
  Path[] result = new Path[list.length];
  for (int i = 0; i < list.length; i++) {
    result[i] = new Path(StringUtils.unEscapeString(list[i]));
  }
  return result;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:FileInputFormat.java

示例9: getInputPaths

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
 * Get the list of input {@link Path}s for the map-reduce job.
 * 
 * @param context The job
 * @return the list of input {@link Path}s for the map-reduce job.
 */
public static Path[] getInputPaths(JobContext context) {
  String dirs = context.getConfiguration().get(INPUT_DIR, "");
  String [] list = StringUtils.split(dirs);
  Path[] result = new Path[list.length];
  for (int i = 0; i < list.length; i++) {
    result[i] = new Path(StringUtils.unEscapeString(list[i]));
  }
  return result;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:16,代碼來源:FileInputFormat.java

示例10: isValidName

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
 * Whether the pathname is valid.  Currently prohibits relative paths, 
 * names which contain a ":" or "//", or other non-canonical paths.
 */
public static boolean isValidName(String src) {
  // Path must be absolute.
  if (!src.startsWith(Path.SEPARATOR)) {
    return false;
  }
    
  // Check for ".." "." ":" "/"
  String[] components = StringUtils.split(src, '/');
  for (int i = 0; i < components.length; i++) {
    String element = components[i];
    if (element.equals(".")  ||
        (element.indexOf(":") >= 0)  ||
        (element.indexOf("/") >= 0)) {
      return false;
    }
    // ".." is allowed in path starting with /.reserved/.inodes
    if (element.equals("..")) {
      if (components.length > 4
          && components[1].equals(FSDirectory.DOT_RESERVED_STRING)
          && components[2].equals(FSDirectory.DOT_INODES_STRING)) {
        continue;
      }
      return false;
    }
    // The string may start or end with a /, but not have
    // "//" in the middle.
    if (element.isEmpty() && i != components.length - 1 &&
        i != 0) {
      return false;
    }
  }
  return true;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:38,代碼來源:DFSUtil.java

示例11: getPathNames

import org.apache.hadoop.util.StringUtils; //導入方法依賴的package包/類
/**
 * Splits an absolute {@code path} into an array of path components.
 * @throws AssertionError if the given path is invalid.
 * @return array of path components.
 */
public static String[] getPathNames(String path) {
  if (path == null || !path.startsWith(Path.SEPARATOR)) {
    throw new AssertionError("Absolute path required");
  }
  return StringUtils.split(path, Path.SEPARATOR_CHAR);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:12,代碼來源:INode.java


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