ambari-server- 资源provider分析
来源:互联网 发布:伊尔18客机数据 编辑:程序博客网 时间:2024/06/05 04:30
本篇主要讲解资源provider,它们是实际数据的提供者,自然会和原始数据打交道。
原始数据包括mysql等落地数据,还有就是实时数据。
这里还是以 GET /clusters/c1/services/HDFS/components/DATANODE 为例进行,该接口用于获取hdfs服务datanode的信息。
入口为ComponentResourceProvider类的getResources方法,方法首先获得请求对应的response组,response为ServiceComponentResponse类,这里用到了匿名类,该类集成Command类,重载invoke方法。
匿名类
Set<ServiceComponentResponse> responses = getResources(new Command<Set<ServiceComponentResponse>>() { @Override public Set<ServiceComponentResponse> invoke() throws AmbariException { return getComponents(requests); } });
相关实体类
Clusters--》Cluster--》Service--》ServiceComponent
首先获得ServiceComponent类,调用convertToResponse方法,将其转为ServiceComponentResponse,主要包含,服务名等信息。ServiceComponentResponse主要是一些component的基本信息。
目前来看数据信息基本都在内存中存储,没有进行落地,或者说是在启动时加载,运行时不在于数据库产生交互;主要的存储类即为Clusters和Cluster。
clusters
@Singletonpublic class ClustersImpl implements Clusters { private static final Logger LOG = LoggerFactory.getLogger(ClustersImpl.class); //名字为key集群组 private final ConcurrentHashMap<String, Cluster> clusters = new ConcurrentHashMap<String, Cluster>(); //id为key集群组 private final ConcurrentHashMap<Long, Cluster> clustersById = new ConcurrentHashMap<Long, Cluster>(); //名字为key主机组 private final ConcurrentHashMap<String, Host> hosts = new ConcurrentHashMap<String, Host>(); //id为key主机组 private final ConcurrentHashMap<Long, Host> hostsById = new ConcurrentHashMap<Long, Host>(); //主机,集群对应关系;一个主机可以在多个集群 private final ConcurrentHashMap<String, Set<Cluster>> hostClusterMap = new ConcurrentHashMap<String, Set<Cluster>>(); //集群,主机对应关系;一个集群可以对应多个主机 private final ConcurrentHashMap<String, Set<Host>> clusterHostMap = new ConcurrentHashMap<String, Set<Host>>();
Cluster
public class ClusterImpl implements Cluster { 。。。 //对应stack id private StackId desiredStackVersion; //名字为key服务组 private final ConcurrentSkipListMap<String, Service> services = new ConcurrentSkipListMap<>(); //配置信息 /** * [ Config Type -> [ Config Version Tag -> Config ] ] */ private final ConcurrentMap<String, ConcurrentMap<String, Config>> allConfigs = new ConcurrentHashMap<>(); //服务对应 组件 对应 主机信息 /** * [ ServiceName -> [ ServiceComponentName -> [ HostName -> [ ... ] ] ] ] */ private final ConcurrentMap<String, ConcurrentMap<String, ConcurrentMap<String, ServiceComponentHost>>> serviceComponentHosts = new ConcurrentHashMap<>(); //主机对应组件信息 /** * [ HostName -> [ ... ] ] */ private final ConcurrentMap<String, List<ServiceComponentHost>> serviceComponentHostsByHost = new ConcurrentHashMap<>(); //配置组信息 /** * Map of existing config groups */ private final Map<Long, ConfigGroup> clusterConfigGroups = new ConcurrentHashMap<>(); //集群调度执行信息 /** * Map of Request schedules for this cluster */ private final Map<Long, RequestExecution> requestExecutions = new ConcurrentHashMap<>(); //集群全局锁 private final ReadWriteLock clusterGlobalLock; //主机状态切换锁 // This is a lock for operations that do not need to be cluster global private final Lock hostTransitionStateWriteLock; /** * The unique ID of the {@link @ClusterEntity}. */ private final long clusterId; //集群名称 private String clusterName;
后续将分析数据库存储。
阅读全文
0 0
- ambari-server- 资源provider分析
- ambari-server-资源请求分析
- ambari 资源创建代码分析
- Ambari-server-agent交互分析
- Ambari-server源码分析(一):Agent组件
- Ambari-server源码分析(三):HeartbeatHander源码分析
- Ambari-server源码分析:核心类agent.rest.AgentResource
- Ambari-server源码分析:核心类-心跳处理agent.HeartBeatHandler
- Ambari-Server Rest API处理2(Ambari-Server通过Rest API进行服务安装、部署、操作流程+操作源码分析)
- ambari server内存溢出
- ambari-server start 出错
- ambari server架构图
- ambari-server setup
- ambari-server setup过程
- ambari-server start过程
- Ambari源码分析(一):Ambari架构
- Ambari源码分析
- Ambari数据库分析-blueprint
- MongoDB数据库读书笔记
- 设计模式之单例模式
- 爬虫基础理论篇
- vuejs与外界通信
- liunx mysql主从复制
- ambari-server- 资源provider分析
- 对301重定向到HTTPS前遭遇中间人攻击的分析
- ubuntu 如何打开rar 文件及zip 包解压出来的文件名乱码
- 第六届Java软件开发B组
- 数据库连接池 dbcp与c3p0的使用
- 使用+、concat、StringBuilder.append连接字符串效率对比
- 51nod 1101 换零钱
- 畅通工程再续
- Android Studio开发趟过的坑之aar的使用