当前位置: 首页>>代码示例>>Java>>正文


Java BlockTokenSecretManager.AccessMode方法代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager.AccessMode方法的典型用法代码示例。如果您正苦于以下问题:Java BlockTokenSecretManager.AccessMode方法的具体用法?Java BlockTokenSecretManager.AccessMode怎么用?Java BlockTokenSecretManager.AccessMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager的用法示例。


在下文中一共展示了BlockTokenSecretManager.AccessMode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkBlockToken

import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager; //导入方法依赖的package包/类
/** Check block access token for the given access mode */
private void checkBlockToken(Block block,
    BlockTokenSecretManager.AccessMode accessMode) throws IOException {
  if (isBlockTokenEnabled && UserGroupInformation.isSecurityEnabled()) {
    Set<TokenIdentifier> tokenIds = UserGroupInformation.getCurrentUser()
        .getTokenIdentifiers();
    if (tokenIds.size() != 1) {
      throw new IOException("Can't continue with "
          + "authorization since " + tokenIds.size()
          + " BlockTokenIdentifier " + "is found.");
    }
    for (TokenIdentifier tokenId : tokenIds) {
      BlockTokenIdentifier id = (BlockTokenIdentifier) tokenId;
      if (LOG.isDebugEnabled()) {
        LOG.debug("Got: " + id.toString());
      }
      blockTokenSecretManager.checkAccess(id, null, block, accessMode);
    }
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:21,代码来源:DataNode.java

示例2: createLocatedBlock

import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager; //导入方法依赖的package包/类
private LocatedBlock createLocatedBlock(final BlockInfoContiguous blk, final long pos,
  final BlockTokenSecretManager.AccessMode mode) throws IOException {
  final LocatedBlock lb = createLocatedBlock(blk, pos);
  if (mode != null) {
    setBlockToken(lb, mode);
  }
  return lb;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:BlockManager.java

示例3: setBlockToken

import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager; //导入方法依赖的package包/类
/** Generate a block token for the located block. */
public void setBlockToken(final LocatedBlock b,
    final BlockTokenSecretManager.AccessMode mode) throws IOException {
  if (isBlockTokenEnabled()) {
    // Use cached UGI if serving RPC calls.
    b.setBlockToken(blockTokenSecretManager.generateToken(
        NameNode.getRemoteUser().getShortUserName(),
        b.getBlock(), EnumSet.of(mode)));
  }    
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:BlockManager.java

示例4: checkAccess

import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager; //导入方法依赖的package包/类
private void checkAccess(OutputStream out, final boolean reply, 
    final ExtendedBlock blk,
    final Token<BlockTokenIdentifier> t,
    final Op op,
    final BlockTokenSecretManager.AccessMode mode) throws IOException {
  if (datanode.isBlockTokenEnabled) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Checking block access token for block '" + blk.getBlockId()
          + "' with mode '" + mode + "'");
    }
    try {
      datanode.blockPoolTokenSecretManager.checkAccess(t, null, blk, mode);
    } catch(InvalidToken e) {
      try {
        if (reply) {
          BlockOpResponseProto.Builder resp = BlockOpResponseProto.newBuilder()
            .setStatus(ERROR_ACCESS_TOKEN);
          if (mode == BlockTokenSecretManager.AccessMode.WRITE) {
            DatanodeRegistration dnR = 
              datanode.getDNRegistrationForBP(blk.getBlockPoolId());
            // NB: Unconditionally using the xfer addr w/o hostname
            resp.setFirstBadLink(dnR.getXferAddr());
          }
          resp.build().writeDelimitedTo(out);
          out.flush();
        }
        LOG.warn("Block token verification failed: op=" + op
            + ", remoteAddress=" + remoteAddress
            + ", message=" + e.getLocalizedMessage());
        throw e;
      } finally {
        IOUtils.closeStream(out);
      }
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:DataXceiver.java

示例5: createLocatedBlock

import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager; //导入方法依赖的package包/类
private LocatedBlock createLocatedBlock(final BlockInfo blk, final long pos,
  final BlockTokenSecretManager.AccessMode mode) throws IOException {
  final LocatedBlock lb = createLocatedBlock(blk, pos);
  if (mode != null) {
    setBlockToken(lb, mode);
  }
  return lb;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:9,代码来源:BlockManager.java

示例6: createLocatedBlock

import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager; //导入方法依赖的package包/类
private LocatedBlock createLocatedBlock(final BlockInfo blk, final long pos,
    final BlockTokenSecretManager.AccessMode mode)
    throws IOException, StorageException {
  final LocatedBlock lb = createLocatedBlock(blk, pos);
  if (mode != null) {
    setBlockToken(lb, mode);
  }
  return lb;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:10,代码来源:BlockManager.java

示例7: setBlockToken

import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager; //导入方法依赖的package包/类
/**
 * Generate a block token for the located block.
 */
public void setBlockToken(final LocatedBlock b,
    final BlockTokenSecretManager.AccessMode mode) throws IOException {
  if (isBlockTokenEnabled()) {
    b.setBlockToken(blockTokenSecretManager
        .generateToken(b.getBlock(), EnumSet.of(mode)));
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:11,代码来源:BlockManager.java

示例8: checkAccess

import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager; //导入方法依赖的package包/类
private void checkAccess(DataOutputStream out, final boolean reply,
    final ExtendedBlock blk, final Token<BlockTokenIdentifier> t, final Op op,
    final BlockTokenSecretManager.AccessMode mode) throws IOException {
  if (datanode.isBlockTokenEnabled) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Checking block access token for block '" + blk.getBlockId() +
          "' with mode '" + mode + "'");
    }
    try {
      datanode.blockPoolTokenSecretManager.checkAccess(t, null, blk, mode);
    } catch (InvalidToken e) {
      try {
        if (reply) {
          if (out == null) {
            out = new DataOutputStream(
                NetUtils.getOutputStream(s, dnConf.socketWriteTimeout));
          }
          
          BlockOpResponseProto.Builder resp =
              BlockOpResponseProto.newBuilder().setStatus(ERROR_ACCESS_TOKEN);
          if (mode == BlockTokenSecretManager.AccessMode.WRITE) {
            DatanodeRegistration dnR =
                datanode.getDNRegistrationForBP(blk.getBlockPoolId());
            // NB: Unconditionally using the xfer addr w/o hostname
            resp.setFirstBadLink(dnR.getXferAddr());
          }
          resp.build().writeDelimitedTo(out);
          out.flush();
        }
        LOG.warn(
            "Block token verification failed: op=" + op + ", remoteAddress=" +
                remoteAddress + ", message=" + e.getLocalizedMessage());
        throw e;
      } finally {
        IOUtils.closeStream(out);
      }
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:40,代码来源:DataXceiver.java


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