2019-12-04 15:55:24 a751204951 阅读数 69

最近二次开发zabbix出现的问题,再配置监控内存使用时出现的问题:在这里插入图片描述
有人说是agent版本问题,这个说法我保留意见,我 的问题是输入的参数不正确导致的,要输入正确的参数
在这里插入图片描述
这里第一个参数的代表要监控的目录,这个参数要正确,然后重启agent节点,在页面进行禁用和启用的的操作,到这里问题解决
在这里插入图片描述

2019-12-11 09:48:40 u010720408 阅读数 6

      因为之前在ambari中在两台机器上安装了zeppelin,通过hdfs同步配置实现多活,但是当一个notebook过大时,spark卡死的时候,重启容易因为hdfs到本地local的配置同步不一致问题,容易重启失败。

      所以,测试环境里通过ambari删除掉一个zeppelin的服务端。

      但是再次重启时,出现标题的类似错误。

resource_management.core.exceptions.ExecutionFailed: Execution of 'chown -R zeppelin:zeppelin /var/run/zeppelin' returned 1. chown cannot access '/var/run/zeppelin': No such file or directory

然后查看之前两台机器的该目录,发现没有/var/run/zeppelin目录,创建,并且 sudo chmod 777 /var/run/zeppelin对所有用户的读写执行权限。

      再去ambari页面重启就ok了,然后查看目录文件,起始就是个记录PID进程编号的问题,over。

2018-11-27 14:49:34 weixin_42660202 阅读数 100
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package security.impl;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import security.IEncryptionAlgorithm;
import security.IEncryptionAlgorithm.Parameter;

public class EncryptionAlgorithmImpl implements IEncryptionAlgorithm {
    public EncryptionAlgorithmImpl() {
    }

    public SecretKey getKeygen(Parameter encryptionParameter, int keysize) throws NoSuchAlgorithmException {
        KeyGenerator instance = KeyGenerator.getInstance(encryptionParameter.getEncryptionType());
        instance.init(keysize);
        SecretKey secretKey = instance.generateKey();
        return secretKey;
    }

    public SecretKey getKeygen(Parameter encryptionParameter, int keysize, String password) throws NoSuchAlgorithmException {
        KeyGenerator instance = KeyGenerator.getInstance(encryptionParameter.getEncryptionType());
        instance.init(keysize, new SecureRandom(password.getBytes()));
        SecretKey secretKey = instance.generateKey();
        return secretKey;
    }

    public String getEncryptMessage(SecretKey deskey, String message) throws BadPaddingException, IllegalBlockSizeException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException {
        String algorithm = deskey.getAlgorithm();
        Cipher cipher = Cipher.getInstance(algorithm);
        cipher.init(1, deskey);
        return this.parseByte2HexStr(cipher.doFinal(message.getBytes()));
    }

    public String getEncryptMessage(String message) throws BadPaddingException, IllegalBlockSizeException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException {
        KeyGenerator generator = KeyGenerator.getInstance("AES");
        SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
        secureRandom.setSeed("******".getBytes());
        generator.init(128, secureRandom);
        SecretKey keygen = generator.generateKey();
        Cipher cipher = Cipher.getInstance(keygen.getAlgorithm());
        cipher.init(1, keygen);
        return this.parseByte2HexStr(cipher.doFinal(message.getBytes()));
    }

    public String getDecryptMessage(SecretKey deskey, String message) throws BadPaddingException, IllegalBlockSizeException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException {
        String algorithm = deskey.getAlgorithm();
        Cipher cipher = Cipher.getInstance(algorithm);
        cipher.init(2, deskey);
        return new String(cipher.doFinal(this.parseHexStr2Byte(message)));
    }

    public String getDecryptMessage(String message) throws BadPaddingException, IllegalBlockSizeException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException {
        KeyGenerator generator = KeyGenerator.getInstance("AES");
        SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
        secureRandom.setSeed("******".getBytes());
        generator.init(128, secureRandom);
        SecretKey keygen = generator.generateKey();
        Cipher cipher = Cipher.getInstance(keygen.getAlgorithm());
        cipher.init(2, keygen);
        return new String(cipher.doFinal(this.parseHexStr2Byte(message)));
    }

    public String parseByte2HexStr(byte[] buf) {
        StringBuffer sb = new StringBuffer();

        for(int i = 0; i < buf.length; ++i) {
            String hex = Integer.toHexString(buf[i] & 255);
            if (hex.length() == 1) {
                hex = '0' + hex;
            }

            sb.append(hex.toUpperCase());
        }

        return sb.toString();
    }

    public byte[] parseHexStr2Byte(String hexStr) {
        if (hexStr.length() < 1) {
            return null;
        } else {
            byte[] result = new byte[hexStr.length() / 2];

            for(int i = 0; i < hexStr.length() / 2; ++i) {
                int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
                int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
                result[i] = (byte)(high * 16 + low);
            }

            return result;
        }
    }
}
2018-10-17 15:38:31 weixin_40691089 阅读数 227

package com.dailai.manage.md5文件加密;

import java.io.FileInputStream;
import java.io.IOException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Created with IDEA
 * author:HCG
 **/
public class Md5CaculateUtil {
//    private static Logger logger =  Logger.getLogger(Md5CaculateUtil.class);

    private static char[] hexChar = {
            '0','1','2','3','4','5','6','7','8','9',
            'a','b','c','d','e','f'
    };

    protected static String toHexString(byte[] b){
        StringBuilder sb = new StringBuilder(b.length*2);
        for(int i=0;i<b.length;i++){
            sb.append(hexChar[(b[i] & 0xf0) >>> 4]);
            sb.append(hexChar[b[i] & 0x0f]);
        }
        return sb.toString();
    }

    public static String getMD5ForFile(String inputFile) throws IOException {
        // 缓冲区大小(这个可以抽出一个参数)
        int bufferSize = 256 * 1024;
        FileInputStream fileInputStream = null;
        DigestInputStream digestInputStream = null;
        try {
            // 拿到一个MD5转换器(同样,这里可以换成SHA1)
            MessageDigest messageDigest =MessageDigest.getInstance("MD5");
            // 使用DigestInputStream
            fileInputStream = new FileInputStream(inputFile);
            digestInputStream = new DigestInputStream(fileInputStream,messageDigest);
            // read的过程中进行MD5处理,直到读完文件
            byte[] buffer =new byte[bufferSize];
            while (digestInputStream.read(buffer) > 0);
            // 获取最终的MessageDigest
            messageDigest= digestInputStream.getMessageDigest();
            // 拿到结果,也是字节数组,包含16个元素
            byte[] resultByteArray = messageDigest.digest();
            // 同样,把字节数组转换成字符串
            return toHexString(resultByteArray);
        } catch (NoSuchAlgorithmException e) {
//            logger.error("系统异常,生成MD5错误。");
            return null;
        } finally {
            try {
                digestInputStream.close();
            } catch (Exception e) {
//                logger.error("系统异常,生成MD5错误。");
                throw e;
            }
            try {
                fileInputStream.close();
            } catch (Exception e) {
//                logger.error("系统异常,生成MD5错误。");
                throw e;
            }
        }
    }
    public static void main(String[] args) {

        long startTime = System.currentTimeMillis();

        try {
            System.out.println(getMD5ForFile("C:\\Users\\LYJ\\Desktop\\CCC.war"));
        } catch (IOException e) {
            e.printStackTrace();
        }

        long endTime = System.currentTimeMillis();

        System.out.println((endTime - startTime) / 1000);
    }
}

2018-11-21 15:05:41 dhq_blog 阅读数 88

错误提示代码:

Error instantiating class book.pojo.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: book.pojo.User.<init>()


首先:

instantiating 中文是“实例化”的意思

init  中文是“初始化”的意思


这里首先考虑的就是你创建的实体类,这里是User类的构造方法的问题。

我这里报错是因为在实体类里只给了一个有参构造方法,但在实例化时候却是用无参构造方法去实例化对象的,所以报了这个错。


解决方法:

1.在实体类中加入一个无参构造方法即可。
2.有可能返回对象不是对应的实体类,检查返回对象是否是表对应的实体类。

没有更多推荐了,返回首页