<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        自定義Hive權(quán)限控制(4)擴展Hive以實現(xiàn)自定義權(quán)限控制

        來源:懂視網(wǎng) 責編:小采 時間:2020-11-09 13:20:45
        文檔

        自定義Hive權(quán)限控制(4)擴展Hive以實現(xiàn)自定義權(quán)限控制

        自定義Hive權(quán)限控制(4)擴展Hive以實現(xiàn)自定義權(quán)限控制:在前3節(jié)中,已經(jīng)就 hive 權(quán)限控制 進行了基礎(chǔ)數(shù)據(jù)的維護,現(xiàn)在用戶權(quán)限配置功能已經(jīng)實現(xiàn)。并且可以通過界面話的方式進行維護和管理。接著,最重要的事情就是針對Hive源碼的修改。 主要是針對org.apache. hadoop . hive .conf.HiveConf及org
        推薦度:
        導讀自定義Hive權(quán)限控制(4)擴展Hive以實現(xiàn)自定義權(quán)限控制:在前3節(jié)中,已經(jīng)就 hive 權(quán)限控制 進行了基礎(chǔ)數(shù)據(jù)的維護,現(xiàn)在用戶權(quán)限配置功能已經(jīng)實現(xiàn)。并且可以通過界面話的方式進行維護和管理。接著,最重要的事情就是針對Hive源碼的修改。 主要是針對org.apache. hadoop . hive .conf.HiveConf及org

        在前3節(jié)中,已經(jīng)就 hive 權(quán)限控制 進行了基礎(chǔ)數(shù)據(jù)的維護,現(xiàn)在用戶權(quán)限配置功能已經(jīng)實現(xiàn)。并且可以通過界面話的方式進行維護和管理。接著,最重要的事情就是針對Hive源碼的修改。 主要是針對org.apache. hadoop . hive .conf.HiveConf及org.apache. hadoop .

        在前3節(jié)中,已經(jīng)就hive權(quán)限控制進行了基礎(chǔ)數(shù)據(jù)的維護,現(xiàn)在用戶權(quán)限配置功能已經(jīng)實現(xiàn)。并且可以通過界面話的方式進行維護和管理。接著,最重要的事情就是針對Hive源碼的修改。
        主要是針對org.apache.hadoop.hive.conf.HiveConf及org.apache.hadoop.hive.ql.Driver
        首先針對我們的特定需求,
        擴展org.apache.hadoop.hive.conf.HiveConf

        ??public static enum ConfVars {	KUXUNUSER("hive.kuxun.username",""), //用戶名	KUXUNPASSWORD("hive.kuxun.password",""),//密碼	KUXUN_HIVESERVER_URL("hive.kuxun.hiveserver.url",""), //權(quán)限認證數(shù)據(jù)庫地址	KUXUN_HIVESERVER_USER("hive.kuxun.hiveserver.username",""),//權(quán)限認證數(shù)據(jù)庫用戶名	KUXUN_HIVESERVER_PASSWORD("hive.kuxun.hiveserver.password",""),//權(quán)限認證數(shù)據(jù)庫密碼	KUXUN_RESERVE_A("hive.kuxun.resrver.a",""),//保留	KUXUN_RESERVE_B("hive.kuxun.resrver.b",""),//保留	KUXUN_RESERVE_C("hive.kuxun.resrver.c",""),//保留	KUXUN_RESERVE_D("hive.kuxun.resrver.d",""),//保留????????.......}

        擴展org.apache.hadoop.hive.ql.Driver類
        新增2個私有變量。用于存儲傳遞來的用戶和密碼信息。
        private String username ="";private String password ="";

        在run()方法中增加獲取username和password的實現(xiàn)
        this.username = HiveConf.getVar(conf, HiveConf.ConfVars.KUXUNUSER);this.password = HiveConf.getVar(conf, HiveConf.ConfVars.KUXUNPASSWORD);

        增加方法:
        private void doAuthorizationExtend(BaseSemanticAnalyzer sem) throws HiveException, AuthorizationException {	//獲取用戶權(quán)限信息	UserAuthDataMode ua ;	try{	ua = new UserAuthDataMode(this.username,this.password,this.conf);	ua.run();	}catch(Exception e){	throw new AuthorizationException(e.getMessage());	}	if(ua.isSuperUser()){	LOG.error("current user is super user,do not check authorization.");	return ;	}	LOG.warn("current user is ["+this.username+"]. start check authorization.......");????LOG.warn("current user["+this.username+"] execute command ["+this.userCommand+"].");?	HashSet inputs = sem.getInputs();	SessionState ss = SessionState.get();	HiveOperation op = ss.getHiveOperation();	if (op != null) {}//不處理這種方式,hiveserver并不提供寫入操作	LOG.debug("---------auth KUXUN--------------");	if (inputs != null && inputs.size() > 0) {	if (inputs.size() > ua.getMaxMapCount()){	String errorMsg = "The max partition numbers which you can handler in one job is ["+ua.getMaxMapCount()+"],but current is ["+inputs.size()+"]. Pemission denied.";	Exception ex = new Exception(errorMsg);	throw new AuthorizationException(errorMsg,ex);	}	for (ReadEntity read : inputs) {	if (read.getPartition() != null) {	Table tbl = read.getTable();	String tblName = tbl.getTableName();	LOG.debug("-----dbName.tableName---------"+tbl.getDbName()+"."+tblName);	String tblFullName = tbl.getDbName()+"."+tblName;	//如果當前表所在db不在用戶權(quán)限db中 ,同時表不在用戶權(quán)限table中,則拋出異常	if(ua.getDbNameList().indexOf(tbl.getDbName()) partValueList = part.getValues();	List partList = tbl.getPartitionKeys();	int partSize = partList.size();	for (int i=0;i tsoTopMap = parseCtx	.getTopToTable();?	for (Map.Entry> topOpMap : querySem	.getParseContext().getTopOps().entrySet()) {	Operator topOp = topOpMap	.getValue();	if (topOp instanceof TableScanOperator	&& tsoTopMap.containsKey(topOp)) {	TableScanOperator tableScanOp = (TableScanOperator) topOp;	Table tbl = tsoTopMap.get(tableScanOp);	String dbName = tbl.getDbName();	String tblName = tbl.getTableName();	List neededColumnIds = tableScanOp	.getNeededColumnIDs();	List columns = tbl.getCols();	List cols = new ArrayList();	if (neededColumnIds != null){	LOG.debug("-------neededColumnIds-----"+neededColumnIds.size());	}else{	LOG.debug("-------neededColumnIds-----null");	}	if (neededColumnIds != null	&& neededColumnIds.size() > 0) {	for (int i = 0; i < neededColumnIds.size(); i++) {	cols.add(columns.get(neededColumnIds.get(i))	.getName());	}	} else {	for (int i = 0; i < columns.size(); i++) {	cols.add(columns.get(i).getName());	}	}	//判斷非分區(qū)表,是否存在于權(quán)限對象中	String fullTableName = dbName +"."+tblName;	if(ua.getDbNameList().indexOf(tbl.getDbName()) authColList = ua.getExcludeColumnList().get(fullTableName);	for(String col:cols){	if(authColList.indexOf(col) !=-1){	throw new AuthorizationException("table ["+fullTableName+"] column ["+col+"] Pemission denied.");	}	LOG.debug("--------col------------"+dbName+"."+tblName+":"+col);	}	}	//判斷是否有必須包含的列,但是在使用中沒有使用的	if(ua.getIncludeColumnList().containsKey(fullTableName)){	List authColList = ua.getIncludeColumnList().get(fullTableName);	for(String authCol:authColList){	if(cols.indexOf(authCol) == -1 ){	throw new AuthorizationException("table ["+fullTableName+"] must contain??column ["+authCol+"]. Pemission denied.");	}	}	}?	}	}	}	}}

        在complie方法中增加自定義權(quán)限認證方法調(diào)用
        public int compile(String command, boolean resetTaskIds){??????try{????	??doAuthorizationExtend(sem);??????}catch (AuthorizationException authExp){????	??errorMessage ="FAILED:Kuxun Authorization failed:" + authExp.getMessage()??????????+ " Please contact anyoneking@163.com for your information." ;????	??console.printError("Kuxun Authorization failed:" + authExp.getMessage()??????????????????+ "Please contact anyoneking@163.com for your information.");??????????????return 403;??????}}請注意:errorMessage在獲取異常后,必須要進行賦值,否則通過hive client訪問的時候,出現(xiàn)異常的時候不會給出異常提示,只會給出NUll。

        以上完成后,重新打包,放到hivelib下面就ok了。
        同時要注意修改hive-site.xml以傳遞對應(yīng)的信息。

        ??hive.kuxun.username??test???hive.kuxun.password??test?????hive.kuxun.hiveserver.url??jdbc:mysql://localhost:3306/hiveserver??hiveserver jdbc connection url???hive.kuxun.hiveserver.username??test??username to use against hiveserver database???hive.kuxun.hiveserver.password??test??password to use against hiveserver database

        聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        自定義Hive權(quán)限控制(4)擴展Hive以實現(xiàn)自定義權(quán)限控制

        自定義Hive權(quán)限控制(4)擴展Hive以實現(xiàn)自定義權(quán)限控制:在前3節(jié)中,已經(jīng)就 hive 權(quán)限控制 進行了基礎(chǔ)數(shù)據(jù)的維護,現(xiàn)在用戶權(quán)限配置功能已經(jīng)實現(xiàn)。并且可以通過界面話的方式進行維護和管理。接著,最重要的事情就是針對Hive源碼的修改。 主要是針對org.apache. hadoop . hive .conf.HiveConf及org
        推薦度:
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲AV无码成人网站在线观看| 久久亚洲2019中文字幕| 无码乱人伦一区二区亚洲| 国产无遮挡又黄又爽免费网站| 免费无码又爽又刺激高潮 | 日本阿v免费费视频完整版| 亚洲国产精品综合久久2007| 91免费在线播放| 亚洲成a人片在线观看中文!!!| 男女一进一出抽搐免费视频 | 一级毛片不卡片免费观看| 三年片在线观看免费大全| 亚洲一线产区二线产区区| 免费鲁丝片一级在线观看| 国产亚洲视频在线观看| 国产日韩成人亚洲丁香婷婷| 国产啪精品视频网站免费尤物 | 国产亚洲午夜精品| 精品国产香蕉伊思人在线在线亚洲一区二区| 久久久久亚洲AV无码去区首| 免费一级毛片不卡不收费| 美女在线视频观看影院免费天天看 | 全免费毛片在线播放| 亚洲乱理伦片在线观看中字| 免费欧洲美女牲交视频| 亚洲国产综合在线| 在线jyzzjyzz免费视频| 一级毛片一级毛片免费毛片| 亚洲第一视频网站| 成人免费视频国产| a级午夜毛片免费一区二区| 亚洲制服丝袜一区二区三区| 免费一级毛片清高播放| 无码av免费一区二区三区试看| 亚洲AV无码日韩AV无码导航| 在线看片无码永久免费视频| 免费大片av手机看片| 亚洲视频网站在线观看| 婷婷亚洲天堂影院| 最近2019年免费中文字幕高清| 亚洲一卡2卡三卡4卡无卡下载|