Skip to content

Instantly share code, notes, and snippets.

View yangl's full-sized avatar
🎯
Focusing

YANGLiiN yangl

🎯
Focusing
View GitHub Profile
@yangl
yangl / 当当sharding-jdbc分布式Id生成器.md
Last active August 8, 2018 05:33
当当sharding-jdbc分布式Id生成器 详见:http://shardingjdbc.io/docs/02-guide/key-generator/ 注意该实现使用限止:1.每毫秒最大并发4096;2.最久使用至2156年 ;

分布式Id生成器

实现动机

传统数据库软件开发中,主键自动生成技术是基本需求。而各大数据库对于该需求也提供了相应的支持,比如MySQL的自增键。 对于MySQL而言,分库分表之后,不同表生成全局唯一的Id是非常棘手的问题。因为同一个逻辑表内的不同实际表之间的自增键是无法互相感知的, 这样会造成重复Id的生成。我们当然可以通过约束表生成键的规则来达到数据的不重复,但是这需要引入额外的运维力量来解决重复性问题,并使框架缺乏扩展性。

目前有许多第三方解决方案可以完美解决这个问题,比如UUID等依靠特定算法自生成不重复键,或者通过引入Id生成服务等。 但也正因为这种多样性导致了Sharding-JDBC如果强依赖于任何一种方案就会限制其自身的发展。

@yangl
yangl / 新版Docker的Swarm模式 创建|部署|扩展|删除.md
Last active April 1, 2018 17:04
新版Docker的Swarm模式 创建|部署|扩展|删除,详见:http://www.dockerinfo.net/3837.html
@yangl
yangl / 0 SwaggerConfig.java
Last active April 23, 2018 06:13
使用springfox、swagger2生成api文档(也可使用https://github.com/apiaryio/api-blueprint 加 aglio) swagger全局参数头
import java.util.List;
import org.springframework.context.annotation.Bean;
import com.google.common.collect.Lists;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
@yangl
yangl / mybatis-plus-pom.xml
Last active February 9, 2017 08:17
mybatis-plus使用例子,详见http://mp.baomidou.com
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>2.0.1</version>
</dependency>
<plugin>
<groupId>com.baomidou</groupId>
<artifactId>mybatisplus-maven-plugin</artifactId>
<version>1.0</version>
@yangl
yangl / bosun.conf
Created April 20, 2017 06:59
bosun配置例子
notification sdk.otps.connrate.uxin.ding60 {
get = http://192.168.0.3:5000/ding?secret=fskd2endprx&phone=13751744327|18928495951|13736157898|18618324918|18576761242|13428967565|13428967565|18676663045|18673390570|15202240237|15118845510|15013718265&content=【有信接通率低于60%预警】有信品牌接通率低于60%
}
notification sdk.otps.connrate.uxin.mail60 {
email = [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
}
template sdk.otps.connrate.uxin {
@yangl
yangl / 0-elasticsearch
Last active July 20, 2017 16:38
elasticsearch备忘
elasticsearch相关
1.安装
http://www.cnblogs.com/jstarseven/p/6803054.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-targz.html
重要参数详见:https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html
2.常用插件
########### These MUST be filled in for a storm configuration
storm.zookeeper.servers:
- "10.10.74.41"
- "10.10.74.42"
- "10.10.74.43"
storm.zookeeper.root: "/jstorm"
cluster.name: "jstorm-uxin"
数据如下:
[2017-05-17 00:00:08.338] [INFO] [http-bio-8021-exec-104] [applog] [250] --validateAuthCode接口调用2,请求参数{"appId":"lancai","authCode":"ccfc95551640493406b04089e4b14e04","sign":"30573840a34733457d081551f5180a44ce45f515","sn":"9d5f890fb4509ab889d78f5dd27ec64d","timestamp":"1494950408309"},返回值{"data":{"openid":"17402156017","token":"BAAAAVwR_PCNAAAABwAAAAUAAAAGAAAABA0_0_FhbmRyb2lkNi4wLjNsYW5jYWk="},"msg":"成功","status":0}--
[2017-05-17 00:00:45.898] [INFO] [http-bio-8021-exec-142] [applog] [250] --validateAuthCode接口调用2,请求参数{"appId":"lancai","authCode":"6bd53c1f7cf3b8fdf6cacff2f6b8dc42","sign":"63184218432f46d5974fb783b6d8ae0efe165126","sn":"c63f174ce714b86471a547c6926a614f","timestamp":"1494950445876"},返回值{"data":{"openid":"17208560624","token":"BAAAAVwR_YNFAAAABgAAAAUAAAAGAAAABAG1y_BpcGhvbmU2LjAuNWxhbmNhaQ=="},"msg":"成功","status":0}--
[2017-05-17 00:01:02.986] [INFO] [http-bio-8021-exec-150] [applog] [250] --validateAuthCode接口调用2,请求参数{"appId":"lancai","authCode":"ce2caaa7013537c11fdc6a4aa01b08d3","sign":"d1255
@yangl
yangl / 1.步骤.txt
Created June 22, 2017 08:18
jmc(全称 Java Mission Control)使用指南
1.JVM参数中添加-XX:+UnlockCommercialFeatures -XX:+FlightRecorder启用jmc,
然后打开jmx(-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false)即可;
2.到JAVA_HOME/bin/下打开jmc客户端即可;
3.填写jmx地址连接;
@yangl
yangl / Log4j2Disconf.java
Created September 5, 2017 08:55
使用disconf动态配置log4j2.xml(由于新项目第一次启动还没有下载到disconf配置中心的配置,故会使用log4j2的默认配置DefaultConfiguration)
package com.xxx.conf;
import com.baidu.disconf.client.common.annotations.DisconfFile;
import com.baidu.disconf.client.common.annotations.DisconfUpdateService;
import com.baidu.disconf.client.common.update.IDisconfUpdate;
import java.net.URISyntaxException;
import java.net.URL;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.springframework.beans.factory.InitializingBean;