本文整理汇总了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);
}
}
}
示例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;
}
示例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)));
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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)));
}
}
示例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);
}
}
}
}