• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Op类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op的典型用法代码示例。如果您正苦于以下问题:Java Op类的具体用法?Java Op怎么用?Java Op使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Op类属于org.apache.hadoop.hdfs.web.resources.HttpOpParam包,在下文中一共展示了Op类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAuthParameters

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
Param<?,?>[] getAuthParameters(final HttpOpParam.Op op) throws IOException {
  List<Param<?,?>> authParams = Lists.newArrayList();    
  // Skip adding delegation token for token operations because these
  // operations require authentication.
  Token<?> token = null;
  if (!op.getRequireAuth()) {
    token = getDelegationToken();
  }
  if (token != null) {
    authParams.add(new DelegationParam(token.encodeToUrlString()));
  } else {
    UserGroupInformation userUgi = ugi;
    UserGroupInformation realUgi = userUgi.getRealUser();
    if (realUgi != null) { // proxy user
      authParams.add(new DoAsParam(userUgi.getShortUserName()));
      userUgi = realUgi;
    }
    authParams.add(new UserParam(userUgi.getShortUserName()));
  }
  return authParams.toArray(new Param<?,?>[0]);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:WebHdfsFileSystem.java


示例2: getXAttrs

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public Map<String, byte[]> getXAttrs(Path p, final List<String> names) 
    throws IOException {
  Preconditions.checkArgument(names != null && !names.isEmpty(), 
      "XAttr names cannot be null or empty.");
  Param<?,?>[] parameters = new Param<?,?>[names.size() + 1];
  for (int i = 0; i < parameters.length - 1; i++) {
    parameters[i] = new XAttrNameParam(names.get(i));
  }
  parameters[parameters.length - 1] = new XAttrEncodingParam(XAttrCodec.HEX);
  
  final HttpOpParam.Op op = GetOpParam.Op.GETXATTRS;
  return new FsPathResponseRunner<Map<String, byte[]>>(op, parameters, p) {
    @Override
    Map<String, byte[]> decodeResponse(Map<?, ?> json) throws IOException {
      return JsonUtil.toXAttrs(json);
    }
  }.run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:WebHdfsFileSystem.java


示例3: listStatus

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public FileStatus[] listStatus(final Path f) throws IOException {
  statistics.incrementReadOps(1);

  final HttpOpParam.Op op = GetOpParam.Op.LISTSTATUS;
  return new FsPathResponseRunner<FileStatus[]>(op, f) {
    @Override
    FileStatus[] decodeResponse(Map<?,?> json) {
      final Map<?, ?> rootmap = (Map<?, ?>)json.get(FileStatus.class.getSimpleName() + "es");
      final List<?> array = JsonUtil.getList(
          rootmap, FileStatus.class.getSimpleName());

      //convert FileStatus
      final FileStatus[] statuses = new FileStatus[array.size()];
      int i = 0;
      for (Object object : array) {
        final Map<?, ?> m = (Map<?, ?>) object;
        statuses[i++] = makeQualified(JsonUtil.toFileStatus(m, false), f);
      }
      return statuses;
    }
  }.run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:WebHdfsFileSystem.java


示例4: getDelegationToken

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public Token<DelegationTokenIdentifier> getDelegationToken(
    final String renewer) throws IOException {
  final HttpOpParam.Op op = GetOpParam.Op.GETDELEGATIONTOKEN;
  Token<DelegationTokenIdentifier> token =
      new FsPathResponseRunner<Token<DelegationTokenIdentifier>>(
          op, null, new RenewerParam(renewer)) {
    @Override
    Token<DelegationTokenIdentifier> decodeResponse(Map<?,?> json)
        throws IOException {
      return JsonUtil.toDelegationToken(json);
    }
  }.run();
  if (token != null) {
    token.setService(tokenServiceName);
  } else {
    if (disallowFallbackToInsecureCluster) {
      throw new AccessControlException(CANT_FALLBACK_TO_INSECURE_MSG);
    }
  }
  return token;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:WebHdfsFileSystem.java


示例5: getHomeDirectory

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public Path getHomeDirectory() {
  if (cachedHomeDirectory == null) {
    final HttpOpParam.Op op = GetOpParam.Op.GETHOMEDIRECTORY;
    try {
      String pathFromDelegatedFS = new FsPathResponseRunner<String>(op, null,
          new UserParam(ugi)) {
        @Override
        String decodeResponse(Map<?, ?> json) throws IOException {
          return JsonUtilClient.getPath(json);
        }
      }   .run();

      cachedHomeDirectory = new Path(pathFromDelegatedFS).makeQualified(
          this.getUri(), null);

    } catch (IOException e) {
      LOG.error("Unable to get HomeDirectory from original File System", e);
      cachedHomeDirectory = new Path("/user/" + ugi.getShortUserName())
          .makeQualified(this.getUri(), null);
    }
  }
  return cachedHomeDirectory;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:25,代码来源:WebHdfsFileSystem.java


示例6: getAuthParameters

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
Param<?,?>[] getAuthParameters(final HttpOpParam.Op op) throws IOException {
  List<Param<?,?>> authParams = Lists.newArrayList();
  // Skip adding delegation token for token operations because these
  // operations require authentication.
  Token<?> token = null;
  if (!op.getRequireAuth()) {
    token = getDelegationToken();
  }
  if (token != null) {
    authParams.add(new DelegationParam(token.encodeToUrlString()));
  } else {
    UserGroupInformation userUgi = ugi;
    UserGroupInformation realUgi = userUgi.getRealUser();
    if (realUgi != null) { // proxy user
      authParams.add(new DoAsParam(userUgi.getShortUserName()));
      userUgi = realUgi;
    }
    authParams.add(new UserParam(userUgi.getShortUserName()));
  }
  return authParams.toArray(new Param<?,?>[0]);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:22,代码来源:WebHdfsFileSystem.java


示例7: getXAttrs

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public Map<String, byte[]> getXAttrs(Path p, final List<String> names)
    throws IOException {
  Preconditions.checkArgument(names != null && !names.isEmpty(),
      "XAttr names cannot be null or empty.");
  Param<?,?>[] parameters = new Param<?,?>[names.size() + 1];
  for (int i = 0; i < parameters.length - 1; i++) {
    parameters[i] = new XAttrNameParam(names.get(i));
  }
  parameters[parameters.length - 1] = new XAttrEncodingParam(XAttrCodec.HEX);

  final HttpOpParam.Op op = GetOpParam.Op.GETXATTRS;
  return new FsPathResponseRunner<Map<String, byte[]>>(op, parameters, p) {
    @Override
    Map<String, byte[]> decodeResponse(Map<?, ?> json) throws IOException {
      return JsonUtilClient.toXAttrs(json);
    }
  }.run();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:WebHdfsFileSystem.java


示例8: createNonRecursive

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public FSDataOutputStream createNonRecursive(final Path f,
    final FsPermission permission, final EnumSet<CreateFlag> flag,
    final int bufferSize, final short replication, final long blockSize,
    final Progressable progress) throws IOException {
  statistics.incrementWriteOps(1);

  final HttpOpParam.Op op = PutOpParam.Op.CREATE;
  return new FsPathOutputStreamRunner(op, f, bufferSize,
      new PermissionParam(applyUMask(permission)),
      new CreateFlagParam(flag),
      new CreateParentParam(false),
      new BufferSizeParam(bufferSize),
      new ReplicationParam(replication),
      new BlockSizeParam(blockSize)
  ).run();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:18,代码来源:WebHdfsFileSystem.java


示例9: getDelegationToken

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public Token<DelegationTokenIdentifier> getDelegationToken(
    final String renewer) throws IOException {
  final HttpOpParam.Op op = GetOpParam.Op.GETDELEGATIONTOKEN;
  Token<DelegationTokenIdentifier> token =
      new FsPathResponseRunner<Token<DelegationTokenIdentifier>>(
          op, null, new RenewerParam(renewer)) {
        @Override
        Token<DelegationTokenIdentifier> decodeResponse(Map<?,?> json)
            throws IOException {
          return JsonUtilClient.toDelegationToken(json);
        }
      }.run();
  if (token != null) {
    token.setService(tokenServiceName);
  } else {
    if (disallowFallbackToInsecureCluster) {
      throw new AccessControlException(CANT_FALLBACK_TO_INSECURE_MSG);
    }
  }
  return token;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:23,代码来源:WebHdfsFileSystem.java


示例10: toUrl

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
URL toUrl(final HttpOpParam.Op op, final Path fspath,
    final Param<?,?>... parameters) throws IOException {
  //initialize URI path and query
  final String path = PATH_PREFIX
      + (fspath == null? "/": makeQualified(fspath).toUri().getRawPath());
  final String query = op.toQueryString()
      + Param.toSortedString("&", getAuthParameters(op))
      + Param.toSortedString("&", parameters);
  final URL url = getNamenodeURL(path, query);
  if (LOG.isTraceEnabled()) {
    LOG.trace("url=" + url);
  }
  return url;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:WebHdfsFileSystem.java


示例11: connect

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
private HttpURLConnection connect(final HttpOpParam.Op op, final URL url)
    throws IOException {
  final HttpURLConnection conn =
      (HttpURLConnection)connectionFactory.openConnection(url);
  final boolean doOutput = op.getDoOutput();
  conn.setRequestMethod(op.getType().toString());
  conn.setInstanceFollowRedirects(false);
  switch (op.getType()) {
    // if not sending a message body for a POST or PUT operation, need
    // to ensure the server/proxy knows this 
    case POST:
    case PUT: {
      conn.setDoOutput(true);
      if (!doOutput) {
        // explicitly setting content-length to 0 won't do spnego!!
        // opening and closing the stream will send "Content-Length: 0"
        conn.getOutputStream().close();
      } else {
        conn.setRequestProperty("Content-Type",
            MediaType.APPLICATION_OCTET_STREAM);
        conn.setChunkedStreamingMode(32 << 10); //32kB-chunk
      }
      break;
    }
    default: {
      conn.setDoOutput(doOutput);
      break;
    }
  }
  conn.connect();
  return conn;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:WebHdfsFileSystem.java


示例12: getHdfsFileStatus

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
private HdfsFileStatus getHdfsFileStatus(Path f) throws IOException {
  final HttpOpParam.Op op = GetOpParam.Op.GETFILESTATUS;
  HdfsFileStatus status = new FsPathResponseRunner<HdfsFileStatus>(op, f) {
    @Override
    HdfsFileStatus decodeResponse(Map<?,?> json) {
      return JsonUtil.toFileStatus(json, true);
    }
  }.run();
  if (status == null) {
    throw new FileNotFoundException("File does not exist: " + f);
  }
  return status;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:WebHdfsFileSystem.java


示例13: getAclStatus

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public AclStatus getAclStatus(Path f) throws IOException {
  final HttpOpParam.Op op = GetOpParam.Op.GETACLSTATUS;
  AclStatus status = new FsPathResponseRunner<AclStatus>(op, f) {
    @Override
    AclStatus decodeResponse(Map<?,?> json) {
      return JsonUtil.toAclStatus(json);
    }
  }.run();
  if (status == null) {
    throw new FileNotFoundException("File does not exist: " + f);
  }
  return status;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:WebHdfsFileSystem.java


示例14: mkdirs

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public boolean mkdirs(Path f, FsPermission permission) throws IOException {
  statistics.incrementWriteOps(1);
  final HttpOpParam.Op op = PutOpParam.Op.MKDIRS;
  return new FsPathBooleanRunner(op, f,
      new PermissionParam(applyUMask(permission))
  ).run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:WebHdfsFileSystem.java


示例15: createSymlink

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
/**
 * Create a symlink pointing to the destination path.
 * @see org.apache.hadoop.fs.Hdfs#createSymlink(Path, Path, boolean) 
 */
public void createSymlink(Path destination, Path f, boolean createParent
    ) throws IOException {
  statistics.incrementWriteOps(1);
  final HttpOpParam.Op op = PutOpParam.Op.CREATESYMLINK;
  new FsPathRunner(op, f,
      new DestinationParam(makeQualified(destination).toUri().getPath()),
      new CreateParentParam(createParent)
  ).run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:WebHdfsFileSystem.java


示例16: rename

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public boolean rename(final Path src, final Path dst) throws IOException {
  statistics.incrementWriteOps(1);
  final HttpOpParam.Op op = PutOpParam.Op.RENAME;
  return new FsPathBooleanRunner(op, src,
      new DestinationParam(makeQualified(dst).toUri().getPath())
  ).run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:WebHdfsFileSystem.java


示例17: setXAttr

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public void setXAttr(Path p, String name, byte[] value, 
    EnumSet<XAttrSetFlag> flag) throws IOException {
  statistics.incrementWriteOps(1);
  final HttpOpParam.Op op = PutOpParam.Op.SETXATTR;
  if (value != null) {
    new FsPathRunner(op, p, new XAttrNameParam(name), new XAttrValueParam(
        XAttrCodec.encodeValue(value, XAttrCodec.HEX)), 
        new XAttrSetFlagParam(flag)).run();
  } else {
    new FsPathRunner(op, p, new XAttrNameParam(name), 
        new XAttrSetFlagParam(flag)).run();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:WebHdfsFileSystem.java


示例18: getXAttr

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public byte[] getXAttr(Path p, final String name) throws IOException {
  final HttpOpParam.Op op = GetOpParam.Op.GETXATTRS;
  return new FsPathResponseRunner<byte[]>(op, p, new XAttrNameParam(name), 
      new XAttrEncodingParam(XAttrCodec.HEX)) {
    @Override
    byte[] decodeResponse(Map<?, ?> json) throws IOException {
      return JsonUtil.getXAttr(json, name);
    }
  }.run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:WebHdfsFileSystem.java


示例19: listXAttrs

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public List<String> listXAttrs(Path p) throws IOException {
  final HttpOpParam.Op op = GetOpParam.Op.LISTXATTRS;
  return new FsPathResponseRunner<List<String>>(op, p) {
    @Override
    List<String> decodeResponse(Map<?, ?> json) throws IOException {
      return JsonUtil.toXAttrNames(json);
    }
  }.run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:WebHdfsFileSystem.java


示例20: setOwner

import org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op; //导入依赖的package包/类
@Override
public void setOwner(final Path p, final String owner, final String group
    ) throws IOException {
  if (owner == null && group == null) {
    throw new IOException("owner == null && group == null");
  }

  statistics.incrementWriteOps(1);
  final HttpOpParam.Op op = PutOpParam.Op.SETOWNER;
  new FsPathRunner(op, p,
      new OwnerParam(owner), new GroupParam(group)
  ).run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:WebHdfsFileSystem.java



注:本文中的org.apache.hadoop.hdfs.web.resources.HttpOpParam.Op类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EditorTestUtil类代码示例发布时间:2022-05-22
下一篇:
Java ExtractedArtifactStoreBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap