package com.bocloud.ims.entity.resource.hmc;

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.meta.PKStrategy;
import com.bocloud.ims.entity.common.MathUtils;

/**
 * HMC系统CPU配置
 * 
 * @author sxp
 * @since May 22, 2018
 */
@Deprecated
@Table("hmc_system_processor_config")
public class HmcSystemProcessorConfig {
    @PK(value = PKStrategy.AUTO)
    private Long id;

    @Column("server_id")
    private Long serverId;

    @Column("current_available_system_processor_units")
    private Double currentAvailableSystemProcessorUnits;

    @Column("configurable_system_processor_units")
    private Double configurableSystemProcessorUnits;

    @Column("installed_system_processor_units")
    private Double installedSystemProcessorUnits;

    @Column("supported_partition_processor_compatibility_modes")
    private String supportedPartitionProcessorCompatibilityModes;

    @IgnoreAll
    private String sharedProcessorPoolCapable;

    @IgnoreAll
    private Double assignedSystemProcessorUnit;

    public HmcSystemProcessorConfig() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getServerId() {
        return serverId;
    }

    public void setServerId(Long serverId) {
        this.serverId = serverId;
    }

    public Double getCurrentAvailableSystemProcessorUnits() {
        return currentAvailableSystemProcessorUnits;
    }

    public void setCurrentAvailableSystemProcessorUnits(Double currentAvailableSystemProcessorUnits) {
        this.currentAvailableSystemProcessorUnits = currentAvailableSystemProcessorUnits;
    }

    public Double getConfigurableSystemProcessorUnits() {
        return configurableSystemProcessorUnits;
    }

    public void setConfigurableSystemProcessorUnits(Double configurableSystemProcessorUnits) {
        this.configurableSystemProcessorUnits = configurableSystemProcessorUnits;
    }

    public Double getInstalledSystemProcessorUnits() {
        return installedSystemProcessorUnits;
    }

    public void setInstalledSystemProcessorUnits(Double installedSystemProcessorUnits) {
        this.installedSystemProcessorUnits = installedSystemProcessorUnits;
    }

    public String getSharedProcessorPoolCapable() {
        return sharedProcessorPoolCapable;
    }

    public void setSharedProcessorPoolCapable(String sharedProcessorPoolCapable) {
        this.sharedProcessorPoolCapable = sharedProcessorPoolCapable;
    }

    public Double getAssignedSystemProcessorUnit() {
        return assignedSystemProcessorUnit;
    }

    public void setAssignedSystemProcessorUnit(Double assignedSystemProcessorUnit) {
        this.assignedSystemProcessorUnit = assignedSystemProcessorUnit;
    }

    public void calculateAssignedSystemProcessorUnit() {
        if (currentAvailableSystemProcessorUnits == null || configurableSystemProcessorUnits == null) {
            return;
        }

        // 可配置的 - 可用的
        double assigned = configurableSystemProcessorUnits - currentAvailableSystemProcessorUnits;
        assignedSystemProcessorUnit = MathUtils.round(assigned, 2);
    }

    public String getSupportedPartitionProcessorCompatibilityModes() {
        return supportedPartitionProcessorCompatibilityModes;
    }

    public void setSupportedPartitionProcessorCompatibilityModes(String supportedPartitionProcessorCompatibilityModes) {
        this.supportedPartitionProcessorCompatibilityModes = supportedPartitionProcessorCompatibilityModes;
    }
}
