package com.cm.central.control.pojo.bos;

import com.google.common.collect.EvictingQueue;
import io.netty.channel.Channel;

import java.io.Serializable;
import java.util.*;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: SocketClientBO
 * @Description: socket客户端
 * @Author: WangGeng
 * @Date: 2020/7/28 3:23 下午
 * @Version: 1.0
 **/
public class SocketClientBO implements Serializable {

    private static final long serialVersionUID = -4686820134132706863L;
    private String clientId;
    private String projectLeaderId;
    private Long lastTime;
    private Channel channel;
    private Integer emailNoticeCount;
    private Map<String, Object> systemInfo = new HashMap<>();
    private List<Map<String, Object>> diskList = new ArrayList<>();
    private Queue<Map<String, Object>> memoryQueue = EvictingQueue.create(120);
    private Queue<Map<String, Object>> jvmQueue = EvictingQueue.create(120);
    private Queue<Map<String, Object>> cpuQueue = EvictingQueue.create(120);

    public String getClientId() {
        return clientId == null ? "" : clientId.trim();
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getProjectLeaderId() {
        return projectLeaderId == null ? "" : projectLeaderId.trim();
    }

    public void setProjectLeaderId(String projectLeaderId) {
        this.projectLeaderId = projectLeaderId;
    }

    public Long getLastTime() {
        return lastTime;
    }

    public void setLastTime(Long lastTime) {
        this.lastTime = lastTime;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public Integer getEmailNoticeCount() {
        return emailNoticeCount == null || emailNoticeCount < 0 ? 0 : emailNoticeCount;
    }

    public void setEmailNoticeCount(Integer emailNoticeCount) {
        this.emailNoticeCount = emailNoticeCount;
    }

    public Map<String, Object> getSystemInfo() {
        return systemInfo;
    }

    public void setSystemInfo(Map<String, Object> systemInfo) {
        this.systemInfo.clear();
        this.systemInfo.putAll(systemInfo);
    }

    public List<Map<String, Object>> getDiskList() {
        return diskList;
    }

    public void setDiskList(List<Map<String, Object>> diskList) {
        this.diskList.clear();
        this.diskList.addAll(diskList);
    }

    public Queue<Map<String, Object>> getMemoryQueue() {
        return memoryQueue;
    }

    public void addMemoryQueue(Map<String, Object> memory) {
        this.memoryQueue.add(memory);
    }

    public Queue<Map<String, Object>> getJvmQueue() {
        return jvmQueue;
    }

    public void addJvmQueue(Map<String, Object> jvm) {
        this.jvmQueue.add(jvm);
    }

    public Queue<Map<String, Object>> getCpuQueue() {
        return cpuQueue;
    }

    public void addCpuQueue(Map<String, Object> cpu) {
        this.cpuQueue.add(cpu);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"clientId\":")
                .append("\"").append(clientId).append("\"");
        sb.append(",\"projectLeaderId\":")
                .append("\"").append(projectLeaderId).append("\"");
        sb.append(",\"lastTime\":")
                .append(lastTime);
        sb.append(",\"channel\":")
                .append(channel);
        sb.append(",\"emailNoticeCount\":")
                .append(emailNoticeCount);
        sb.append('}');
        return sb.toString();
    }
}
