Luckylau's Blog

Keep Moving, Keep Learning


  • 首页

  • 分类

  • 关于

  • 归档

  • 标签

  • 搜索
close
Luckylau's Blog

Zookeeper的原理(1)

发表于 2018-03-05 | 分类于 分布式架构

​ Apache Zookeeper是由Apache Hadoop的子项目发展而来,于2010年11月正式成为Apache顶级项目。Zookeeper为分布式应用提供高效且可靠的分布式协调服务,提供了统一命名服务、配置管理、分布式锁等分布式的基础服务。Zookeeper并没有直接采用Paxos算法,而是采用了一种被称为ZAB(Zookeeper Atomic Broadcast)的一致性协议。

什么是Zookeeper

​ Zookeeper是一个开源的分布式协调服务,由Yahoo创建,是Google Chubby的开源实现。Zookeeper将那些复杂且容易出错的分布式一致性服务封装起来,构成一个高效可靠的原语集,并以一系列简单易用的接口提供给用户使用。

阅读全文 »
Luckylau's Blog

常用在线工具

发表于 2018-02-27 | 分类于 Tools

cron在线

http://cron.qqe2.com/

json编辑器

http://www.bejson.com/jsoneditoronline/

Luckylau's Blog

微服务架构之Dubbo服务引用

发表于 2018-02-22 | 分类于 分布式架构

之前讲解了Dubbo服务的发布,下面我们来看看如何进行服务的引用。

在Spring启动的时候,根据dubbo:reference配置会创建一个ReferenceBean。ReferenceBean继承了ReferenceConfig,重点是看init()方法,前面做了很多工作收集配置参数,然后根据参数信息创建代理

阅读全文 »
Luckylau's Blog

微服务架构之Dubbo服务降级(2)

发表于 2018-02-09 | 分类于 分布式架构

​ 在之前微服务架构之Dubbo服务降级(1)讲解了mock的服务降级机制,其实stub可以说范围更广阔,更全面的服务降级。

​ 官方是这样介绍的:Mock是Stub(本地存根)的一个子集,便于服务提供方在客户端执行容错逻辑,因经常需要在出现RpcException(比如网络失败,超时等)时进行容错,而在出现业务异常(比如登录用户名密码错误)时不需要容错,如果用Stub, 需要捕获并依赖RpcException类,而用Mock就可以不依赖RpcException,因为它的约定就是只有出现RpcException时才执行。Mock通常用于服务降级,比如某验权服务,当服务提供方全部挂掉后,客户端不抛出异常,而是通过Mock数据返回授权失败。

阅读全文 »
Luckylau's Blog

微服务架构之Dubbo服务发布(4)

发表于 2018-02-09 | 分类于 分布式架构

zookeeper连接,注册与监听

接着微服务架构之Dubbo服务发布(2)我们详细讲解

连接

1
2
3
4
//首先获取注册中心的地址
URL registryUrl = getRegistryUrl(originInvoker);
//返回的格式是zookeeper://
final Registry registry = getRegistry(originInvoker);

首先第一个重点来了,追踪代码流程,我们先看其时序图,最终registry的实例是ZookeeperRegistry。

阅读全文 »
Luckylau's Blog

微服务架构之Dubbo服务发布(3)

发表于 2018-02-09 | 分类于 分布式架构

netty的启动

接着微服务架构之Dubbo服务发布(2)我们详细讲解

1
final ExporterChangeableWrapper<T> exporter = doLocalExport(originInvoker);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
private <T> ExporterChangeableWrapper<T> doLocalExport(final Invoker<T> originInvoker) {
String key = getCacheKey(originInvoker);
ExporterChangeableWrapper<T> exporter = (ExporterChangeableWrapper<T>) bounds.get(key);
if (exporter == null) {
synchronized (bounds) {
exporter = (ExporterChangeableWrapper<T>) bounds.get(key);
if (exporter == null) {
final Invoker<?> invokerDelegete = new InvokerDelegete<T>(originInvoker, getProviderUrl(originInvoker));
//这里最重要的是调用DubboProtocol的export方法,导出完之后,返回一个新的ExporterChangeableWrapper实例
exporter = new ExporterChangeableWrapper<T>((Exporter<T>) protocol.export(invokerDelegete), originInvoker);
bounds.put(key, exporter);
}
}
}
return exporter;
}
阅读全文 »
1…161718…36
Luckylau

Luckylau

人生识字忧患始

215 日志
14 分类
33 标签
GitHub Weibo
© 2017 - 2022 Luckylau
由 Hexo 强力驱动
主题 - NexT.Pisces