All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.taobao.drc.clusterclient.clustermanager.PartitionInfo Maven / Gradle / Ivy

There is a newer version: 5.0.0.1.beta
Show newest version
package com.taobao.drc.clusterclient.clustermanager;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yangyang
 * @since 17/6/20
 */
public class PartitionInfo {
    private String guid;
    private String group;
    private String partition;

    private String topic;
    private Map tables;
    private Integer partitionId;
    private Integer partitionNum;

    private Integer errCode;
    private String errMsg;

    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getPartition() {
        return partition;
    }

    public void setPartition(String partition) {
        this.partition = partition;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public Map getTables() {
        return tables;
    }

    public void setTables(Map tables) {
        this.tables = tables;
    }

    public Integer getPartitionId() {
        return partitionId;
    }

    public void setPartitionId(Integer partitionId) {
        this.partitionId = partitionId;
    }

    public Integer getPartitionNum() {
        return partitionNum;
    }

    public void setPartitionNum(Integer partitionNum) {
        this.partitionNum = partitionNum;
    }

    public Integer getErrCode() {
        return errCode;
    }

    public void setErrCode(Integer errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    static public class TableDetail {
        private String name;
        private Map tables = new HashMap();

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Map getTables() {
            return tables;
        }

        public void setTables(Map tables) {
            this.tables = tables;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            TableDetail that = (TableDetail) o;

            if (name != null ? !name.equals(that.name) : that.name != null) return false;
            return tables != null ? tables.equals(that.tables) : that.tables == null;
        }

        @Override
        public int hashCode() {
            int result = name != null ? name.hashCode() : 0;
            result = 31 * result + (tables != null ? tables.hashCode() : 0);
            return result;
        }
    }

    public String makeFilterString() {
        if (getTables() == null || getTables().isEmpty()) {
            throw new IllegalStateException("Partition [" + partition + "] has no tables?");
        }

        StringBuilder builder = new StringBuilder();
        for (Map.Entry entry : getTables().entrySet()) {
            String dbName = entry.getKey();
            for (String tableName : entry.getValue().getTables().keySet()) {
                if (builder.length() > 0) {
                    builder.append("|");
                }
                builder.append(dbName).append(".").append(tableName).append(".*");
            }
        }
        return builder.toString();
    }

    @Override
    public String toString() {
    	String tableFilter ;
    	try
    	{
    		tableFilter = makeFilterString();
    	}catch(IllegalStateException e)
    	{
    		tableFilter="";
    	}
        return "PartitionInfo{" +
                "guid='" + guid + '\'' +
                ", group='" + group + '\'' +
                ", partition='" + partition + '\'' +
                ", topic='" + topic + '\'' +
                ", tables=" + tableFilter +
                ", partitionId=" + partitionId +
                ", partitionNum=" + partitionNum +
                ", errCode=" + errCode +
                ", errMsg='" + errMsg + '\'' +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy