diff --git a/README.md b/README.md index 04bf376c..50d0db7b 100755 --- a/README.md +++ b/README.md @@ -327,9 +327,10 @@ JVM 这部分内容主要参考 [JVM 虚拟机规范-Java8 ](https://docs.oracle ### 理论&算法&协议 -- [CAP 理论和 BASE 理论解读](./docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md) -- [Paxos 算法解读](./docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md) -- [Raft 算法解读](./docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md) +- [CAP 理论和 BASE 理论详解](./docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md) +- [Paxos 算法详解](./docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md) +- [Raft 算法详解](./docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md) +- [Gossip 协议详解](./docs/distributed-system/theorem&algorithm&protocol/gossip-protocl.md) ### API 网关 diff --git a/docs/.vuepress/sidebar.ts b/docs/.vuepress/sidebar.ts index cb44f1ad..c0b07fb9 100644 --- a/docs/.vuepress/sidebar.ts +++ b/docs/.vuepress/sidebar.ts @@ -430,7 +430,12 @@ export const sidebarConfig = sidebar({ text: "理论&算法&协议", icon: "suanfaku", prefix: "theorem&algorithm&protocol/", - children: ["cap&base-theorem", "paxos-algorithm", "raft-algorithm"], + children: [ + "cap&base-theorem", + "paxos-algorithm", + "raft-algorithm", + "gossip-protocl", + ], }, "api-gateway", "distributed-id", diff --git a/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-in-action.md b/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-in-action.md index 5f1cd0c5..b5b6aaaf 100644 --- a/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-in-action.md +++ b/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-in-action.md @@ -1,4 +1,9 @@ -# ZooKeeper 实战 +--- +title: ZooKeeper 实战 +category: 分布式 +tag: + - ZooKeeper +--- 这篇文章简单给演示一下 ZooKeeper 常见命令的使用以及 ZooKeeper Java客户端 Curator 的基本使用。介绍到的内容都是最基本的操作,能满足日常工作的基本需要。 diff --git a/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-intro.md b/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-intro.md index 4a64788e..2cefa604 100644 --- a/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-intro.md +++ b/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-intro.md @@ -1,6 +1,9 @@ - - -# ZooKeeper 相关概念总结(入门) +--- +title: ZooKeeper 相关概念总结(入门) +category: 分布式 +tag: + - ZooKeeper +--- 相信大家对 ZooKeeper 应该不算陌生。但是你真的了解 ZooKeeper 到底有啥用不?如果别人/面试官让你给他讲讲对于 ZooKeeper 的认识,你能回答到什么地步呢? diff --git a/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-plus.md b/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-plus.md index a5216431..6ac968ae 100644 --- a/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-plus.md +++ b/docs/distributed-system/distributed-process-coordination/zookeeper/zookeeper-plus.md @@ -1,4 +1,9 @@ -# ZooKeeper 相关概念总结(进阶) +--- +title: ZooKeeper 相关概念总结(进阶) +category: 分布式 +tag: + - ZooKeeper +--- > [FrancisQ](https://juejin.im/user/5c33853851882525ea106810) 投稿。 @@ -90,7 +95,7 @@ ![3PC流程](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/80854635d48c42d896dbaa066abf5c26~tplv-k3u1fbpfcp-zoom-1.image) -> 这里是 `3PC` 在成功的环境下的流程图,你可以看到 `3PC` 在很多地方进行了超时中断的处理,比如协调者在指定时间内为收到全部的确认消息则进行事务中断的处理,这样能 **减少同步阻塞的时间** 。还有需要注意的是,**`3PC` 在 `DoCommit` 阶段参与者如未收到协调者发送的提交事务的请求,它会在一定时间内进行事务的提交**。为什么这么做呢?是因为这个时候我们肯定**保证了在第一阶段所有的协调者全部返回了可以执行事务的响应**,这个时候我们有理由**相信其他系统都能进行事务的执行和提交**,所以**不管**协调者有没有发消息给参与者,进入第三阶段参与者都会进行事务的提交操作。 +> 这里是 `3PC` 在成功的环境下的流程图,你可以看到 `3PC` 在很多地方进行了超时中断的处理,比如协调者在指定时间内未收到全部的确认消息则进行事务中断的处理,这样能 **减少同步阻塞的时间** 。还有需要注意的是,**`3PC` 在 `DoCommit` 阶段参与者如未收到协调者发送的提交事务的请求,它会在一定时间内进行事务的提交**。为什么这么做呢?是因为这个时候我们肯定**保证了在第一阶段所有的协调者全部返回了可以执行事务的响应**,这个时候我们有理由**相信其他系统都能进行事务的执行和提交**,所以**不管**协调者有没有发消息给参与者,进入第三阶段参与者都会进行事务的提交操作。 总之,`3PC` 通过一系列的超时机制很好的缓解了阻塞问题,但是最重要的一致性并没有得到根本的解决,比如在 `PreCommit` 阶段,当一个参与者收到了请求之后其他参与者和协调者挂了或者出现了网络分区,这个时候收到消息的参与者都会进行事务提交,这就会出现数据不一致性问题。 diff --git a/docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md b/docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md index 9d74ccc7..cb53b519 100644 --- a/docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md +++ b/docs/distributed-system/theorem&algorithm&protocol/cap&base-theorem.md @@ -2,7 +2,7 @@ title: CAP & BASE理论详解 category: 分布式 tag: - - 分布式协议&算法 + - 分布式理论 --- 经历过技术面试的小伙伴想必对 CAP & BASE 这个两个理论已经再熟悉不过了! diff --git a/docs/distributed-system/theorem&algorithm&protocol/gossip.md b/docs/distributed-system/theorem&algorithm&protocol/gossip-protocl.md similarity index 92% rename from docs/distributed-system/theorem&algorithm&protocol/gossip.md rename to docs/distributed-system/theorem&algorithm&protocol/gossip-protocl.md index fcf42383..261bdcdc 100644 --- a/docs/distributed-system/theorem&algorithm&protocol/gossip.md +++ b/docs/distributed-system/theorem&algorithm&protocol/gossip-protocl.md @@ -1,8 +1,9 @@ --- -title: CAP & BASE理论详解 +title: Gossip 协议详解 category: 分布式 tag: - 分布式协议&算法 + - 共识算法 --- ## 背景 @@ -31,7 +32,9 @@ Gossip 协议最早是在 ACM 上的一篇 1987 年发表的论文 [《Epidemic ## Gossip 协议应用 -**1、Redis Cluster 基于 Gossip 协议通信共享信息** +NoSQL 数据库 Redis 和 Apache Cassandra、服务网格解决方案 Consul 等知名项目都用到了 Gossip 协议,学习 Gossip 协议有助于我们搞清很多技术的底层原理。 + +我们这里以 Redis Cluster 为例说明 Gossip 协议的实际应用。 我们经常使用的分布式缓存 Redis 的官方集群解决方案(3.0 版本引入) Redis Cluster 就是基于 Gossip 协议来实现集群中各个节点数据的最终一致性。 @@ -54,14 +57,6 @@ Redis Cluster 的节点之间会相互发送多种 Gossip 消息: 关于 Redis Cluster 的详细介绍,可以查看这篇文章 [Redis 集群详解(付费)](https://javaguide.cn/database/redis/redis-cluster.html) 。 -**2、NoSQL 数据库 Apache Cassandra 集群通过 Gossip 协议来进行动态管理集群节点状态(节点故障检测和恢复)。** - -**3、服务网格解决方案 Consul 使用 Gossip 协议网络内可靠有效地传输新服务和事件的信息。** - -**4、Bitcoin 使用 Gossip 协议来传播交易和区块信息。不过,为了提供更好的隐私保护,CMU 的研究人员提出 蒲公英协议。** - -还有非常多使用 Gossip 协议的应用,学习 Gossip 协议有助于我们搞清很多技术的底层原理。 - ## Gossip 协议消息传播模式 Gossip 设计了两种可能的消息传播模式:**反熵(Anti-Entropy)** 和 **传谣(Rumor-Mongering)**。 @@ -95,7 +90,7 @@ Gossip 设计了两种可能的消息传播模式:**反熵(Anti-Entropy)** 3. 节点 C 推送数据给 A,节点 A 获取到节点 B,C 中的最新数据。 4. 节点 A 再推送数据给 B 形成闭环,这样节点 B 就获取到节点 C 中的最新数据。 -虽然反熵很简单实用,但是,节点过多或者节点动态变化的话,反熵就不太适用了。这个时候,我们想要实现最终一致性就要靠 **谣言传播(Rumor mongering) ** 。 +虽然反熵很简单实用,但是,节点过多或者节点动态变化的话,反熵就不太适用了。这个时候,我们想要实现最终一致性就要靠 **谣言传播(Rumor mongering)** 。 ### 谣言传播(Rumor mongering) diff --git a/docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md b/docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md index 9c6a7acb..89edd3fd 100644 --- a/docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md +++ b/docs/distributed-system/theorem&algorithm&protocol/paxos-algorithm.md @@ -1,8 +1,9 @@ --- -title: Paxos 算法详细 +title: Paxos 算法详解 category: 分布式 tag: - 分布式协议&算法 + - 共识算法 --- ## 背景 diff --git a/docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md b/docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md index ec8c37e4..86faeca5 100644 --- a/docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md +++ b/docs/distributed-system/theorem&algorithm&protocol/raft-algorithm.md @@ -3,6 +3,7 @@ title: Raft 算法详解 category: 分布式 tag: - 分布式协议&算法 + - 共识算法 --- > 本文由 [SnailClimb](https://github.com/Snailclimb) 和 [Xieqijun](https://github.com/jun0315) 共同完成。 diff --git a/docs/home.md b/docs/home.md index 927b1894..8b3ae45d 100644 --- a/docs/home.md +++ b/docs/home.md @@ -331,6 +331,8 @@ JVM 这部分内容主要参考 [JVM 虚拟机规范-Java8 ](https://docs.oracle - [CAP 理论和 BASE 理论解读](./distributed-system/theorem&algorithm&protocol/cap&base-theorem.md) - [Paxos 算法解读](./distributed-system/theorem&algorithm&protocol/paxos-algorithm.md) - [Raft 算法解读](./distributed-system/theorem&algorithm&protocol/raft-algorithm.md) +- [Gossip 协议详解](./distributed-system/theorem&algorithm&protocol/gossip-protocl.md) + ### API 网关 diff --git a/docs/java/new-features/java17.md b/docs/java/new-features/java17.md index 5b6e8017..23920e9d 100644 --- a/docs/java/new-features/java17.md +++ b/docs/java/new-features/java17.md @@ -139,7 +139,7 @@ static void testFooBar(String s) { 删除远程方法调用 (RMI) 激活机制,同时保留 RMI 的其余部分。RMI 激活机制已过时且不再使用。 -## JEP 409:密封类(转正) +## JEP 409:密封类(转正) 密封类由 [JEP 360](https://openjdk.java.net/jeps/360) 提出预览,集成到了 Java 15 中。在 JDK 16 中, 密封类得到了改进(更加严格的引用检查和密封类的继承关系),由 [JEP 397](https://openjdk.java.net/jeps/397) 提出了再次预览。