@Query("select sum(r.amount) from RechargeOrder r where 1=1 " + "AND (case when (:status is null) then true when(:status=r.status) then true else false end)=true " + "AND (case when (:walletType is null) then true when(:walletType=r.walletType) then true else false end)=true " + "AND (case when (:payType is null) then true when(:payType=r.payType) then true else false end)=true " + "AND (case when (:userId is null) then true when(:payType=r.userId) then true else false end)=true " + "AND (case when (:rechargeType is null) then true when(:rechargeType=r.rechargeType) then true else false end)=true " + "AND (case when (:successTimeBegin is null) then true when(:successTimeBegin<=r.successTime) then true else false end)=true " + "AND (case when (:successTimeEnd is null) then true when(:successTimeEnd>=r.successTime) then true else false end)=true " + "") Integer sumAmount( @Param("status") Integer status ,@Param("walletType") Integer walletType ,@Param("payType") Integer payType ,@Param("userId") Integer userId ,@Param("rechargeType") Integer rechargeType ,@Param("successTimeBegin") Date successTimeBegin ,@Param("successTimeEnd") Date successTimeEnd );
win中cmd调用npm脚本的办法
打docker包,需要打node环境的镜像
先用bat命令行编译vue的代码
直接用npm install 无法按正常顺序执行,每个npm命令没有阻塞会并发运行
之后改用start /wait 可以顺序执行完但每次会弹出个新窗口,并且子窗口完成后需要手动关闭,并且在主装口选择是否继续
最后改用call 很好用,能正常在一个窗口中顺序执行
hystrix线程高并且是waiting状态的修改方法
hystrix.threadpool.default.coreSize=20
springcloud里这个参数不是越大越好,得看看自己的内存
之前设置500,发现他会给每个controller预留500个线程是waiting状态。占用大量内存,现在重新改小了,再观察下是否对降低内存消耗有帮助。
免密码登录
ssh-keygen -t dsa -P ” -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
sed 替换引号
原始日志文件格式定义错了连着两个”引号,批量替换
sed -i "s/\"\"/\" \"/g" ./2017-09-01.log
elasticsearch内存引起的结点无法正常运行
效果
1,kibana看服务red
2,/_cat/nodes发现少个结点
3,阿里云容器里看结点正常运行,重启提示找不到主结点。不过测试ping能通。
4,/_cat/indices 无法打开。
最后发现开结点有点慢,发现内存占用90%,偶尔飙到98%。怀疑内存不够
最后吧机器内的hadoop关了,内存降到90%以下就好了。
springcloud中怎么蓝绿发布嘞
百度上搜的有好多理论。就不说了
springcloud没啥管理界面。
搜到一个springcloudadmin的,结果是个第三方的。觉得不太稳。
我们的环境是,阿里云的docker,springcloud经典全家桶。
服务更新的时候是,同时启动版本1和版本2,两个服务,然后关掉老的版本1.
这样会造成5~10秒的服务中断
单一服务的时候,是用的阿里负载均衡的蓝绿发布。但使用注册服务eureka的话这样就不行了。
再说下早期的弯路,也是搜百度,springcloud如何优雅关闭,然后找到了,每个服务可以执行 shutdown方法,但这其实并没有什么卵用。阿里关闭服务的时候已经算是优雅关闭了。用这个效果一样。
最终解决的方向是,eureka里的 /status?value=OUT_OF_SERVICE
格式是 PUT方法(必须PUT别的不行)
http://eureka/apps/服务名(大小写都行)/[服务id]/status?value=OUT_OF_SERVICE
这样在eureka中服务会显示OUT_OF_SERVICE,新的请求就不会走这个服务了,如果想回滚只要这个服务没有删重新设置成UP就行了。
注意:如果里面运行着队列的话会继续执行的,并不会终止。
如何制作一个UI界面方便管理呢。
最早看贴子有说用postman的
然后想过做个html解析,处理下eureka页面。
现在的方案是,改写eureka的url
eureka.instance.status-page-url=http://处理页面/hoststatus?servicename=${spring.application.name}&clientid=${clientid}
这个配置是在每个服务里的。这样注册后,会在eureka中看到这个链接,不再是/info
这个页面里可以写个开关服务的按钮就行了。比较容易实现。
jmater,2毫秒间隔请求接口实测,0异常。
elasticsearch分析nginx的例子
http://www.cnblogs.com/Orgliny/p/5592186.html
http://www.jianshu.com/p/abca8e5b913b
这两个能解决大部分问题
data.domain.PageImpl can not deserialize
用默认的或者自定义一个,不用那个啥来着就行了
aliyun在docker容器服务里配置elasticsearch5
第一步,制作镜像。官方镜像没有x-pack。
FROM kibana:5.6.3 ENV TIME_ZONE Asia/Shanghai RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "${TIME_ZONE}" > /etc/timezone RUN kibana-plugin install x-pack EXPOSE 5601
第二部,多节点发布
这里举例发布一个主节点,一个数据节点。
aliyun的容器里配置
elasticsearch: container_name: elasticsearch restart: always environment: - LANG=C.UTF-8 - JAVA_HOME=/docker-java-home/jre - "ES_JAVA_OPTS=-Xms512m -Xmx512m" expose: - '9200:9200/tcp' - '9300:9300/tcp' memswap_limit: 0 labels: aliyun.scale: '1' command: - elasticsearch - '-E' - cluster.name=searcher #所有节点设置成一样的 - '-E' - node.master=true #主节点true,数据节点false - '-E' - node.name=elasticsearch #节点名不能一样 - '-E' - network.host=172.19.0.27#这里需要些容器的ip否则互相找不到,而且不能加引号 - '-E' - discovery.zen.ping.unicast.hosts=172.19.0.32:9300 #互相发现的节点和ip shm_size: 0 #image: 'elasticsearch:5.6.3' #如果不装或手动装xpack的话可以用官方镜像。官方镜像安装xpack比较消内存,可能因内存不足提示killed安装失败。 image: 'xx[这里是你的镜像]x/elastic_search:0.1.0' memswap_reservation: 0 volumes: - esdata1:/usr/share/elasticsearch/data kernel_memory: 0 mem_limit: 0