Java Generic - Upper bound, Lower bound
A rare one that is explained more clearly:( Generic wildcard<? Extends T>is used to receive the returned data. Generic collections with this ...
java 泛型 - 上界,下界
少有的讲得比较清楚的 :( 泛型通配符<? extends T>来接收返回的数据,此写法的泛型集合不能使用 add 方法,而<? super T>不能使用 get 方法,做为接口调用赋值时易出错。 说明:扩展说一下 PECS(Producer Extends Consu...
消息事务
消息事务参考: https://github.com/zjpjohn/ReliableMeageSystem 消息记录和业务DB在一个库中,业务DB操作完成后(事务完成后),开始发送消息。需要用到Spring中的事务同步TransactionSynchronizationAdapter Mes...
redis分布式锁 - redlock
摘自:http://mushroom.cnblogs.com/ 单机Redis分布式锁12# 加锁SET resource_name my_random_value NX PX 30000 123456# 释放锁if redis.call("get",KEYS[1]) =...
log4j trace - MDC
在记录日志的时候,我们可能有这种需求,对于每个记录除了知道日志信息外,也要当前登录用户的信息。可以这样解决:使用log4j的MDC 在web.xml加入 Filter: 12345678<filter> <filter-name>set log4j MDC for l...
分布式全局ID生成算法
twitter/snowflake结构snowflake的结构如下(每部分用-分开): 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 第一位为未使用,接下来的41位为毫...
流控
服务化过程中各种流控策略 计数器 滑动窗口 控制并发信号量 123456789101112131415Semaphore semphore = new Semaphore(10); if(semphore.getQueueLength() > 10){ //等待队...
MySQL summary
MySQL summary索引从两个维度来看: 普通索引 唯一索引 主键索引 组合索引 索引遵循最左匹配规则 函数索引 mysql不支持 B+树索引 hash索引 只能是等值查询 不支持范围查询 内存DB中用的多一些? Covering Index(覆盖索引) 在Expla...
JDK Summary
JDK###JMM -XX:NewRatio -XX:NewRatio=4表示年轻代与年老代所占比值为1:4,年轻代占整个堆栈的1/5Xms=Xmx并且设置了Xmn的情况下,该参数不需要进行设置。 -XX:SurvivorRatio 设置为8,则两个Sur...
Java heap memory parameter tuning - Xms Xmx parameters
Java heap memory parameter tuning Some performance tuning articles suggest adjusting the - Xms and - Xmx parameters to the same value, considering ...