AutoScalingGroupProjectConstant.java 8.09 KB
package com.ui.ctrl;

import org.apache.commons.lang.StringUtils;

/**
 * Created by craig.qin on 2017/8/23.
 */
public class AutoScalingGroupProjectConstant {
    public static String getProjectNames(String cloudType,String groupName){
        return getProjectsOrTags(cloudType,groupName,1);
    }

    public static String getTags(String cloudType,String groupName){
        return getProjectsOrTags(cloudType,groupName,2);
    }

    public static String getMobjectPaths(String cloudType,String groupName){
        return getProjectsOrTags(cloudType,groupName,3);
    }

    private static String getProjectsOrTags(String cloudType,String groupName,int retainProjectFlag){
        String projects="";
        String tags="";
        String mobjectPaths="";
        if("qcloud".equalsIgnoreCase(cloudType)){
            switch (groupName){
                case "gateway":
                    projects = "yoho-gateway";
                    tags = "java,gateway,";
                    mobjectPaths="YOHO,application,java_app,gateway";
                    break;
                case "resources-user":
                    projects = "yohobuy-resources,yoho-users";
                    tags = "java,users,resources,";
                    mobjectPaths="YOHO,application,java_app,resources-users";
                    break;
                case "product-message-sns":
                    projects = "yohobuy-product,yoho-message,yoho-sns";
                    tags = "java,product,message,sns,";
                    mobjectPaths="YOHO,application,java_app,product-message-sns";
                    break;
                case "order-promotion":
                    projects = "yohobuy-order,yohobuy-promotion";
                    tags = "java,promotion,order,";
                    mobjectPaths="YOHO,application,java_app,order-promotion";
                    break;
                case "activity-bigdata":
                    projects = "yohobuy-activity,yohobuy-bigdata";
                    tags = "java,activity,bigdata,";
                    mobjectPaths="YOHO,application,java_app,activity-bigdata";
                    break;
                case "uic-brower":
                    projects = "uic,yohobuy-brower";
                    tags = "java,uic,brower,";
                    mobjectPaths="YOHO,application,java_app,uic-brower";
                    break;

                /////**************** node项目 *****************/
                case "PCH5-AutoScaling":
                    projects = "YOHOBUY-PC-NODE,YOHOBUY-WAP-NODE,YOHOBLK-WAP";
                    tags = "PC/H5,BLK,node,";
                    break;

                /////**************** es类型 *****************/
                case "ELASTICSEARCH":
                    projects = "";
                    tags = "search-es,";
                    break;

                /////**************** nginx类型 *****************/
                case "java-nginx":
                    //////  只有tag projects="";
                    tags = "nginx,Nginx-JAVA,limit-switch,upstream-switch,";
                    mobjectPaths="YOHO,middleware,nginx,java_nginx,nginx_gateway";
                    break;
                case "pch5-nginx":
                    tags = "java,pch5,nginx,";
                    mobjectPaths="YOHO,middleware,nginx,pch5_nginx";
                    break;

                /////**************** memcache 类型 *****************/
                case "PCH5-memcache":
                    projects = "PCH5-memcache";
                    tags = "memcached,PC/H5,";
                    mobjectPaths="YOHO,middleware,memcached,qcloud_pc_h5";
                    break;
                case "java-gateway-memcache":
                    projects = "java-gateway-memcache";
                    tags = "java,memcached,";
                    mobjectPaths="YOHO,middleware,memcached,qcloud_java_gateway";
                    break;
            }
        }else if("aws".equalsIgnoreCase(cloudType)){
            switch (groupName){
                case "java-gateway":
                    projects = "yoho-gateway";
                    tags = "java,gateway,";
                    mobjectPaths="YOHO,application,java_app,gateway";
                    break;
                case "java-product-message-sns":
                    projects = "yohobuy-product,yoho-message,yoho-sns";
                    tags = "java,product,message,sns,";
                    mobjectPaths="YOHO,application,java_app,product-message-sns";
                    break;
                case "product-message-sns":
                    projects = "yohobuy-product,yoho-message,yoho-sns";
                    tags = "java,product,message,sns,";
                    mobjectPaths="YOHO,application,java_app,product-message-sns";
                    break;
                case "order-promotion":
                    projects = "yohobuy-order,yohobuy-promotion";
                    tags = "java,promotion,order,";
                    mobjectPaths="YOHO,application,java_app,order-promotion";
                    break;
                case "resources-user":
                    projects = "yohobuy-resources,yoho-users";
                    tags = "java,users,resources,";
                    mobjectPaths="YOHO,application,java_app,resources-users";
                    break;
                case "activity-bigdata":
                    projects = "yohobuy-activity,yohobuy-bigdata";
                    tags = "java,activity,bigdata,";
                    mobjectPaths="YOHO,application,java_app,activity-bigdata";
                    break;
                case "uic-brower":
                    projects = "uic,yohobuy-brower";
                    tags = "java,uic,brower,";
                    mobjectPaths="YOHO,application,java_app,uic-brower";
                    break;
                case "yoho-now":
                    projects = "yoho-now";
                    tags = "java,yohonow";
                    mobjectPaths="YOHO,application,java_app,yoho!now";
                    break;

                /////**************** node项目 *****************/
                case "PCH5-NODE":
                    projects = "YOHOBUY-PC-NODE,YOHOBUY-WAP-NODE,YOHOBLK-WAP";
                    tags = "PC/H5,BLK,node,";
                    break;

                /////**************** es类型 *****************/
                case "ELASTICSEARCH":
                    projects = "";
                    tags = "search-es,";
                    break;

                /////**************** nginx类型 *****************/
                case "java-nginx":
                    //////  只有tag projects="";
                    tags = "nginx,Nginx-JAVA,limit-switch,upstream-switch,";
                    mobjectPaths="YOHO,middleware,nginx,java_nginx,nginx_gateway";
                    break;
                case "pch5-nginx":
                    tags = "java,pch5,nginx,";
                    mobjectPaths="YOHO,middleware,nginx,pch5_nginx";
                    break;

                /////**************** memcache 类型 *****************/
                case "PCH5-memcache":
                    projects = "PCH5-memcache";
                    tags = "memcached,PC/H5,";
                    mobjectPaths="YOHO,middleware,memcached,aws_pc_h5";
                    break;
                case "java-gateway-memcache":
                    projects = "java-gateway-memcache";
                    tags = "java,memcached,";
                    mobjectPaths="YOHO,middleware,memcached,aws_java_gateway";
                    break;
            }
        }
        if(1==retainProjectFlag){
            if(StringUtils.isNotBlank(projects)){
                return projects;
            }else{
                return groupName;
            }
        }else if(2==retainProjectFlag){
            if(StringUtils.isNotBlank(tags)){
                return  tags;
            }else{
                if(groupName.contains("java")){
                    return groupName.replace("-",",")+",";
                }else{
                    return "java,"+groupName.replace("-",",")+",";
                }
            }
        }else if(3==retainProjectFlag){
            return mobjectPaths;
        }
        return "";
    }
}