Maxith's Bolg


  • 首页

  • 分类

  • 归档

  • 标签

spring-cloud 学习笔记(3)

发表于 2017-09-04 | 分类于 spring-cloud |

STEP 3 : 熔断器

1. 什么是熔断器

熔断器(CircuitBreaker)

“熔断器(CircuitBreaker)”本身是一种开关装置,用于在电路上保护线路过载,当线路中有电器发生短路时,“熔断器”能够及时的切断故障电路,防止发生过载、发热、甚至起火等严重后果。

在现代分布式应用的日常的生产过程中,我们的应用服务总是会出现各种各样的问题比如网络连接缓慢、资源繁忙,暂时不可用,服务脱机等导致服务稳定受到影响,一旦其中一个关联了子服务的服务受到影响后,子服务也会受到影响,然后一级一级的服务就会接连崩溃,最后导致整个系统的雪崩.这样的情况,我相信没有人希望出现。

而熔断器模式解决了大型分布式系统因为服务稳定性异常导致系统雪崩的问题,它能在服务阻塞(BLOCK)的时候通过断路器的故障监控(类似熔断保险丝),向调用方返回一个错误响应,而不是长时间的等待,防止服务雪崩的发生。

阅读全文 »

spring-cloud 学习笔记(2)

发表于 2017-09-01 | 分类于 spring-cloud |

STEP 2 : 微服务的消费

在上一个笔记中我们学习了服务的注册与发现,那么已经有了服务提供方,接下来会有服务的消费方,这次笔记的主要内容就是 如何消费微服务.

基本配置

1.pom 设置

  
<dependencies>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-eureka</artifactId>
	</dependency>
</dependencies>

pom配置需要注意的一个问题:

调用的客户端框架需要和服务端所使用的框架一致,比如说我们使用eureka框架作为服务端,那么客户端也需要使用eureka框架.

阅读全文 »

注解@EnableDiscoveryClient,@EnableEurekaClient的区别[转]

发表于 2017-08-30 | 分类于 spring-cloud |

注解@EnableDiscoveryClient,@EnableEurekaClient的区别[转]

SpringCloud中的Discovery Service有多种实现,比如:eureka, consul, zookeeper。

1.`@EnableDiscoveryClient`注解是基于`spring-cloud-commons`依赖,并且在classpath中实现;
2,`@EnableEurekaClient`注解是基于`spring-cloud-netflix`依赖,只能为eureka作用;

如果你的classpath中添加了eureka,则它们的作用是一样的。

来源:

夜闯秋名山吃瓜皮 : 注解@EnableDiscoveryClient,@EnableEurekaClient的区别

阅读全文 »

java 算法系列 - 笛卡尔积算法

发表于 2017-08-30 | 分类于 java算法 |

STEP 1 : 什么是笛卡尔积

来自维基百科-笛卡儿积的解释:

在数学中,两个集合X和Y的笛卡儿积(Cartesian product),又称直积,在集合论中表示为X × Y,是所有可能的有序对组成的集合,其中有序对的第一个对象是X的成员,第二个对象是Y的成员。

来自百度百科-笛卡儿积的解释:

笛卡尔乘积是指在数学中,两个集合X和Y的笛卡尓积(Cartesian product),又称直积,表示为X × Y,第一个对象是X的成员而第二个对象是Y的所有可能有序对的其中一个成员。

阅读全文 »

spring-cloud 学习笔记(1)

发表于 2017-08-29 | 分类于 spring-cloud |

STEP 1 : Eureka 微服务的注册

作为spring-cloud中最重要最核心的组件,spring-cloud学习的第一步当然是学习使用Eureka.

首先让我们先了解一下Eureka的背景.

Eureka是Netflix开源的一款提供服务注册和发现的产品,它提供了完整的服务注册和发现。也是spring-cloud体系中最重要最核心的组件之一。

既然是提供服务注册与,那当然需要有server(服务注册中心) 、client(服务提供方) 以及** consumer(服务消费者)**,由于篇幅有限,接下来,我们只针对对server和client进行学习.

阅读全文 »

spring-cloud 学习笔记(0)

发表于 2017-08-28 | 分类于 spring-cloud |

STEP 0 : hello spring-cloud

1.什么是spring-cloud

官方介绍

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state). Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud developers can quickly stand up services and applications that implement those patterns. They will work well in any distributed environment, including the developer’s own laptop, bare metal data centres, and managed platforms such as Cloud Foundry.

GOOGLE翻译:

Spring Cloud为开发人员提供快速构建的工具 分布式系统中的一些常见模式 (例如,配置管理,服务发现, 断路器,智能路由,微代理, 控制器,一次性令牌,全局锁,领导 选举,分布式会话,集群状态)。 分布式系统的引导样板模式, 并使用Spring Cloud开发人员可以快速建立服务 实现这些模式的应用程序。 他们将在任何分布式环境中运行良好, 包括开发商自己的笔记本电脑,裸机数据中心, 以及诸如Cloud Foundry之类的管理平台。

阅读全文 »

CAS5.1.x overlay使用体验[转]

发表于 2017-08-24 | 分类于 cas |

CAS5.1.x overlay使用体验,希望能帮助大家少遇到一些坑[转]。

官方文档:

https://apereo.github.io/cas/5.1.x/installation/Maven-Overlay-Installation.html

1)准备工作

编辑hosts

增加 127.0.0.1cas.example.org cas-overlay github地址

https://github.com/apereo/cas-overlay-template

2)证书相关

注:JAVA_HOME目录的jre下cacerts keytool -list -keystore cacerts -alias cas

生成证书,此处CN为前面设定的host的域名

阅读全文 »

安装Redis 2.8.18时报错

发表于 2016-11-24 | 分类于 redis |

安装Redis 2.8.18时报错:

zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2

原因分析

在README 有这个一段话。

Allocator

Selecting a non-default memory allocator when building Redis is done by setting
the MALLOC environment variable. Redis is compiled and linked against libc
malloc by default, with the exception of jemalloc being the default on Linux
systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc.

To force compiling against libc malloc, use:

% make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

% make MALLOC=jemalloc

阅读全文 »

安装Redis 错误You need tcl 8.5 or newer in order to run the Redis test.

发表于 2016-11-14 | 分类于 redis |

You need tcl 8.5 or newer in order to run the Redis test.

安装Redis,运行make test的时候出错:

You need tcl 8.5 or newer in order to run the Redis test make: *** [test] Error 1

安装tcl就行了:

wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gzsudotar xzvf tcl8.6.1-src.tar.gz  -C /usr/local/
cd  /usr/local/tcl8.6.1/unix/
sudo ./configure
sudomakesudomakeinstall
阅读全文 »

解决maven报错[转]

发表于 2016-05-05 | 分类于 maven |

导入Myabtis源码后,POM文件会报出如下异常:

Plugin execution not covered by lifecycle configuration org.sonatype.plugins:jarjar-maven-plugin  
Plugin execution not covered by lifecycle configuration org.apache.felix:maven-bundle-plugin

在这里找到了问题的原因和解决办法:

http://wiki.eclipse.org/M2E_plugin_execution_not_covered

m2e在eclipse中执行maven生命周期构建,配置完毕后执行Maven构建后的项目。这是被多个不同Maven目标控制的。有些目标在workspace层面控制,有些在project/.setting下控制。

阅读全文 »
1 2
Maxith Zhou

Maxith Zhou

25 日志
9 分类
RSS
GitHub 知乎 V2EX
© 2017 - 2018 Maxith Zhou
由 Jekyll 强力驱动
主题 - NexT.Muse
本站访客数 人次 本站总访问量 次