package com.lanyuanxiaoyao.service.command.entity;

import cn.hutool.core.util.ObjectUtil;
import com.lanyuanxiaoyao.service.common.entity.TableMeta;
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnApplication;

/**
 * @author ZhangJiacheng
 * @date 2023-12-21
 */
public class TableMetaJob {
    private final TableMeta meta;
    private final YarnApplication application;

    public TableMetaJob(TableMeta meta, YarnApplication application) {
        this.meta = meta;
        this.application = application;
    }

    public TableMetaJob(TableMeta meta) {
        this(meta, null);
    }

    public Boolean isRunning() {
        return ObjectUtil.isNotNull(application);
    }

    public Boolean isNotRunning() {
        return ObjectUtil.isNull(application);
    }

    public Long getFlinkJobId() {
        return meta.getJob().getId();
    }

    public String getFlinkJobName() {
        return meta.getJob().getName();
    }

    public String getAlias() {
        return meta.getAlias();
    }

    public String getCluster() {
        return application.getCluster();
    }

    public String getId() {
        return application.getId();
    }

    public String getUser() {
        return application.getUser();
    }

    public String getQueue() {
        return application.getQueue();
    }

    public String getName() {
        return application.getName();
    }

    public String getState() {
        return application.getState();
    }

    public String getFinalStatus() {
        return application.getFinalStatus();
    }

    public Float getProgress() {
        return application.getProgress();
    }

    public String getDiagnostics() {
        return application.getDiagnostics();
    }

    public String getApplicationType() {
        return application.getApplicationType();
    }

    public Long getStartedTime() {
        return application.getStartedTime();
    }

    public Long getLaunchTime() {
        return application.getLaunchTime();
    }

    public Long getFinishedTime() {
        return application.getFinishedTime();
    }

    public Long getElapsedTime() {
        return application.getElapsedTime();
    }

    public String getTrackingUrl() {
        return application.getTrackingUrl();
    }

    public Long getAllocatedMB() {
        return application.getAllocatedMB();
    }

    public Long getAllocatedVCores() {
        return application.getAllocatedVCores();
    }

    public Integer getRunningContainers() {
        return application.getRunningContainers();
    }

    public Float getQueueUsagePercentage() {
        return application.getQueueUsagePercentage();
    }

    public Float getClusterUsagePercentage() {
        return application.getClusterUsagePercentage();
    }
}
