package org.caesar.hivemeta.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.caesar.hivemeta.common.CommonUtil;
import org.caesar.hivemeta.common.Constants;
import org.caesar.hivemeta.common.Response;
import org.caesar.hivemeta.dao.CommonDML;
import org.caesar.hivemeta.entity.hive.*;
import org.caesar.hivemeta.entity.zeus.TbZeusFile;
import org.caesar.utils.db.ExecutorDB;
import org.caesar.utils.encryption.MD5;
import org.caesar.utils.hdfs.HDFSUtil2;
import org.caesar.utils.hive.HiveDBOperator;
import org.caesar.utils.os.Systems;
import org.caesar.utils.properties.PropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Pattern;
/**
* Created by caesar on 2016/7/4.
*/
@Controller
@RequestMapping("/")
public class CommonController {
private static Logger logger = LoggerFactory.getLogger(LoginController.class);
private static Map<String,HiveDBOperator.HiveQueryResult> searchDatacaches = Collections.synchronizedMap(new HashMap<String, HiveDBOperator.HiveQueryResult>());
ExecutorDB hive = new ExecutorDB(2);
ExecutorDB zeus = new ExecutorDB(3);
@RequestMapping(value = "readDatabaseTree", method = RequestMethod.GET)
@ResponseBody
public String read() throws Exception {
JSONObject rootJson = new JSONObject();
JSONArray arrayJson = new JSONArray();
rootJson.put("sucess","true");
String sql = "select * from DBS";
StringBuffer sb = new StringBuffer();
sb.append("{sucess:true,children:[");
List<TbDBS> dbsList = hive.queryList(sql,TbDBS.class);
for(TbDBS dbs : dbsList) {
List<TbTBLS> tbTBLSList = CommonDML.getTablesListByDBId(dbs.getDbID());
// System.out.println(dbs.getName());
if (tbTBLSList.size() == 0) {
sb.append("{id:\"" + "DB_" + dbs.getDbID() + "\",name:\"" + dbs.getName() + "\",qtip:\"" + dbs.getName() + "[库]\",icon:'static/images/extIcons/icons/database.png',leaf:true},");
} else {
sb.append("{id:\"" + "DB_" + dbs.getDbID() + "\",name:\"" + dbs.getName() + "\",qtip:\"" + dbs.getName() + "[库]\",icon:'static/images/extIcons/icons/database.png',expanded:false,children:[");
for (TbTBLS tbs : tbTBLSList) {
// System.out.println(tbs.getTableName());
sb.append("{id:\"" + "TB_"+ tbs.getTableID() + "\",name:\"" + tbs.getTableName() + "\",qtip:\"" + tbs.getTableName() + "[表]\",icon:'static/images/extIcons/icons/table.png',leaf:true},");
}
sb.deleteCharAt(sb.length() - 1);
sb.append("]},");
}
}
sb.deleteCharAt(sb.length()-1);
sb.append("]}");
System.out.println(sb);
return sb.toString();
}
@RequestMapping(value = "readTablePartitionInfo", method = RequestMethod.GET)
@ResponseBody public String readTablePartition(String tableId) throws Exception {
/**
* 目前分区只支持深度为1的分区
*/
if(tableId.equals("null")){
return null;
}
DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
TbTBLS table = hive.queryOne(String.format("select * from TBLS where TBL_ID='%s'", tableId), TbTBLS.class);
TbPartitionKeys tbPartitionKeys = hive.queryOne(String.format("select * from PARTITION_KEYS where TBL_ID='%s'", tableId), TbPartitionKeys.class);
if(tbPartitionKeys == null){
return null;
}
List<TbPartitions> tbPartitionsList = hive.queryList(String.format("select * from PARTITIONS where TBL_ID='%s' ORDER BY PART_NAME ASC", tableId), TbPartitions.class);
StringBuffer sb = new StringBuffer();
//相关表的创建时间当作该分区的创建时间
String partitionFeildCreateTime = df.format(CommonUtil.convertHiveDateTime(table.getCreateTime()));
//相关表的uri路径即为该分区字段的路径
int id=1953548;//ext中tree类型需要指定id,否则在做节点展开时会有问题
String partitionFeildURI = hive.queryOne(String.format("select LOCATION from SDS where SD_ID='%s'",table.getSdID()), TbSDS.class).getLocation();
sb.append("{\"sucess\":true,\"children\":[{\"name\":\""+tbPartitionKeys.getpKeyName()+"\",\"uri\":\""+partitionFeildURI +
"\",\"createTime\":\"" + partitionFeildCreateTime +
"\",id:\"" + (id++) +
"\",\"tableID\":\"" + table.getTableID() +
"\",\"expanded\":" + true + ",\"children\":[");
for(TbPartitions tbPartitions : tbPartitionsList) {
String partitionValue = tbPartitions.getPartName();
String partitionValueCreateTime = df.format(CommonUtil.convertHiveDateTime(tbPartitions.getCreateTime()));
String partitionValueURI = hive.queryOne(String.format("select LOCATION from SDS where SD_ID='%s'",
tbPartitions.getSdID()), TbSDS.class).getLocation();
sb.append("{\"name\":\"" + partitionValue + "\",\"uri\":\"" + partitionValueURI +
"\",\"tableID\":\"" + table.getTableID() +
"\",id:\"" + (id++) +
"\",\"partitionID\":\"" + tbPartitions.getPartID() +
"\",\"createTime\":\"" + partitionValueCreateTime + "\",\"leaf\":" + true+ "},");
}
if(tbPartitionsList.size()!=0){
sb.deleteCharAt(sb.length()-1);
}
sb.append("]}]}");
System.out.println(sb);
return sb.toString();
}
@RequestMapping(value = "readTableFieldsInfo", method = RequestMethod.GET)
@ResponseBody
public String readTableFieldsInfo(String tableId) throws Exception {
//查看索引字段
Set<String> indexFields = new HashSet<String>();
List<TbIDXS> tbIDXSList = hive.queryList(String.format("select * from IDXS where ORIG_TBL_ID='%s'", tableId), TbIDXS.class);
for(TbIDXS tbIDXS:tbIDXSList) {
TbSDS tbSDS = hive.queryOne(String.format("select * from SDS where SD_ID='%s'", tbIDXS.getSdID()), TbSDS.class);
TbColumns tbColumns = hive.queryOne(String.format("select * from COLUMNS_V2 where CD_ID='%s'", tbSDS.getCdID()), TbColumns.class);
indexFields.add(tbColumns.getColumnName());
}
List<TbColumns> columns = CommonDML.getColumnsListByTableID(tableId);
List<TbPartitionKeys> tbPartitionKeysList = hive.queryList(String.format("select * from PARTITION_KEYS where TBL_ID='%s'", tableId), TbPartitionKeys.class);
StringBuffer json = new StringBuffer();
json.append("{\"sucess\":true,\"total\":" + (columns.size()+tbPartitionKeysList.size()) + ",\"fields\":[");
for(TbPartitionKeys tbPartitionKeys:tbPartitionKeysList){
String comment = tbPartitionKeys.getpKeyComment();
comment=comment == null||"null".equals(comment)?"":comment;
comment=CommonUtil.filterSpecialCharactersForJson(comment);
json.append("{\"field\":\""+tbPartitionKeys.getpKeyName()
+"\",\"tableID\":\""+tableId
+"\",\"fieldID\":\""+(tbPartitionKeys.getIntegerIDX()+100000000)//为了保证前台按照fieldid排序后,索引字段可以放在最后一个位置
+"\",\"type\":\""+tbPartitio
没有合适的资源?快使用搜索试试~ 我知道了~
hive仓库元数据管理系统
共2000个文件
js:1256个
html:204个
gif:197个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 73 浏览量
2024-02-05
23:17:23
上传
评论
收藏 34.07MB ZIP 举报
温馨提示
hive仓库元数据管理系统 hive仓库元数据管理系统 ##有如下功能: 1.hive元数据信息的查看,包括表基本信息,数据库基本信息,字段信息,分区信息,索引信息等; 2.对hive元数据的检索,包括表、字段、数据库等内容的检索 3.元数据信息更新(目前只提供对库、表、字段的描述信息进行更新,通过单击或者双击相应字段可进行相应编辑); 4.对表数据或按分区进行预览 5.对表数据或按分区进行数据EXCEl格式导出 6.数据下载,直接从hdfs上下载原始数据,可以对整表或者分区进行下载 7.表或该表相应分区的删除(需要数据管理员验证码) 8.执行SQl查询与更新操作,并且可以进行查询结果的导出 9.执行SQl查询与更新操作,并且可以进行查询结果的导出 10.如果你的调度系统是zeus,那么可以通过本系统和zeus结合,实现对字段与表在zeus中的开发中心引用关系的查看
资源推荐
资源详情
资源评论
收起资源包目录
hive仓库元数据管理系统 (2000个子文件)
ext-theme-neptune-all-rtl-debug.css 676KB
ext-theme-neptune-all-debug.css 661KB
ext-theme-classic-sandbox-all-rtl-debug.css 640KB
ext-theme-classic-all-rtl-debug.css 633KB
ext-theme-gray-all-rtl-debug.css 625KB
ext-theme-access-all-rtl-debug.css 614KB
ext-theme-classic-sandbox-all-debug.css 584KB
ext-theme-classic-all-debug.css 578KB
ext-theme-gray-all-debug.css 572KB
ext-theme-access-all-debug.css 560KB
ext-theme-neptune-all-rtl.css 317KB
ext-theme-neptune-all.css 311KB
ext-theme-classic-sandbox-all-rtl.css 304KB
ext-theme-classic-all-rtl.css 298KB
ext-theme-gray-all-rtl.css 290KB
ext-theme-access-all-rtl.css 282KB
ext-theme-classic-sandbox-all.css 270KB
ext-theme-classic-all.css 265KB
ext-theme-gray-all.css 258KB
ext-theme-access-all.css 249KB
bubble-panel.css 234KB
nested-loading.css 200KB
bootstrap.css 129KB
bootstrap.min.css 109KB
pictos_base64.css 28KB
ambiance.css 26KB
bootstrap-theme.css 21KB
bootstrap-theme.min.css 18KB
calendar.css 18KB
desktop.css 13KB
welcome.css 10KB
extjs.css 8KB
desktop.css 6KB
codemirror.css 5KB
GroupTabPanel.css 4KB
tasks.css 3KB
Feed-Viewer.css 3KB
Feed-Viewer.css 3KB
layout-browser.css 3KB
statusbar.css 3KB
xq-dark.css 2KB
lesser-dark.css 2KB
page-analyzer.css 2KB
basic.css 2KB
prettify.css 2KB
examples.css 1KB
example.css 1KB
data-view.css 1KB
chooser.css 1KB
organizer.css 1KB
vibrant-ink.css 1KB
rubyblue.css 1KB
portal.css 1KB
toolbars.css 1KB
toolbar.css 1KB
erlang-dark.css 1KB
blackboard.css 1KB
dnd_with_dom.css 1KB
monokai.css 1KB
release-notes.css 1KB
night.css 1KB
eclipse.css 1KB
cobalt.css 1KB
animated-dataview.css 929B
pictos.css 873B
app.css 850B
menus.css 801B
ItemSelector.css 629B
elegant.css 593B
neat.css 524B
writer.css 507B
progress-bar.css 503B
forum-search.css 491B
restful.css 449B
dialog.css 449B
TabScrollerMenu.css 408B
RangeMenu.css 382B
simple-hint.css 368B
example.css 360B
tabs-adv.css 328B
bootstrap.css 315B
multiple-sorting.css 314B
bootstrap.css 285B
qtips.css 251B
slider.css 218B
welcome_ie6.css 193B
GridFilters.css 189B
LiveSearchGridPanel.css 187B
side-tabs.css 178B
tabs.css 144B
ext-sandbox-debug.css 79B
DragSelector.css 76B
ext-sandbox.css 73B
ext-all-neptune-rtl-debug.css 67B
ext-all-rtl-debug.css 67B
ext-all-access-rtl-debug.css 65B
ext-all-debug.css 63B
ext-all-neptune-debug.css 63B
ext-all-access-debug.css 61B
ext-all-rtl.css 61B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
博士僧小星
- 粉丝: 1745
- 资源: 5850
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- ### 词向量的介绍、使用技巧和优缺点的文章
- 基于STM32F103CBT6单片机GC65+MP2625+CC1101 GPSTrack模块板硬件(原理图+PCB)工程文件
- ### 通道处理过程模拟概念、优缺点和使用技巧
- ### MyBatis动态SQL介绍说明、使用技巧和优缺点
- 上传下载仿163网盘无刷新文件上传 for Jsp-fileupload-jsp.rar
- VMware Workstation业界非常稳定且安全的桌面虚拟机软件-计算机上运行多个操作系统,支持Windows、DOS等
- 基于STM8L101F3P6单片机+LY2508A33P+CC1100遥控器硬件(原理图+PCB)工程文件.zip
- 上传下载WAP图铃下载系统-unimg.rar
- YTX-0.1.0-Win
- 上传下载ExtJS 2.2 开源网络硬盘系统-dogdisk.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功