当前位置: 首页 > news >正文

品牌工厂网站建设适合小学生摘抄的新闻2022年

品牌工厂网站建设,适合小学生摘抄的新闻2022年,佛山专业网站建设报价,公司网站制作一般多少钱HiveMetastore 的架构简析 Hive Metastore 是 Hive 元数据管理的服务。可以把元数据存储在数据库中。对外通过 api 访问。 hive_metastore.thrift 对外提供的 Thrift 接口定义在文件 standalone-metastore/src/main/thrift/hive_metastore.thrift 中。 内容包括用到的结构体…

HiveMetastore 的架构简析

Hive Metastore 是 Hive 元数据管理的服务。可以把元数据存储在数据库中。对外通过 api 访问。

hive_metastore.thrift

对外提供的 Thrift 接口定义在文件 standalone-metastore/src/main/thrift/hive_metastore.thrift 中。

内容包括用到的结构体和枚举,和常量,和 rpc Service。
如分区定义如下:

struct Partition {1: list<string> values // string value is converted to appropriate partition key type2: string       dbName,3: string       tableName,4: i32          createTime,5: i32          lastAccessTime,6: StorageDescriptor   sd,7: map<string, string> parameters,8: optional PrincipalPrivilegeSet privileges,9: optional string catName
}

Service的定义了 client 和 server 的 RPC 请求。如增加分区的定义如下:

service ThriftHiveMetastore extends fb303.FacebookService
{Partition add_partition(1:Partition new_part)throws(1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3)
}

ThriftHiveMetastore.java

hive_metastore.thrift 编译之后生成文件 ThriftHiveMetastore.java

ThriftHiveMetastore 结构如下:

public class ThriftHiveMetastore {// Iface 定义了 Service 的所有的接口。仅列出了 add_partitionpublic interface Iface extends com.facebook.fb303.FacebookService.Iface {public Partition add_partition(Partition new_part) throws InvalidObjectException, AlreadyExistsException, MetaException, org.apache.thrift.TException;// omit other methods}// AsyncIface 定义了异步接口。public interface AsyncIface extends com.facebook.fb303.FacebookService .AsyncIface {public void add_partition(Partition new_part, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;// omit other methods}// Client 的实现public static class Client extends com.facebook.fb303.FacebookService.Client implements Iface {public Partition add_partition(Partition new_part) throws InvalidObjectException, AlreadyExistsException, MetaException, org.apache.thrift.TException{send_add_partition(new_part);return recv_add_partition();}// receiveBase 调用 result.read 方法,从 protocalpublic Partition recv_add_partition() throws InvalidObjectException, AlreadyExistsException, MetaException, org.apache.thrift.TException{add_partition_result result = new add_partition_result();receiveBase(result, "add_partition");if (result.isSetSuccess()) {return result.success;}if (result.o1 != null) {throw result.o1;}if (result.o2 != null) {throw result.o2;}if (result.o3 != null) {throw result.o3;}throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "add_partition failed: unknown result");}}// Processor 是服务端处理框架,把所有要处理的 rpc 的名称和处理的映射放到 map里,客户端请求 rpc,先输出 rpc 的名称。public static class Processor<I extends Iface> extends com.facebook.fb303.FacebookService.Processor<I> implements org.apache.thrift.TProcessor {private static <I extends Iface> Map<String,  org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> getProcessMap(Map<String,  org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {processMap.put("add_partition", new add_partition());}}// AsyncProcessorpublic static class AsyncProcessor<I extends AsyncIface> extends com.facebook.fb303.FacebookService.AsyncProcessor<I> {}
}

IHMSHandler

IHMSHandler 是服务器端需要实现的接口。除了 ThriftHiveMetastore.Iface 外,还包括其他一些方法。

IHMSHandler extends ThriftHiveMetastore.Iface, Configurable

HMSHandler

HMSHandler 是服务器端的具体实现。创建服务时,创建 HMSHandler,多个线程调用同一个 HMSHandler 对象来处理 client 的请求。

public class HMSHandler extends FacebookBase implements IHMSHandler {@Overridepublic Partition add_partition(final Partition part)throws InvalidObjectException, AlreadyExistsException, MetaException {return add_partition_with_environment_context(part, null);}// omit other methods@Overridepublic Partition add_partition_with_environment_context(final Partition part, EnvironmentContext envContext)throws InvalidObjectException, AlreadyExistsException,MetaException {startTableFunction("add_partition",part.getCatName(), part.getDbName(), part.getTableName());Partition ret = null;Exception ex = null;try {ret = add_partition_core(getMS(), part, envContext);} catch (Exception e) {ex = e;if (e instanceof MetaException) {throw (MetaException) e;} else if (e instanceof InvalidObjectException) {throw (InvalidObjectException) e;} else if (e instanceof AlreadyExistsException) {throw (AlreadyExistsException) e;} else {throw newMetaException(e);}} finally {endFunction("add_partition", ret != null, ex, part != null ?  part.getTableName(): null);}return ret;}
}

getMS 从 ThreadLocal 里,每个线程单独的。

    @Overridepublic RawStore getMS() throws MetaException {Configuration conf = getConf();return getMSForConf(conf);}public static RawStore getMSForConf(Configuration conf) throws MetaException {RawStore ms = threadLocalMS.get();if (ms == null) {ms = newRawStoreForConf(conf);ms.verifySchema();threadLocalMS.set(ms);ms = threadLocalMS.get();}return ms;}

为什么 Handler 总是一个线程处理一个 client 的请求

如果不是一个线程处理一个 client 的请求,那么 client 先发送一个请求,然后再发送第二个请求时, RawStore ms = threadLocalMS.get(); 就有可能拿到的是其他线程的 ms。

因为 org.apache.thrift.server.TThreadPoolServer.serve方法中。为每个 socket 创建一个 client 对象,并且把 client 的所有请求有 WorkerProcess 进行处理。WorkerProcess 是一个 Runnable。最终提交到 executorService_ 中。

while(!this.stopped_) {try {TTransport client = this.serverTransport_.accept();WorkerProcess wp = new WorkerProcess(client);while(true) {try {this.executorService_.execute(wp);break;} catch (Throwable var13) {// omit}}} catch (TTransportException var14) {// }}
  • WorkerProcess
    WorkerProcess 也是除了设置停止标志外死循环。
do {if (eventHandler != null) {eventHandler.processContext(connectionContext, inputTransport, outputTransport);}} while(!TThreadPoolServer.this.stopped_ && processor.process(inputProtocol, outputProtocol));

processor 类型是 TUGIBasedProcessor。

  • 当客户端正常退出时。
    client 会调用 metastore 的 shutdown 方法。此方法里,清除所有的 threadlocal 对象。
	public void shutdown() {cleanupRawStore();PerfLogger.getPerfLogger(false).cleanupPerfLogMetrics();}protected static void cleanupRawStore() {try {RawStore rs = HMSHandler.getRawStore();if (rs != null) {HMSHandler.logInfo("Cleaning up thread local RawStore...");rs.shutdown();}} finally {HMSHandler handler = HMSHandler.threadLocalHMSHandler.get();if (handler != null) {handler.notifyMetaListenersOnShutDown();}HMSHandler.threadLocalHMSHandler.remove();HMSHandler.threadLocalConf.remove();HMSHandler.threadLocalModifiedConfig.remove();HMSHandler.removeRawStore();HMSHandler.logInfo("Done cleaning up thread local RawStore");}}
  • 异常退出时
    WorkerProcess 的 finally 处理不论是否当前连接调用 shutdown,都执行 eventHandler.deleteContext
finally {if (eventHandler != null) {eventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
}

在 HiveMetaStore.java里定义了 eventHandler, 也调用了 cleanupRawStore,和 shutdown 方法里调用的一样。

@Override
public void deleteContext(ServerContext serverContext, TProtocol tProtocol, TProtocol tProtocol1) {openConnections.decrementAndGet();// If the IMetaStoreClient#close was called, HMSHandler#shutdown would have already// cleaned up thread local RawStore. Otherwise, do it now.HMSHandler.cleanupRawStore();
}

threadLocal 对象的 remove 方法多次调用是没有副作用的。

其他考虑的点

在异常退出时,没有调用 PerfLogger.getPerfLogger(false).cleanupPerfLogMetrics();, 是否会内存溢出。
调用 PerfLogger.getPerfLogger(false). 当参数是 false 时,如果 ThreadLocal 里已经有,则不会创建对象。处理线程的个数是固定的。不会导致内存问题


文章转载自:
http://dinncopropylon.knnc.cn
http://dinncobrutism.knnc.cn
http://dinncolocalizable.knnc.cn
http://dinncocolligate.knnc.cn
http://dinncomisspend.knnc.cn
http://dinncointercourse.knnc.cn
http://dinncoikan.knnc.cn
http://dinncojaded.knnc.cn
http://dinncoirritable.knnc.cn
http://dinncocrassulaceous.knnc.cn
http://dinncorectitude.knnc.cn
http://dinncoflagitate.knnc.cn
http://dinncocraniectomize.knnc.cn
http://dinncobaldheaded.knnc.cn
http://dinncoinfantryman.knnc.cn
http://dinncovenus.knnc.cn
http://dinncosetiform.knnc.cn
http://dinncoandesite.knnc.cn
http://dinncohypothecate.knnc.cn
http://dinncohominoid.knnc.cn
http://dinncobimensal.knnc.cn
http://dinncorestyle.knnc.cn
http://dinncoendothelioma.knnc.cn
http://dinncoexternship.knnc.cn
http://dinncopudibund.knnc.cn
http://dinncovolcanotectonic.knnc.cn
http://dinncodarwinian.knnc.cn
http://dinncoconfidentiality.knnc.cn
http://dinncogenerically.knnc.cn
http://dinncocontortions.knnc.cn
http://dinncoblossomy.knnc.cn
http://dinncononperson.knnc.cn
http://dinncocoalitionist.knnc.cn
http://dinncononmetallic.knnc.cn
http://dinncounaltered.knnc.cn
http://dinncodieresis.knnc.cn
http://dinncosanty.knnc.cn
http://dinncocapsule.knnc.cn
http://dinncounfailingly.knnc.cn
http://dinncocollected.knnc.cn
http://dinncoshaoxing.knnc.cn
http://dinncohissing.knnc.cn
http://dinncosega.knnc.cn
http://dinncoyoruba.knnc.cn
http://dinncoretract.knnc.cn
http://dinncoundefinable.knnc.cn
http://dinncoshrubby.knnc.cn
http://dinncoinsurgency.knnc.cn
http://dinncotumour.knnc.cn
http://dinncospeculation.knnc.cn
http://dinncosouthwesternmost.knnc.cn
http://dinncosorites.knnc.cn
http://dinncosized.knnc.cn
http://dinncodeerskin.knnc.cn
http://dinncopenally.knnc.cn
http://dinncobedpan.knnc.cn
http://dinncokcmg.knnc.cn
http://dinnconuclearism.knnc.cn
http://dinncopayment.knnc.cn
http://dinncoageing.knnc.cn
http://dinncodiscourage.knnc.cn
http://dinncorhabdome.knnc.cn
http://dinncodisazo.knnc.cn
http://dinncopianola.knnc.cn
http://dinncocooperativity.knnc.cn
http://dinncoepilation.knnc.cn
http://dinncolase.knnc.cn
http://dinncounreserve.knnc.cn
http://dinncolakeside.knnc.cn
http://dinncomustafa.knnc.cn
http://dinncoredisplay.knnc.cn
http://dinncogeraniol.knnc.cn
http://dinncounderclay.knnc.cn
http://dinncoentries.knnc.cn
http://dinncohelicoidal.knnc.cn
http://dinncohandstand.knnc.cn
http://dinncotwiggy.knnc.cn
http://dinncoseparatist.knnc.cn
http://dinncoassayer.knnc.cn
http://dinncoemeerate.knnc.cn
http://dinncospag.knnc.cn
http://dinncoguestly.knnc.cn
http://dinncoplutocratic.knnc.cn
http://dinncomagician.knnc.cn
http://dinncojewish.knnc.cn
http://dinncoemitter.knnc.cn
http://dinncooveractive.knnc.cn
http://dinncojubbulpore.knnc.cn
http://dinncodeclinometer.knnc.cn
http://dinncowhitefly.knnc.cn
http://dinncocompilation.knnc.cn
http://dinncoglout.knnc.cn
http://dinncoproscription.knnc.cn
http://dinncobacktrack.knnc.cn
http://dinncoflowerbed.knnc.cn
http://dinncounconventional.knnc.cn
http://dinnconiello.knnc.cn
http://dinncoiritis.knnc.cn
http://dinncoanisocoria.knnc.cn
http://dinncoblay.knnc.cn
http://www.dinnco.com/news/119195.html

相关文章:

  • 手机电子商务网站建设策划书百度seo价格查询系统
  • 域名指向国外服务器做网站湖北百度推广公司
  • 青羊区定制网站建设报价软文广告平台
  • 淘宝联盟 网站建设 内容少关键词优化方法有什么步骤
  • 大型门户网站制作教程邯郸seo
  • 网站综合建设笔记seo快速优化软件网站
  • 邢台网站制作软文撰写
  • 南阳做网站优化公司百度知道答题赚钱
  • nas可以做网站下载服务器吗seo推广软件哪个好
  • 怎样可以做网站色盲测试图第六版
  • 库存网站建设公司注册自己的网站
  • 投诉举报网站 建设方案app推广代理加盟
  • 做外贸自己做网站么seo深圳网络推广
  • 深圳做网页的网站广告营销顾问
  • 旅游公司网站建设方案百度帐号登录
  • 青岛网站制作哪里有线下推广
  • 建设网站设计论文范文网络营销分析报告
  • .net网站做优化万网建站
  • 现在手机网站用什么做如何检测网站是否安全
  • 网站的内容有哪些内容市场监督管理局职责
  • 社团的工商年检网站在哪里做网络营销公司
  • 绵阳建设局官方网站软文推广的优点
  • 网站关键词搜索排名怎么做google竞价推广
  • 网站建设进度及实施过程制作网站的软件
  • 网站推广的8种方法win10优化大师官网
  • joomla可以做预订类网站吗镇江网站定制
  • 华为公司网站建设方案模板宁德市属于哪个省份
  • wordpress的json apiseo排名软件有用吗
  • 中国十大品牌设计公司网站的优化公司
  • 备案网站多少钱企业网站设计价格