本文主要基于 SkyWalking 3.2.6 正式版

  • 1. 概述

  • 2. collector-cache-define

    • 2.1 CacheModule

    • 2.2 ApplicationCacheService

    • 2.3 InstanceCacheService

    • 2.4 ServiceNameCacheService

  • 3. collector-cache-guava-provider

    • 3.1 CacheModuleGuavaProvider

    • 3.2 ApplicationCacheGuavaService

    • 3.3 InstanceCacheGuavaService

    • 3.4 ServiceNameCacheGuavaService


1. 概述

本文主要分享 SkyWalking Collector Cache Module,缓存组件。该组件用于缓存 Application 、Instance 、ServiceName 等常用不变的数据,以提升性能。

友情提示:本文内容较为简单,胖友可快速阅读。

Cache Module 在 SkyWalking 架构图处于如下位置( 红框 ) :

FROM https://github.com/apache/incubating-skywalking

下面我们来看看整体的项目结构,如下图所示 :

  • collector-cache-define :定义缓存组件接口。

  • collector-cache-guava-provider :基于 Google Guava 的缓存组件实现。

下面,我们从接口到实现的顺序进行分享。

2. collector-cache-define

collector-cache-define :定义队列组件接口。项目结构如下 :

2.1 CacheModule

org.skywalking.apm.collector.cache.CacheModule ,实现 Module 抽象类,缓存 Module 。

#name() 实现方法,返回模块名为 "cache" 。

#services() 实现方法,返回 Service 类名:ApplicationCacheService 、InstanceCacheService 、ServiceIdCacheService 、ServiceNameCacheService 。

2.2 ApplicationCacheService

org.skywalking.apm.collector.cache.service.ApplicationCacheService ,应用数据缓存服务接口

  • Table :org.skywalking.apm.collector.storage.table.register.ApplicationTable

  • Data :org.skywalking.apm.collector.storage.table.register.Application

2.3 InstanceCacheService

org.skywalking.apm.collector.cache.service.InstanceCacheService ,应用实例数据缓存服务接口

  • Table :org.skywalking.apm.collector.storage.table.register.InstanceTable

  • Data :org.skywalking.apm.collector.storage.table.register.Instance

2.4 ServiceNameCacheService

org.skywalking.apm.collector.cache.service.ServiceNameCacheService ,服务名数据缓存服务接口
org.skywalking.apm.collector.cache.service.ServiceIdCacheService ,服务编号数据缓存服务接口

  • Table :org.skywalking.apm.collector.storage.table.register.ServiceNameTable

  • Data :org.skywalking.apm.collector.storage.table.register.ServiceName

3. collector-cache-guava-provider

collector-cache-guava-provider ,基于 Google Guava 的缓存组件实现。

项目结构如下 :

默认配置,在 application-default.yml 已经配置如下:

cache:  guava:

3.1 CacheModuleGuavaProvider

org.skywalking.apm.collector.cache.guava.CacheModuleGuavaProvider ,实现 ModuleProvider 抽象类,基于 Guava 的缓存组件服务提供者。

#name() 实现方法,返回组件服务提供者名为 "guava" 。

module() 实现方法,返回组件类为 CacheModule 。

#requiredModules() 实现方法,返回依赖组件为空。


#prepare(Properties) 实现方法,执行准备阶段逻辑。

  • 第 44 行 :创建 ApplicationCacheGuavaService 、InstanceCacheGuavaService 、ServiceIdCacheGuavaService 、ServiceNameCacheGuavaService 对象,并调用 #registerServiceImplementation() 父类方法,注册到 services 。

#start() 实现方法,方法为空。

#notifyAfterCompleted() 实现方法,方法为空。

3.2 ApplicationCacheGuavaService

org.skywalking.apm.collector.cache.guava.service.ApplicationCacheGuavaService ,实现 ApplicationCacheService 接口,基于 Guava 的应用数据缓存服务实现类

  • EsDAO :org.skywalking.apm.collector.storage.es.dao.ApplicationEsCacheDAO

3.3 InstanceCacheGuavaService

org.skywalking.apm.collector.cache.guava.service.InstanceCacheGuavaService ,实现 InstanceCacheService 接口,基于 Guava 的应用实例数据缓存服务实现类

  • EsDAO :org.skywalking.apm.collector.storage.es.dao.InstanceEsCacheDAO

3.4 ServiceNameCacheGuavaService

org.skywalking.apm.collector.cache.guava.service.ServiceNameCacheGuavaService ,实现 ServiceNameCacheService 接口,基于 Guava 的服务名数据缓存服务实现类
org.skywalking.apm.collector.cache.guava.service.ServiceIdCacheGuavaService ,实现 ServiceNameCacheService 接口,基于 Guava 的服务编号数据缓存服务实现类

  • EsDAO :org.skywalking.apm.collector.storage.es.dao.ServiceNameEsCacheDAO


©著作权归作者所有:来自51CTO博客作者mb5ff80520dfa04的原创作品,如需转载,请注明出处,否则将追究法律责任

更多相关文章

  1. EVCache缓存在 Spring Boot中的实战
  2. 轻量级 Memcached缓存代理 twemproxy实践
  3. Springboot应用缓存实践之:Ehcache加持
  4. 从输入 URL 到展现涉及哪些缓存环节(非常详细)
  5. 熔断器 Hystrix 源码解析 —— 执行结果缓存
  6. 超实用的VueJS滑块组件,支持级联滑动和渐变色
  7. AngularJS 日期时间选择组件(附详细使用方法)
  8. 【前端词典】输入 URL 到展现涉及的缓存环节
  9. Mybatis 配置 自定义缓存 ehcache

随机推荐

  1. 不同类型业务系统技术架构的差异化
  2. 程序员何苦为难程序员
  3. 推荐系统实战
  4. 程序员,你的一千万在哪里
  5. 图解HTTP(一)
  6. 推荐
  7. 《推荐系统实践》—— 读后总结
  8. 图解HTTP(二)
  9. 《Effective Java》—— 读后总结
  10. 《一线架构师实践指南》—— 读后总结