天玑阁

vuePress-theme-reco gqsu    2018 - 2021
天玑阁 天玑阁

Choose mode

  • dark
  • auto
  • light
主页
时间轴
文档
  • vuepress-reco
分类
  • elasticsearch
  • Hadoop
  • life
  • linux
  • note
  • Apache James
  • collection
  • Dubbo
  • git
  • jwt
  • k8s
  • mongodb
  • ali
  • netty-socketio
  • nginx
  • node
  • oracle
  • own
  • rabbitmq
  • shell
  • vuepress
  • springDataJpa
  • web
  • wechat
  • redis
  • springBoot
  • rabbitmq,springBoot
  • springCloud
  • sql
  • study
  • util
标签
author-avatar

gqsu

156

Article

42

Tag

    主页
    时间轴
    文档
    • vuepress-reco
    分类
    • elasticsearch
    • Hadoop
    • life
    • linux
    • note
    • Apache James
    • collection
    • Dubbo
    • git
    • jwt
    • k8s
    • mongodb
    • ali
    • netty-socketio
    • nginx
    • node
    • oracle
    • own
    • rabbitmq
    • shell
    • vuepress
    • springDataJpa
    • web
    • wechat
    • redis
    • springBoot
    • rabbitmq,springBoot
    • springCloud
    • sql
    • study
    • util
    标签

    util Categories

    vuePress-theme-reco gqsu    2018 - 2021
    • elasticsearch 20
    • Hadoop 2
    • life 6
    • linux 9
    • note 9
    • Apache James 2
    • collection 1
    • Dubbo 1
    • git 1
    • jwt 1
    • k8s 1
    • mongodb 1
    • ali 2
    • netty-socketio 2
    • nginx 2
    • node 3
    • oracle 1
    • own 1
    • rabbitmq 2
    • shell 1
    • vuepress 1
    • springDataJpa 1
    • web 2
    • wechat 2
    • redis 6
    • springBoot 27
    • rabbitmq,springBoot 1
    • springCloud 13
    • sql 6
    • study 24
    • util 5
    一些测试和运维软件的使用

    # Jmeter

    # 安装

    1、下载地址:https://link.juejin.im/?target=http%3A%2F%2Fjmeter.apache.org%2Fdownload_jmeter.cgi

    2、修改 /bin 下的 jmeter.properties 文件, 修改 language为:zh_CN。然后在运行 jemter.bat

    # 使用

    1、添加 -> 线程(用户) -> 线程组 2、线程组 -> 添加 -> 测试元件 -> http请求默认值 3、线程组 -> 添加 -> 测试元件 -> HTTP信息头管理器 4、线程组 -> 添加 -> 取样器 -> HTTP请求 5、线程组 -> 添加 -> 监听器 -> XXXXXXXXX

    # Arthas--开源java诊断工具

    项目地址:https://github.com/alibaba/arthas

    安装: 执行 ./install.sh 启动: 执行 ./as.sh pid

    gqsu Invalid Date util
    常用算法

    # 红包算法

    public class RedPacket {
    
        /**
         * 生成红包最小值 1分
         */
        private static final int MIN_MONEY = 1;
    
        /**
         * 生成红包最大值 200人民币
         */
        private static final int MAX_MONEY = 200 * 100;
    
        /**
         * 小于最小值
         */
        private static final int LESS = -1;
        /**
         * 大于最大值
         */
        private static final int MORE = -2;
    
        /**
         * 正常值
         */
        private static final int OK = 1;
    
        /**
         * 最大的红包是平均值的 TIMES 倍,防止某一次分配红包较大
         */
        private static final double TIMES = 2.1F;
    
        private int recursiveCount = 0;
    
        public List<Integer> splitRedPacket(int money, int count) {
            List<Integer> moneys = new LinkedList<>();
    
            //金额检查,如果最大红包 * 个数 < 总金额;则需要调大最小红包 MAX_MONEY
            if (MAX_MONEY * count <= money) {
                System.err.println("请调大最小红包金额 MAX_MONEY=[" + MAX_MONEY + "]");
                return moneys ;
            }
    
    
            //计算出最大红包
            int max = (int) ((money / count) * TIMES);
            max = max > MAX_MONEY ? MAX_MONEY : max;
    
            for (int i = 0; i < count; i++) {
                //随机获取红包
                int redPacket = randomRedPacket(money, MIN_MONEY, max, count - i);
                moneys.add(redPacket);
                //总金额每次减少
                money -= redPacket;
            }
    
            return moneys;
        }
    
        private int randomRedPacket(int totalMoney, int minMoney, int maxMoney, int count) {
            //只有一个红包直接返回
            if (count == 1) {
                return totalMoney;
            }
    
            if (minMoney == maxMoney) {
                return minMoney;
            }
    
            //如果最大金额大于了剩余金额 则用剩余金额 因为这个 money 每分配一次都会减小
            maxMoney = maxMoney > totalMoney ? totalMoney : maxMoney;
    
            //在 minMoney到maxMoney 生成一个随机红包
            int redPacket = (int) (Math.random() * (maxMoney - minMoney) + minMoney);
    
            int lastMoney = totalMoney - redPacket;
    
            int status = checkMoney(lastMoney, count - 1);
    
            //正常金额
            if (OK == status) {
                return redPacket;
            }
    
            //如果生成的金额不合法 则递归重新生成
            if (LESS == status) {
                recursiveCount++;
                System.out.println("recursiveCount==" + recursiveCount);
                return randomRedPacket(totalMoney, minMoney, redPacket, count);
            }
    
            if (MORE == status) {
                recursiveCount++;
                System.out.println("recursiveCount===" + recursiveCount);
                return randomRedPacket(totalMoney, redPacket, maxMoney, count);
            }
    
            return redPacket;
        }
    
        /**
         * 校验剩余的金额的平均值是否在 最小值和最大值这个范围内
         *
         * @param lastMoney
         * @param count
         * @return
         */
        private int checkMoney(int lastMoney, int count) {
            double avg = lastMoney / count;
            if (avg < MIN_MONEY) {
                return LESS;
            }
    
            if (avg > MAX_MONEY) {
                return MORE;
            }
    
            return OK;
        }
    
    
        public static void main(String[] args) {
            RedPacket redPacket = new RedPacket();
            List<Integer> redPackets = redPacket.splitRedPacket(20000, 100);
            System.out.println(redPackets);
    
            int sum = 0;
            for (Integer red : redPackets) {
                sum += red;
            }
            System.out.println(sum);
        }
    
    }
    
    gqsu 2019/1/28下午9:09:04 util
    工具类-三方工具的使用

    # 七牛云

    gqsu 2018/10/8下午2:55:06 util
    常用组件-POI、Hutool

    # 使用POI组件操作Excel

    # sql数据导出到Excel表格

    1、添加依赖:

    <dependency>
    	<groupId>org.apache.poi</groupId>
    	<artifactId>poi-ooxml</artifactId>
    	<version>3.9</version>
    </dependency>
    <!--<dependency>
    	<groupId>org.apache.poi</groupId>
    	<artifactId>poi</artifactId>
        <version>3.9</version>
    </dependency>-->
    
    gqsu 2018/8/8下午2:55:06 util
    时间工具类、HttpClinet工具类

    # 时间工具类

    gqsu 2018/5/16上午11:09:04 util
    Prev 1 ... 1 ... 1 Next Jump To Go