SSH相关

1.MD5处理
public static String md5(String str){
     try {
            StringBuffer buffer = new StringBuffer();
            char [] chars = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

            byte[] bytes = str.getBytes();
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] target = md.digest(bytes);

            for(Byte b : target){
                buffer.append(chars[(b >> 4) & 0x0F]);
                buffer.append(chars[b & 0x0F]);
            }

            return buffer.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
}




2.深度复制
     实现 Serializable 接口,使用 transient 界定要复制对象图的边界。
     public static Serializable deeplyCopy(Serializable src){
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(src);
            oos.close();
            baos.close();

            byte[] bytes = baos.toByteArray();

            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            ObjectInputStream ois = new ObjectInputStream(bais);
            Serializable copy = (Serializable) ois.readObject();
            ois.close();
            bais.close();

            return copy;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }




3.权限位,权限码
     pos          code
     1             0001          1
                    0010          2
                    0100          4
              |     1000          8

                    1111          15    sum                                                       1111     15

              &   0010          2                                                  &     0001  0000     16

                    0010          2     !=     0     有权限                           0000  0000     0     ==     0     没有权限



4.ThreadLocal 令牌
public class SurveyparkToken {

    private static ThreadLocal<SurveyparkToken> threadLocal = new ThreadLocal<>();

    private Survey survey;

    public Survey getSurvey() {
        return survey;
    }

    public void setSurvey(Survey survey) {
        this.survey = survey;
    }

    public static void bindToken(SurveyparkToken token){
        threadLocal.set(token);
    }

    public static void unbindToken(){
        threadLocal.remove();
    }

    public static SurveyparkToken getCurrentToken(){
        return threadLocal.get();
    }
}




5.分表、分库
     石英调度动态生成分表:日志表
     水平分库:同构,少跨库访问
     竖直分库:异构,少跨模块访问



ssh,深入了解其原理和实现机制
研究开源框架

binlog分库分表

JVM
多线程开发
IO
网络



















































































































  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值