package com.bocloud.ims.entity.resource;

import com.bocloud.cmp.model.HostSystem;
import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Table("cluster")
public class Cluster extends GenericEntity {

    @PK(value = PKStrategy.AUTO)
    private Long id;
    @Column("uuid")
    private String uuid;
    @Column("vendor_id")
    private Long vendorId; // 云供应商ID
    @IgnoreAll
    private String vendorName; // 云供应商名称
    @Column("gmt_expired")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date gmtExpired;// 过期时间
    @Column("cpu_total")
    private Long cpuTotal;
    @Column("mem_total")
    private Double memTotal;
    @Column("disk_total")
    private Double diskTotal;
    @Column("cpu_used")
    private Long cpuUsed;
    @Column("mem_used")
    private Double memUsed;
    @Column("disk_used")
    private Double diskUsed;
    @IgnoreAll
    private Long cpuUnused;
    @IgnoreAll
    private Double memUnused;
    @IgnoreAll
    private Double diskUnused;
    @Column("vdc_id")
    private Long vdcId;
    @Column("category")
    private String category;
    @IgnoreAll
    private List<HostSystem> hosts;
    @IgnoreAll
    private String vdcName;
    @Column("host_num")
    private Integer hostNum;// 集群下物理主机数量
    @Column("vm_num")
    private Integer vmNum;// 集群下虚拟机数量
    @Column("template_num")
    private Integer templateNum;// 集群下模板数量
    @Column("cpu_core")
    private Integer cpuCore;// 集群中cpu核数
    @Column("cluster_val")
    private String clusterVal;
    @Column("type")
    private String type;
    @Column("version")
    private String version;
    @IgnoreAll
    private List<ClusterNode> nodes;
    @IgnoreAll
    private VmResourcePool vmResourcePool;
    @Column("guid")
    private String guid;// 全局唯一标识
    @Column("region_id")
    private Long regionId;
    @IgnoreAll
    private String regionName;
    @Column("cpu_excess_ratio")
    private Long cpuExcessRatio;// CPU超分比
    @Column("cpu_distributable_ratio")
    private BigDecimal cpuDistributableRatio;// CPU可分配百分比
    @Column("mem_distributable_ratio")
    private BigDecimal memDistributableRatio;// 内存可分配百分比
    @Column("policy_id")
    private Long policyId;// 策略ID
    @IgnoreAll
    private Integer vmCpuTotal;// 集群下虚机CPU总量
    @IgnoreAll
    private Integer cpuDistributable;// CPU可分配
    @IgnoreAll
    private Double memDistributable;// 内存可分配
    @Column("initial_policy")
    private String initialPolicy; // 布置策略

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the uuid
     */
    public String getUuid() {
        return uuid;
    }

    /**
     * @param uuid
     *            the uuid to set
     */
    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    /**
     * @return the vendorId
     */
    public Long getVendorId() {
        return vendorId;
    }

    /**
     * @param vendorId
     *            the vendorId to set
     */
    public void setVendorId(Long vendorId) {
        this.vendorId = vendorId;
    }

    /**
     * @return the vendorName
     */
    public String getVendorName() {
        return vendorName;
    }

    /**
     * @param vendorName
     *            the vendorName to set
     */
    public void setVendorName(String vendorName) {
        this.vendorName = vendorName;
    }

    /**
     * @return the gmtExpired
     */
    public Date getGmtExpired() {
        return gmtExpired;
    }

    /**
     * @param gmtExpired
     *            the gmtExpired to set
     */
    public void setGmtExpired(Date gmtExpired) {
        this.gmtExpired = gmtExpired;
    }

    /**
     * @return the cpuTotal
     */
    public Long getCpuTotal() {
        return cpuTotal;
    }

    /**
     * @param cpuTotal
     *            the cpuTotal to set
     */
    public void setCpuTotal(Long cpuTotal) {
        this.cpuTotal = cpuTotal;
    }

    /**
     * @return the memTotal
     */
    public Double getMemTotal() {
        return memTotal;
    }

    /**
     * @param memTotal
     *            the memTotal to set
     */
    public void setMemTotal(Double memTotal) {
        this.memTotal = memTotal;
    }

    /**
     * @return the diskTotal
     */
    public Double getDiskTotal() {
        return diskTotal;
    }

    /**
     * @param diskTotal
     *            the diskTotal to set
     */
    public void setDiskTotal(Double diskTotal) {
        this.diskTotal = diskTotal;
    }

    /**
     * @return the cpuUsed
     */
    public Long getCpuUsed() {
        return cpuUsed;
    }

    /**
     * @param cpuUsed
     *            the cpuUsed to set
     */
    public void setCpuUsed(Long cpuUsed) {
        this.cpuUsed = cpuUsed;
    }

    /**
     * @return the memUsed
     */
    public Double getMemUsed() {
        return memUsed;
    }

    /**
     * @param memUsed
     *            the memUsed to set
     */
    public void setMemUsed(Double memUsed) {
        this.memUsed = memUsed;
    }

    /**
     * @return the diskUsed
     */
    public Double getDiskUsed() {
        return diskUsed;
    }

    /**
     * @param diskUsed
     *            the diskUsed to set
     */
    public void setDiskUsed(Double diskUsed) {
        this.diskUsed = diskUsed;
    }

    public Long getCpuUnused() {
        return cpuUnused;
    }

    public void setCpuUnused(Long cpuUnused) {
        this.cpuUnused = cpuUnused;
    }

    public Double getMemUnused() {
        return memUnused;
    }

    public void setMemUnused(Double memUnused) {
        this.memUnused = memUnused;
    }

    public Double getDiskUnused() {
        return diskUnused;
    }

    public void setDiskUnused(Double diskUnused) {
        this.diskUnused = diskUnused;
    }

    /**
     * @return the vdcId
     */
    public Long getVdcId() {
        return vdcId;
    }

    /**
     * @param vdcId
     *            the vdcId to set
     */
    public void setVdcId(Long vdcId) {
        this.vdcId = vdcId;
    }

    /**
     * @return the category
     */
    public String getCategory() {
        return category;
    }

    /**
     * @param category
     *            the category to set
     */
    public void setCategory(String category) {
        this.category = category;
    }

    /**
     * @return the hosts
     */
    public List<HostSystem> getHosts() {
        return hosts;
    }

    /**
     * @param hosts
     *            the hosts to set
     */
    public void setHosts(List<HostSystem> hosts) {
        this.hosts = hosts;
    }

    /**
     * @return the vdcName
     */
    public String getVdcName() {
        return vdcName;
    }

    /**
     * @param vdcName
     *            the vdcName to set
     */
    public void setVdcName(String vdcName) {
        this.vdcName = vdcName;
    }

    /**
     * @return the hostNum
     */
    public Integer getHostNum() {
        return hostNum;
    }

    /**
     * @param hostNum
     *            the hostNum to set
     */
    public void setHostNum(Integer hostNum) {
        this.hostNum = hostNum;
    }

    /**
     * @return the vmNum
     */
    public Integer getVmNum() {
        return vmNum;
    }

    /**
     * @param vmNum
     *            the vmNum to set
     */
    public void setVmNum(Integer vmNum) {
        this.vmNum = vmNum;
    }

    /**
     * @return the templateNum
     */
    public Integer getTemplateNum() {
        return templateNum;
    }

    /**
     * @param templateNum
     *            the templateNum to set
     */
    public void setTemplateNum(Integer templateNum) {
        this.templateNum = templateNum;
    }

    /**
     * @return the cpuCore
     */
    public Integer getCpuCore() {
        return cpuCore;
    }

    /**
     * @param cpuCore
     *            the cpuCore to set
     */
    public void setCpuCore(Integer cpuCore) {
        this.cpuCore = cpuCore;
    }

    /**
     * @return the clusterVal
     */
    public String getClusterVal() {
        return clusterVal;
    }

    /**
     * @param clusterVal
     *            the clusterVal to set
     */
    public void setClusterVal(String clusterVal) {
        this.clusterVal = clusterVal;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type
     *            the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * @return the version
     */
    public String getVersion() {
        return version;
    }

    /**
     * @param version
     *            the version to set
     */
    public void setVersion(String version) {
        this.version = version;
    }

    /**
     * @return the nodes
     */
    public List<ClusterNode> getNodes() {
        return nodes;
    }

    /**
     * @param nodes
     *            the nodes to set
     */
    public void setNodes(List<ClusterNode> nodes) {
        this.nodes = nodes;
    }

    /**
     * @return the resourcePool
     */
    public VmResourcePool getResourcePool() {
        return vmResourcePool;
    }

    /**
     * @param vmResourcePool
     *            the resourcePool to set
     */
    public void setResourcePool(VmResourcePool vmResourcePool) {
        this.vmResourcePool = vmResourcePool;
    }

    /**
     * @return the guid
     */
    public String getGuid() {
        return guid;
    }

    /**
     * @param guid
     *            the guid to set
     */
    public void setGuid(String guid) {
        this.guid = guid;
    }

    /**
     * @return the regionId
     */
    public Long getRegionId() {
        return regionId;
    }

    /**
     * @param regionId
     *            the regionId to set
     */
    public void setRegionId(Long regionId) {
        this.regionId = regionId;
    }

    /**
     * @return the regionName
     */
    public String getRegionName() {
        return regionName;
    }

    /**
     * @param regionName
     *            the regionName to set
     */
    public void setRegionName(String regionName) {
        this.regionName = regionName;
    }

    public Long getCpuExcessRatio() {
        return cpuExcessRatio;
    }

    public void setCpuExcessRatio(Long cpuExcessRatio) {
        this.cpuExcessRatio = cpuExcessRatio;
    }

    public BigDecimal getCpuDistributableRatio() {
        return cpuDistributableRatio;
    }

    public void setCpuDistributableRatio(BigDecimal cpuDistributableRatio) {
        this.cpuDistributableRatio = cpuDistributableRatio;
    }

    public BigDecimal getMemDistributableRatio() {
        return memDistributableRatio;
    }

    public void setMemDistributableRatio(BigDecimal memDistributableRatio) {
        this.memDistributableRatio = memDistributableRatio;
    }

    public Integer getCpuDistributable() {
        return cpuDistributable;
    }

    public void setCpuDistributable(Integer cpuDistributable) {
        this.cpuDistributable = cpuDistributable;
    }

    public Double getMemDistributable() {
        return memDistributable;
    }

    public void setMemDistributable(Double memDistributable) {
        this.memDistributable = memDistributable;
    }

    public Long getPolicyId() {
        return policyId;
    }

    public void setPolicyId(Long policyId) {
        this.policyId = policyId;
    }

    public String getInitialPolicy() {
        return initialPolicy;
    }

    public void setInitialPolicy(String initialPolicy) {
        this.initialPolicy = initialPolicy;
    }

    /**
     * @param creatorId
     * @param ownerId
     * @param menderId
     * @param id
     * @param uuid
     * @param vendorId
     * @param vendorName
     * @param gmtExpired
     * @param cpuTotal
     * @param memTotal
     * @param diskTotal
     * @param cpuUsed
     * @param memUsed
     * @param diskUsed
     */
    public Cluster(Long creatorId, Long ownerId, Long menderId, Long id, String uuid, Long vendorId, String vendorName,
            Date gmtExpired, Long cpuTotal, Double memTotal, Double diskTotal, Long cpuUsed, Double memUsed,
            Double diskUsed, Integer hostNum, Integer vmNum, Integer templateNum, Integer cpuCore, String clusterVal) {
        super(creatorId, ownerId, menderId);
        this.id = id;
        this.uuid = uuid;
        this.vendorId = vendorId;
        this.vendorName = vendorName;
        this.gmtExpired = gmtExpired;
        this.cpuTotal = cpuTotal;
        this.memTotal = memTotal;
        this.diskTotal = diskTotal;
        this.cpuUsed = cpuUsed;
        this.memUsed = memUsed;
        this.diskUsed = diskUsed;
        this.hostNum = hostNum;
        this.vmNum = vmNum;
        this.templateNum = templateNum;
        this.cpuCore = cpuCore;
        this.clusterVal = clusterVal;
    }

    /**
     *
     */
    public Cluster() {
        super();
    }

    /**
     * @param creatorId
     * @param ownerId
     * @param menderId
     * @param name
     * @param status
     * @param deleted
     * @param props
     * @param remark
     */
    public Cluster(Long creatorId, Long ownerId, Long menderId, String name, String status, Boolean deleted,
            String props, String remark) {
        super(creatorId, ownerId, menderId, name, status, deleted, props, remark);
    }

    public Cluster(Long creatorId, Long ownerId, Long menderId) {
        super(creatorId, ownerId, menderId);
    }

    public void preSave(Long creatorId, Long menderId, Long vendorId, Long vdcId) {
        this.setCreatorId(creatorId);
        this.setMenderId(menderId);
        this.setVendorId(vendorId);
        this.setVdcId(vdcId);
    }

	public Integer getVmCpuTotal() {
		return vmCpuTotal;
	}

	public void setVmCpuTotal(Integer vmCpuTotal) {
		this.vmCpuTotal = vmCpuTotal;
	}

}
