自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

lack的专栏

the quieter you become,the more you are able to hear

  • 博客(232)
  • 资源 (15)
  • 收藏
  • 关注

原创 zookeeper源码 — 三、集群启动—leader、follower同步

zookeeper集群启动的时候,首先读取配置,接着开始选举,选举完成以后,每个server根据选举的结果设置自己的角色,角色设置完成后leader需要和所有的follower同步。上面一篇介绍了leader选举过程,这篇接着介绍启动过程中的leader和follower同步过程。本文结构如下:同步过程总结同步过程设置server当前状态server刚启动的时候都处于LOOKIN...

2019-05-06 00:25:09 369

原创 zookeeper源码 — 二、集群启动—leader选举

上一篇介绍了zookeeper的单机启动,集群模式下启动和单机启动有相似的地方,但是也有各自的特点。集群模式的配置方式和单机模式也是不一样的,这一篇主要包含以下内容:概念介绍:角色,服务器状态服务器组件启动leader选举概念介绍:角色,服务器状态集群模式会有多台server,每台server根据不同的角色会有不同的状态,server状态的定义如下public enum...

2019-04-26 00:43:24 156

原创 zookeeper源码 — 一、单机启动

zookeeper一般使用命令工具启动,启动主要就是初始化所有组件,让server可以接收并处理来自client的请求。本文主要结构:main入口配置解析组件启动main入口我们一般使用命令行工具来部署zk server,zkServer.sh,这个脚本用来启动停止server,通过不同的参数和选项来达到不同的功能。该脚本最后会通过Java执行下面的main方法org.apache...

2019-04-23 00:29:54 141

原创 RocketMQ源码 — 十一、 RocketMQ事务消息

分布式事务是一个复杂的问题,rmq实现了事务的最终一致性,rmq保证本地事务成功消息一定会发送成功并被成功消费,如果本地事务失败了,消息不会被发送。rmq事务消息的实现过程为:producer发送half消息broker确认half消息,并通知producer,表示消息已经成功发送到broker(这个过程其实就是步骤1broker的返回)producer收到half确认消息之后,执行...

2018-05-24 23:48:39 646 3

原创 RocketMQ源码 — 十、 RocketMQ顺序消息

RocketMQ本身支持顺序消息,在使用上发送顺序消息和非顺序消息有所区别发送顺序消息SendResult sendResult = producer.send(msg, new MessageQueueSelector() { @Override public MessageQueue select(List<MessageQueue> mqs, Messag...

2018-05-23 00:38:29 337

原创 RocketMQ源码 — 九、 RocketMQ延时消息

RocketMQ源码 — 九、 RocketMQ延时消息上一节消息重试里面提到了重试的消息可以被延时消费,其实除此之外,用户发送的消息也可以指定延时时间(更准确的说是延时等级),然后在指定延时时间之后投递消息,然后被consumer消费。阿里云的ons还支持定时消息,而且延时消息是直接指定延时时间,其实阿里云的延时消息也是定时消息的另一种表述方式,都是通过设置消息被投递的时间来实现的,但是Ap...

2018-05-10 00:09:17 2010

原创 RocketMQ源码 — 八、 RocketMQ消息重试

RocketMQ的消息重试包含了producer发送消息的重试和consumer消息消费的重试。producer发送消息重试producer在发送消息的时候如果发送失败了,RocketMQ会自动重试。private SendResult sendDefaultImpl( Message msg, final CommunicationMode communicati...

2018-05-08 22:33:18 2119 2

原创 RocketMQ源码 — 七、 RocketMQ高可用(2)

上一篇说明了RocketMQ怎么支持broker集群的,这里接着说RocketMQ实现高可用的手段之一——冗余。RocketMQ部署的时候一个broker set会有一个mater和一个或者多个slave,salve起到的作用就是同步master存储的的消息,并且会接收部分consumer读取消息的请求,下面围绕两个问题来阐明怎么做的冗余:怎么实现冗余冗余之后的消息读取怎么实现冗...

2018-05-06 16:14:41 235

原创 RocketMQ源码 — 六、 RocketMQ高可用(1)

高可用究竟指的是什么?请参考:关于高可用的系统RocketMQ做了以下的事情来保证系统的高可用多master部署,防止单点故障消息冗余(主从结构),防止消息丢失故障恢复(本篇暂不讨论)那么问题来了:怎么支持多broker的写?怎么实现消息冗余?下面分开说明这两个问题多master集群这里强调出master集群,是因为需要多个broker set,而一个...

2018-05-05 14:54:42 269

原创 Java代码风格和在idea中的一些设置

源文件基本设置1. 文件名驼峰标识,.java结尾2. 编码统一为UTF-8Transport…可以解决property文件不能正常显示为中文的问题3. 特殊字符尽量使用转义字符(\t, \n等),而不是八进制的(\012)或者Unicode转义(\u000a)非ascii字符,最容易理解,使用unicode字符,比如:μ,不使用转义:\u03bcs...

2018-04-03 00:18:53 3369 1

原创 dubbo扩展http协议后FullGC

问题dubbo内部定制的版本中,在处理大于10K的包的时候,会出现内存溢出的现象原因是我们在定制dubbo http协议的时候,使用了jboss包里面的HttpRequestDecoder的http decoder方法来解析http协议内容该方法在解析非http协议的大内容时,会出现内存溢出的情况某个服务因为这个问题,出现了full gc 的情况复现问题根据描述复现该问题指定dub

2018-02-28 09:14:22 291

原创 dubbo源码—service reply

dubbo通过netty将请求发送到provider的时候,provider之前已经启动好的NettyServer监听指定端口的时候会收到来自consumer的请求,将通过网络发送来的二进制编码成Request交给上层处理。dubbo从Request中取出调用信息,找到之前的Invoker,然后经过filter,最后通过代理调用到提供服务的方法。provider处理请求的调用堆栈如下:sayH

2018-02-28 09:14:19 176

原创 dubbo源码—service invoke

dubbo的远程调用过程是怎么样的?dubbo远程过程调用经过了那些处理?发起远程调用的时候究竟传了什么数据给provider?要解决这些问题,欢迎一起探讨走进dubbo源码栏目。在service reference中说了consumer端发起调用的时候使用的是远程服务的本地代理,发起调用的堆栈是(上面调用堆栈中的filter链先不介绍了,留在后面service reply中介绍,因为

2018-02-28 09:14:16 1276 1

原创 dubbo源码—service reference

service reference在编写好服务之后,dubbo会将服务export出去,这个时候就可以编写consumer来调用这个服务了。dubbo作为一个rpc框架,使用者使用远程服务和使用本地服务是类似的,不用关心远程服务在哪里,怎么引用的,因为dubbo包含了自动发现和引用服务的功能。dubbo引用服务主要工作:创建proxy和Invoker(DubboInvoker里面会启动Ne

2018-02-28 09:14:13 290

原创 dubbo源码—service export

在应用编写好服务并进行之后,dubbo负责将服务export出去,dubbo export服务的时候主要做了以下几件事:将服务export到本地(根据scope的配置)创建Invoker(启动本地NettyServer,监听指定端口,等待请求)注册provider的信息到registry,供consumer发现并订阅服务订阅registry中的configurator节点,可以动态更改部

2018-02-28 09:14:11 700

原创 dubbo源码—SPI

Java中的SPISPI,Service Provider Interface,java中提供的一种使程序可扩展的方式,系统定义好接口规范,供其他服务提供方实现,服务提供方将自己jar包META-INF/services下新建一个以接口全名称定义的文件,里面内容写上自己服务的实现的类名,每一行代表一个实现,服务使用方可以通过ServiceLoader.load加载所有的服务,然后判断可以使用的服

2018-02-28 09:14:08 181

原创 dubbo源码—dubbo自定义spring xml标签

dubbo为了和spring更好的集成,提供了一些xml配置标签,也就是自定义标签spring自定义标签spring自定义标签的方式如下:设计配置属性和JavaBean编写xsd文件,校验xml属性和便于编辑器提示编写NamespaceHandler和BeanDefinitionParser解析xml对应的标签编写spring.handlers和spring.schemas串联起所有

2018-02-28 09:14:05 184

原创 dubbo源码—dubbo简介

dubbo是一个RPC框架,应用方像使用本地service一样使用dubbo service。dubbo体系架构上图中的角色:最重要的是consumer、registry和providerconsumer:服务调用者provider:服务提供者registry:供provider注册服务和consumer发现服务monitor:监控调用过程的一些参数,比如:调用次数countcon

2018-02-28 09:14:02 310

原创 leetcode — reorder-list

/** * Source : https://oj.leetcode.com/problems/reorder-list/ * * Given a singly linked list L: L0→L1→…→Ln-1→Ln, * reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… * * You must do this in-place without al

2018-02-28 09:13:59 138

原创 leetcode — linked-list-cycle

/** * Source : https://oj.leetcode.com/problems/linked-list-cycle/ * * Given a linked list, determine if it has a cycle in it. * * Follow up: * Can you solve it without using extra space? */pu

2018-02-28 09:13:57 158

原创 leetcode — linked-list-cycle-ii

/** * Source : https://oj.leetcode.com/problems/linked-list-cycle-ii/ * * Given a linked list, return the node where the cycle begins. If there is no cycle, return null. * * Follow up: * Can you

2018-02-28 09:13:54 133

原创 leetcode — word-break-ii

import java.util.*;/** * Source : https://oj.leetcode.com/problems/word-break-ii/ * * Given a string s and a dictionary of words dict, add spaces in s to construct a sentence * where each word i

2018-02-28 09:13:52 120

原创 leetcode — word-break

import java.util.Arrays;import java.util.HashSet;import java.util.Set;/** * Source : https://oj.leetcode.com/problems/word-break/ * * * Given a string s and a dictionary of words dict, determi

2018-02-28 09:13:49 120

原创 leetcode — copy-list-with-random-pointer

import java.util.*;/** * * Source : https://oj.leetcode.com/problems/copy-list-with-random-pointer/ * * A linked list is given such that each node contains an additional random pointer * which

2018-02-28 09:13:46 97

原创 leetcode — single-number-ii

/** * Source : https://oj.leetcode.com/problems/single-number-ii/ * * Given an array of integers, every element appears three times except for one. Find that single one. * * Note: * Your algorit

2018-02-28 09:13:43 181

原创 leetcode — single-number

/** * Source : https://oj.leetcode.com/problems/single-number/ * * * Given an array of integers, every element appears twice except for one. Find that single one. * * Note: * Your algorithm sho

2018-02-28 09:13:41 76

原创 leetcode — candy

/** * Source : https://oj.leetcode.com/problems/candy/ * * There are N children standing in a line. Each child is assigned a rating value. * * You are giving candies to these children subjected t

2018-02-28 09:13:38 89

原创 leetcode — gas-station

/** * Source : https://oj.leetcode.com/problems/gas-station/ * * There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. * * You have a car with an unlimi

2018-02-28 09:13:35 154

原创 leetcode — clone-graph

import java.util.*;/** * Source : https://oj.leetcode.com/problems/clone-graph/ * * * Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. * * OJ's u

2018-02-28 09:13:33 118

原创 leetcode — palindrome-partitioning

import java.util.ArrayList;import java.util.Arrays;import java.util.List;/** * Source : https://oj.leetcode.com/problems/palindrome-partitioning/ * * * Given a string s, partition s such that

2018-02-28 09:13:30 142

原创 leetcode — palindrome-partitioning-ii

import java.util.Arrays;/** * * Source : https://oj.leetcode.com/problems/palindrome-partitioning-ii/ * * Given a string s, partition s such that every substring of the partition is a palindrome

2018-02-28 09:13:27 120

原创 leetcode — surrounded-regions

import java.util.Arrays;import java.util.Stack;/** * Source : https://oj.leetcode.com/problems/surrounded-regions/ * * * Given a 2D board containing 'X' and 'O', capture all regions surrounded

2018-02-28 09:13:24 101

原创 leetcode — sum-root-to-leaf-numbers

import java.util.Stack;/** * * Source : https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/ * * * Given a binary tree containing digits from 0-9 only, each root-to-leaf path could repres

2018-02-28 09:13:22 99

原创 leetcode — longest-consecutive-sequence

import java.util.HashSet;import java.util.Set;/** * Source : https://oj.leetcode.com/problems/longest-consecutive-sequence/ * * * Given an unsorted array of integers, find the length of the lon

2018-02-28 09:13:19 162

原创 leetcode — word-ladder-ii

import java.util.*;/** * Source : https://oj.leetcode.com/problems/word-ladder-ii/ * * * Given two words (start and end), and a dictionary, find all shortest transformation * sequence(s) from s

2018-02-28 09:13:16 134

原创 leetcode — word-ladder

import java.util.*;/** * Source : https://oj.leetcode.com/problems/word-ladder/ * * * Given two words (start and end), and a dictionary, find the length of shortest * transformation sequence fr

2018-02-28 09:13:13 110

原创 leetcode — valid-palindrome

/** * Source : https://oj.leetcode.com/problems/valid-palindrome/ * * * Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. * * For exam

2018-02-28 09:13:10 109

原创 leetcode — binary-tree-maximum-path-sum

/** * * Source : https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/ * * * Given a binary tree, find the maximum path sum. * * The path may start and end at any node in the tree. *

2018-02-28 09:13:08 113

原创 leetcode — best-time-to-buy-and-sell-stock-iii

/** * Source : https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/ * * * Say you have an array for which the ith element is the price of a given stock on day i. * * Design an a

2018-02-28 09:13:05 205

原创 leetcode — best-time-to-buy-and-sell-stock-ii

/** * Source : https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ * * * * Say you have an array for which the ith element is the price of a given stock on day i. * * Design an

2018-02-28 09:13:03 132

Hibernate 的第一个例子

学习HIbernate的第一个例子,便于初学者入门

2016-03-16

Win32 API大全.chm

进行win32开发需要参看的一些API函数,可以快速查找相关函数

2014-05-22

C语言函数库大全.chm

包含C语言大部分库函数,最重要的是里面还有例子哦

2014-05-22

java API

java API chm方便阅读,中文文档,为初学者

2014-03-19

c程序100例.doc

c程序100例.doc,帮助练习,学习c语言

2013-09-06

JAVAScript教程

学习网站制作,想让自己的网页更加丰富多彩,一定要学习JAVAScript教程

2013-04-17

API命名规则

复杂的windowsAPI如何命名,找到其中规律有助于你进一步运用API进行编程

2013-04-17

vc++6.0程序员指南

vc++6.0从入门到精通到精通,包含基础知识以及仅仅一步学习c++编程

2013-03-29

74h573中文资料

锁存器,用来扩展单片机i/o口,并控制输出

2013-03-28

viual c++游戏

c++游戏编程,适合想进一步学习c++的同胞,一些简单的代码,很好

2013-03-26

proe5.0 破解文件

proe5.0 32位破解文件,proe64位野火版,破解神器

2013-03-26

开发工具的应用

到目前为止,对Visual C++ .NET的应用,可以说仅运用了最基本的功能,但即便如此我们依旧可以感受到Visual C++ .NET这个集成开发环境所带来的便利。这一章里,将告诉您如何应用Visual C++ .NET的功能

2013-01-03

.NET+2003窗口程序设计

相信当您学会这些工具后,将可提升您开发窗口程序的速度与品质。

2013-01-03

dotNetFx40_Full_x86.exe

与vs2008一起使用,有些电脑需要安装此软件才能运行

2013-01-03

C++CLR上.pdf

c++入门的不错教材,纤细介绍了c++基本概念

2013-01-03

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除