本文整理汇总了Java中org.apache.hadoop.hbase.ipc.RequestContext.isInRequestContext方法的典型用法代码示例。如果您正苦于以下问题:Java RequestContext.isInRequestContext方法的具体用法?Java RequestContext.isInRequestContext怎么用?Java RequestContext.isInRequestContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.ipc.RequestContext
的用法示例。
在下文中一共展示了RequestContext.isInRequestContext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requireScannerOwner
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
/**
* Verify, when servicing an RPC, that the caller is the scanner owner. If so, we assume that
* access control is correctly enforced based on the checks performed in preScannerOpen()
*/
private void requireScannerOwner(InternalScanner s) throws AccessDeniedException {
if (RequestContext.isInRequestContext()) {
String requestUName = RequestContext.getRequestUserName();
String owner = scannerOwners.get(s);
if (owner != null && !owner.equals(requestUName)) {
throw new AccessDeniedException("User '" + requestUName + "' is not the scanner owner!");
}
}
}
示例2: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
/**
* @return User who called RPC method. For non-RPC handling, falls back to system user
* @throws IOException When there is IOE in getting the system user (During non-RPC handling).
*/
public static User getActiveUser() throws IOException {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
user = User.getCurrent();
}
if (LOG.isTraceEnabled()) {
LOG.trace("Current active user name is " + user.getShortName());
}
return user;
}
示例3: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
/**
* Returns the active user to which authorization checks should be applied.
* If we are in the context of an RPC call, the remote user is used,
* otherwise the currently logged in user is used.
*/
private User getActiveUser() throws IOException {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
// for non-rpc handling, fallback to system user
user = userProvider.getCurrent();
}
return user;
}
示例4: requireScannerOwner
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
/**
* Verify, when servicing an RPC, that the caller is the scanner owner.
* If so, we assume that access control is correctly enforced based on
* the checks performed in preScannerOpen()
*/
private void requireScannerOwner(InternalScanner s)
throws AccessDeniedException {
if (RequestContext.isInRequestContext()) {
String requestUserName = RequestContext.getRequestUserName();
String owner = scannerOwners.get(s);
if (owner != null && !owner.equals(requestUserName)) {
throw new AccessDeniedException("User '"+ requestUserName +"' is not the scanner owner!");
}
}
}
示例5: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
private User getActiveUser() {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
return null;
}
//this is for testing
if (userProvider.isHadoopSecurityEnabled()
&& "simple".equalsIgnoreCase(conf.get(User.HBASE_SECURITY_CONF_KEY))) {
return User.createUserForTesting(conf, user.getShortName(), new String[]{});
}
return user;
}
示例6: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
private User getActiveUser() throws IOException {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
// for non-rpc handling, fallback to system user
user = User.getCurrent();
}
if (LOG.isTraceEnabled()) {
LOG.trace("Current active user name is "+user.getShortName());
}
return user;
}
示例7: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
private User getActiveUser() {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
return null;
}
//this is for testing
if("simple".equalsIgnoreCase(conf.get(User.HBASE_SECURITY_CONF_KEY))) {
return User.createUserForTesting(conf, user.getShortName(), new String[]{});
}
return user;
}
示例8: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
/**
* Returns the active user to which authorization checks should be applied.
* If we are in the context of an RPC call, the remote user is used,
* otherwise the currently logged in user is used.
*/
private User getActiveUser() throws IOException {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
// for non-rpc handling, fallback to system user
user = userProvider.getCurrent();
}
return user;
}
示例9: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
private User getActiveUser() throws IOException {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
throw new DoNotRetryIOException("Failed to get requesting user");
}
//this is for testing
if("simple".equalsIgnoreCase(conf.get(User.HBASE_SECURITY_CONF_KEY))) {
return User.createUserForTesting(conf, user.getShortName(), new String[]{});
}
return user;
}
示例10: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
/**
* Returns the active user to which authorization checks should be applied.
* If we are in the context of an RPC call, the remote user is used,
* otherwise the currently logged in user is used.
*/
private User getActiveUser() throws IOException {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
// for non-rpc handling, fallback to system user
user = User.getCurrent();
}
return user;
}
示例11: getActiveUser
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
/**
* Returns the active user to which authorization checks should be applied.
* If we are in the context of an RPC call, the remote user is used,
* otherwise the currently logged in user is used.
*/
private User getActiveUser() throws IOException {
User user = RequestContext.getRequestUser();
if (!RequestContext.isInRequestContext()) {
// for non-rpc handling, fallback to system user
user = User.getCurrent();
}
return user;
}
示例12: prepare
import org.apache.hadoop.hbase.ipc.RequestContext; //导入方法依赖的package包/类
@Override
public CreateTableHandler prepare()
throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
int timeout = conf.getInt("hbase.client.catalog.timeout", 10000);
// Need hbase:meta availability to create a table
try {
if (server.getMetaTableLocator().waitMetaRegionLocation(
server.getZooKeeper(), timeout) == null) {
throw new NotAllMetaRegionsOnlineException();
}
// If we are creating the table in service to an RPC request, record the
// active user for later, so proper permissions will be applied to the
// new table by the AccessController if it is active
if (RequestContext.isInRequestContext()) {
this.activeUser = RequestContext.getRequestUser();
} else {
this.activeUser = UserProvider.instantiate(conf).getCurrent();
}
} catch (InterruptedException e) {
LOG.warn("Interrupted waiting for meta availability", e);
InterruptedIOException ie = new InterruptedIOException(e.getMessage());
ie.initCause(e);
throw ie;
}
//acquire the table write lock, blocking. Make sure that it is released.
this.tableLock.acquire();
boolean success = false;
try {
TableName tableName = this.hTableDescriptor.getTableName();
if (MetaTableAccessor.tableExists(this.server.getConnection(), tableName)) {
throw new TableExistsException(tableName);
}
checkAndSetEnablingTable(assignmentManager, tableName);
success = true;
} finally {
if (!success) {
releaseTableLock();
}
}
return this;
}