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

php 网站超市营销推广费用包括哪些

php 网站超市,营销推广费用包括哪些,wordpress 闭站,wordpress免费云储存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://www.yayakq.cn/news/509562/

相关文章:

  • 做网站西美花街中国亚马逊官网
  • 南京重庆网站建设修改wordpress登陆用户名和密码
  • 滨江做网站网站网站二维码收钱怎么做的
  • 河北省住房建设厅网站首页wordpress版权信息更换
  • 南京营销型网站建设公司免费论坛网站建设
  • 谷歌推广网站价格划算的网站开发
  • 苏州正规网站建设概况优化wordpress
  • 网站登陆注册怎么做邢台招聘信息最新招聘2023
  • 甘肃机械化建设工程有限公司网站广州seo关键字推广
  • 贴吧怎么做网站视频人力外包和项目外包哪个好
  • 素材网站视频网站备案怎样提交管局
  • 网站说服力营销型网站策划旅游药都网站建设方案
  • 集团公司网站源码下载网站建设的完整流程包括哪些
  • 中国建设银行租赁网站熊掌号网站怎么做
  • 使用nas建设网站苏州市现代建设咨询管理公司
  • 用帝国cms做企业网站版权网站外链建设与文章发布规范
  • 北京网站优化校学费阿里巴巴外贸网站登录
  • 哈尔滨如何免费制作网站汇鑫网站建设方便
  • 网站架构设计师有哪些学校可以报考怎么给企业制作网站
  • 商城模板建站价格哈尔滨关键词优化平台
  • jetty网站开发城乡与建设厅网站首页
  • 柳州哪家网站建设专业wordpress图片文件目录下
  • 企业网站快速建站装修公司需要什么资质
  • 网站模板如何用展厅设计说明
  • 站群建站系统昆明网站建设哪个公司好
  • 做网站开发要具备什么知识简单的微信小程序项目
  • 河北网站建设报价云彩网站
  • 房产网站建设什么类型哪个网站做的效果图好
  • 网站域名登陆地址查询网络市场营销的概念
  • 陕西建设网综合便民服务中心网站灯塔网站建设