您的位置:首页 > 其它

Voltdb 源码阅读

2015-12-08 18:51 246 查看
入口文件:https://github.com/VoltDB/voltdb/blob/master/src/frontend/org/voltdb/VoltDB.java

主要就是Configuration类保存运行参数,主要的如 pathToDeployment(指向deployment.xml),m_startAction(create ,rejoin,,),端口等

    一个单体voltdb实例 https://github.com/VoltDB/voltdb/blob/master/src/frontend/org/voltdb/RealVoltDB.java
主要voltdb 实例类:https://github.com/VoltDB/voltdb/blob/master/src/frontend/org/voltdb/RealVoltDB.java

m_config.m_computationCoreBindings 是个 ArrayQueue<String>,ThreadFactory从这个里面取得元素创建一个线程到线程池{computation threadpool 个数为核心数/4,用的是ThreadPoolExecutor},由MoreExecutors封装{任务执行完有回调通知}
http://guojuanjun.blog.51cto.com/277646/948298/
public final Queue<String> m_networkCoreBindings = new ArrayDeque<String>();

对应buildMeshCluster里的HostMessenger的VoltNetworkPool,cpu/4个线程,所以VoltNetworkPool含有VoltNetwork[cpu/4]。

public final Queue<String> m_computationCoreBindings = new ArrayDeque<String>();

对应private ListeningExecutorService m_computationService; 是个ExecuteService的线程池,cpu/4个线程。

public final Queue<String> m_executionCoreBindings = new ArrayDeque<String>();

VoltNetwork是一个实现了Runnable的类;

HostMessager还包含一个SocketJoiner类实例,顾名思义,看下面:

/**
* SocketJoiner runs all the time listening for new nodes in the cluster. Since it is a dedicated thread
* it is able to block while a new node joins without disrupting other activities.
*
* At startup socket joiner will connect to the rest of the cluster in the start method if it fails
* to bind to the leader address.
*
* If it binds to the leader address and becomes the leader the start method returns immediately and runPrimary
* is run from a separate thread. runPrimary will wait for the countdown latch for bootstrapping zk to count down
* before accepting new connections
*/

--host 指定的机器,运行runPrimary,其它机器执行connectToPrimary。第一个连上primary,第二个连上primary,被告知第一个的监听地址,于是再连接第一个;第三个连上 primary后,会被告知第一个和第二个host的监听地址,再连上第一个和第二个。如此进行。 知道最后所有节点都会两两之间存在连接。

AgreementSite代表一个zk node,zk 的一个非持久的内置实现。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: